MDL-29956: Implement common cartridge export (r16882)
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
3319af85a9
commit
42dffc6feb
@@ -17,14 +17,13 @@
|
||||
* @package moodlecore
|
||||
* @subpackage backup-imscc
|
||||
* @copyright 2009 Mauro Rondinelli (mauro.rondinelli [AT] uvcms.com)
|
||||
* @copyright 2011 Darko Miletic ([email protected])
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
class quiz extends entities {
|
||||
|
||||
private $namespaces = array('xmlns' => 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2');
|
||||
class cc_quiz extends entities {
|
||||
|
||||
public function generate_node_question_categories () {
|
||||
|
||||
@@ -141,15 +140,15 @@ class quiz extends entities {
|
||||
'[#node_questions_feedback#]');
|
||||
|
||||
$replace_values = array($instance['id'],
|
||||
$instance['title'],
|
||||
$instance['title'],
|
||||
$quiz_stamp,
|
||||
$questions_strings,
|
||||
htmlentities($instance['title']),
|
||||
htmlentities($instance['title']),
|
||||
htmlentities($quiz_stamp),
|
||||
htmlentities($questions_strings),
|
||||
time(),
|
||||
$instance['options']['max_attempts'],
|
||||
$instance['options']['timelimit'],
|
||||
$node_course_modules_quiz_question_instances,
|
||||
$node_course_modules_quiz_feedback);
|
||||
$node_course_modules_quiz_feedback); //this one has tags
|
||||
|
||||
$node_question_mod = str_replace($find_tags, $replace_values, $sheet_question_mod);
|
||||
|
||||
@@ -158,7 +157,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_global_config ($assessment, $option, $default_value, $replace_values = '') {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
$metadata = $xpath->query('/xmlns:questestinterop/xmlns:assessment/xmlns:qtimetadata/xmlns:qtimetadatafield');
|
||||
|
||||
foreach ($metadata as $field) {
|
||||
@@ -257,7 +256,7 @@ class quiz extends entities {
|
||||
$quiz_stamp = 'localhost+' . time() . '+' . $this->generate_random_string(6);
|
||||
|
||||
$replace_values = array($instance['id'],
|
||||
$instance['title'],
|
||||
htmlentities($instance['title']),
|
||||
$quiz_stamp,
|
||||
$node_course_question_categories_questions);
|
||||
|
||||
@@ -305,10 +304,10 @@ class quiz extends entities {
|
||||
$question_type_node = ($question_moodle_type == MOODLE_QUIZ_SHORTANSWER) ? $this->create_node_course_question_categories_question_category_question_shortanswer($question) : $question_type_node;
|
||||
|
||||
$replace_values = array($question['id'],
|
||||
$this->truncate_text($question['title'], 255, true),
|
||||
$question['title'],
|
||||
htmlentities($this->truncate_text($question['title'], 255, true)),
|
||||
htmlentities($question['title']),
|
||||
$question_moodle_type,
|
||||
$question['feedback'],
|
||||
htmlentities($question['feedback']),
|
||||
time(),
|
||||
$question_type_node,
|
||||
$quiz_stamp,
|
||||
@@ -328,7 +327,7 @@ class quiz extends entities {
|
||||
|
||||
$questions = array();
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
if (!$is_question_bank) {
|
||||
$questions_items = $xpath->query('/xmlns:questestinterop/xmlns:assessment/xmlns:section/xmlns:item');
|
||||
@@ -398,7 +397,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_general_feedback ($assessment, $question_identifier) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$respconditions = $xpath->query('//xmlns:item[@ident="' . $question_identifier . '"]/xmlns:resprocessing/xmlns:respcondition');
|
||||
|
||||
@@ -443,7 +442,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_feedback ($assessment, $identifier, $item_identifier, $question_type) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$resource_processing = $xpath->query('//xmlns:item[@ident="' . $item_identifier . '"]/xmlns:resprocessing/xmlns:respcondition');
|
||||
|
||||
@@ -488,7 +487,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_answers_fib ($question_identifier, $identifier, $assessment, &$last_answer_id) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$answers_fib = array();
|
||||
|
||||
@@ -554,7 +553,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_answers_pattern_match ($question_identifier, $identifier, $assessment, &$last_answer_id) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$answers_fib = array();
|
||||
|
||||
@@ -630,7 +629,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_answers ($identifier, $assessment, &$last_answer_id) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$answers = array();
|
||||
|
||||
@@ -719,7 +718,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_score ($assessment, $identifier, $question_identifier) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$resource_processing = $xpath->query('//xmlns:item[@ident="' . $question_identifier . '"]/xmlns:resprocessing/xmlns:respcondition');
|
||||
|
||||
@@ -765,7 +764,7 @@ class quiz extends entities {
|
||||
'[#is_single#]');
|
||||
|
||||
$replace_values = array($node_course_question_categories_question_answer,
|
||||
$answer_string,
|
||||
htmlentities($answer_string),
|
||||
$is_single);
|
||||
|
||||
$node_question_categories_question = str_replace($find_tags, $replace_values, $sheet_question_categories_question);
|
||||
@@ -820,8 +819,8 @@ class quiz extends entities {
|
||||
'[#use_case#]',
|
||||
'[#node_course_question_categories_question_category_question_answer#]');
|
||||
|
||||
$replace_values = array($answers_string,
|
||||
$use_case,
|
||||
$replace_values = array(htmlentities($answers_string),
|
||||
htmlentities($use_case),
|
||||
$node_course_question_categories_question_answer);
|
||||
|
||||
|
||||
@@ -867,7 +866,7 @@ class quiz extends entities {
|
||||
'[#false_answer_id#]');
|
||||
|
||||
$replace_values = array($node_course_question_categories_question_answer,
|
||||
$true_answer_id,
|
||||
htmlentities($true_answer_id),
|
||||
$false_answer_id);
|
||||
|
||||
$node_question_categories_question = str_replace($find_tags, $replace_values, $sheet_question_categories_question);
|
||||
@@ -901,7 +900,7 @@ class quiz extends entities {
|
||||
'[#answer_feedback#]');
|
||||
|
||||
$replace_values = array($answer['id'],
|
||||
$answer['title'],
|
||||
htmlentities($answer['title']),
|
||||
$answer['score'],
|
||||
$answer['feedback']);
|
||||
|
||||
@@ -912,7 +911,7 @@ class quiz extends entities {
|
||||
|
||||
private function get_question_type ($identifier, $assessment) {
|
||||
|
||||
$xpath = cc2moodle::newx_path($assessment, $this->namespaces);
|
||||
$xpath = cc2moodle::newx_path($assessment, cc2moodle::getquizns());
|
||||
|
||||
$metadata = $xpath->query('//xmlns:item[@ident="' . $identifier . '"]/xmlns:itemmetadata/xmlns:qtimetadata/xmlns:qtimetadatafield');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user