From d544fb24ce8e95e69b0f4957e989d8d42fe57eb0 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Wed, 4 Apr 2012 12:58:02 +0700 Subject: [PATCH 1/5] MDL-47494 ddmarker: NOBUG added script to do upgrade automatically during 2.1 site upgrade --- question/type/ddmarker/db/install.php | 166 ++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 question/type/ddmarker/db/install.php diff --git a/question/type/ddmarker/db/install.php b/question/type/ddmarker/db/install.php new file mode 100644 index 00000000000..59a39eb8cb2 --- /dev/null +++ b/question/type/ddmarker/db/install.php @@ -0,0 +1,166 @@ +. + +/** + * Matching question type upgrade code. + * + * @package qtype + * @subpackage match + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +function index_array_of_records_by_key($key, $recs) { + $out = array(); + foreach ($recs as $id => $rec) { + if (!isset($out[$rec->{$key}])) { + $out[$rec->{$key}] = array(); + } + $out[$rec->{$key}][$id] = $rec; + } + return $out; +} + +function course_context_id($catcontextid) { + $context = get_context_instance_by_id($catcontextid); + while ($context->contextlevel != CONTEXT_COURSE) { + $context = get_context_instance_by_id(get_parent_contextid($context)); + } + return $context->id; +} +/** + * Upgrade code for the matching question type. + * @param int $oldversion the version we are upgrading from. + */ +function xmldb_qtype_ddmarker_install() { + global $DB, $OUTPUT; + + $from = 'FROM {question_categories} cat, {question} q'; + $where = ' WHERE q.qtype = \'imagetarget\' AND q.category = cat.id '; + + $sql = 'SELECT q.*, cat.contextid '.$from.$where.'ORDER BY cat.id, q.name'; + + $questions = $DB->get_records_sql($sql); + + if (!empty($questions)) { + foreach ($questions as $question) { + $dragssql = 'SELECT drag.* '.$from.', {qtype_ddmarker_drags} drag'.$where.' AND drag.questionid = q.id'; + $drags = index_array_of_records_by_key('questionid', $DB->get_records_sql($dragssql)); + + $dropssql = 'SELECT drop.* '.$from.', {qtype_ddmarker_drops} drop'.$where.' AND drop.questionid = q.id'; + $drops = index_array_of_records_by_key('questionid', $DB->get_records_sql($dropssql)); + + $answerssql = 'SELECT answer.* '.$from.', {question_answers} answer'.$where.' AND answer.question = q.id'; + $answers = index_array_of_records_by_key('question', $DB->get_records_sql($answerssql)); + + $imgfiles = $DB->get_records_sql_menu('SELECT question, qimage FROM {question_imagetarget}'); + + $correctfeedback = ''; + $correctfeedbackformat = 1; + $incorrectfeedback = ''; + $incorrectfeedbackformat = 1; + $foundincorrectanswer = false; + foreach ($answers[$question->id] as $answer) { + $no = 1; + if ('*' !== $answer->answer) { + $drop = new stdClass(); + $drop->questionid = $question->id; + $drop->shape = 'rectangle'; + $drop->no = $no; + list($x1, $y1, $x2, $y2) = explode(',', $answer->answer); + $width = $x2 - $x1; + $height = $y2 - $y1; + $drop->coords = "{$x1},{$y1};{$width},{$height}"; + $drop->choice = 1; + $DB->insert_record('qtype_ddmarker_drops', $drop); + $no++; + $correctfeedback = $answer->feedback; + $correctfeedbackformat = $answer->feedbackformat; + } else { + $foundincorrectanswer = false; + $incorrectfeedback = $answer->feedback; + $incorrectfeedbackformat = $answer->feedbackformat; + } + } + if (count($answers[$question->id]) < 2) { + echo $OUTPUT->notification('There are less than 2 answers. '. + '(Normally we expect at least a correct and incorrect answer). '. + 'For question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } + if (!$foundincorrectanswer) { + echo $OUTPUT->notification('No incorrect answer found for question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } + $drag = new stdClass(); + $drag->questionid = $question->id; + $drag->no = 1; + $drag->label = "X"; + $drag->infinite = 0; + $DB->insert_record('qtype_ddmarker_drags', $drag); + + $ddmarker = new stdClass(); + $ddmarker->questionid = $question->id; + $ddmarker->shuffleanswers = 0; + $ddmarker->correctfeedback = $correctfeedback; + $ddmarker->correctfeedbackformat = $correctfeedbackformat; + $ddmarker->partiallycorrectfeedback = ''; + $ddmarker->partiallycorrectfeedbackformat = 1; + $ddmarker->incorrectfeedback = $incorrectfeedback; + $ddmarker->incorrectfeedbackformat = $incorrectfeedbackformat; + $ddmarker->shownumcorrect = 0; + $ddmarker->showmisplaced = 0; + $DB->insert_record('qtype_ddmarker', $ddmarker); + + $newrec = clone($question); + unset($newrec->contextid); + $newrec->qtype = 'ddmarker'; + $newrec->timemodified = time(); + $DB->update_record('question', $newrec); + + $fs = get_file_storage(); + //we need to look in the course legacy files area for file + $bgimagefile = $fs->get_file(course_context_id($question->contextid), + 'course', + 'legacy', + '0', + '/'.dirname($imgfiles[$question->id]).'/', + basename($imgfiles[$question->id])); + if ($bgimagefile === false) { + echo $OUTPUT->notification('File "'.$imgfiles[$question->id].'" not found in legacy course files area. '. + 'For question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } else { + $newbgimagefile = new stdClass(); + $newbgimagefile->component = 'qtype_ddmarker'; + $newbgimagefile->filearea = 'bgimage'; + $newbgimagefile->filepath = '/'; + $newbgimagefile->itemid = $question->id; + $newbgimagefile->contextid = $question->contextid; + $fs->create_file_from_storedfile($newbgimagefile, $bgimagefile); + } + } + + list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($questions)); + $DB->delete_records_select('question_answers', 'question '.$qsql, $qparams); + $dbman = $DB->get_manager(); + $dbman->drop_table(new xmldb_table('question_imagetarget')); + } +} From 86529cb3abd489f79bb88070ee0cd6738a87c155 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Wed, 4 Apr 2012 14:42:40 +0700 Subject: [PATCH 2/5] MDL-47494 ddmarker: NOBUG refactoring so that automatic and manual conversion code is shared --- question/type/ddmarker/db/install.php | 141 +++--------------- question/type/ddmarker/db/upgradelib.php | 1 - .../type/ddmarker/imagetargetconverter.php | 69 +-------- question/type/ddmarker/lib.php | 98 ++++++++++++ 4 files changed, 124 insertions(+), 185 deletions(-) diff --git a/question/type/ddmarker/db/install.php b/question/type/ddmarker/db/install.php index 59a39eb8cb2..dfa98f087af 100644 --- a/question/type/ddmarker/db/install.php +++ b/question/type/ddmarker/db/install.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Matching question type upgrade code. + * ddmarker question type installation code. * * @package qtype * @subpackage match @@ -27,27 +27,8 @@ defined('MOODLE_INTERNAL') || die(); -function index_array_of_records_by_key($key, $recs) { - $out = array(); - foreach ($recs as $id => $rec) { - if (!isset($out[$rec->{$key}])) { - $out[$rec->{$key}] = array(); - } - $out[$rec->{$key}][$id] = $rec; - } - return $out; -} - -function course_context_id($catcontextid) { - $context = get_context_instance_by_id($catcontextid); - while ($context->contextlevel != CONTEXT_COURSE) { - $context = get_context_instance_by_id(get_parent_contextid($context)); - } - return $context->id; -} /** - * Upgrade code for the matching question type. - * @param int $oldversion the version we are upgrading from. + * Installation code for the ddmarker question type. It converts all existing imagetarget questions to ddmarker */ function xmldb_qtype_ddmarker_install() { global $DB, $OUTPUT; @@ -60,107 +41,33 @@ function xmldb_qtype_ddmarker_install() { $questions = $DB->get_records_sql($sql); if (!empty($questions)) { + require_once(dirname(__FILE__).'/../lib.php'); + $dragssql = 'SELECT drag.* '.$from.', {qtype_ddmarker_drags} drag'.$where.' AND drag.questionid = q.id'; + $drags = xmldb_qtype_ddmarker_index_array_of_records_by_key('questionid', $DB->get_records_sql($dragssql)); + + $dropssql = 'SELECT drop.* '.$from.', {qtype_ddmarker_drops} drop'.$where.' AND drop.questionid = q.id'; + $drops = xmldb_qtype_ddmarker_index_array_of_records_by_key('questionid', $DB->get_records_sql($dropssql)); + + $answerssql = 'SELECT answer.* '.$from.', {question_answers} answer'.$where.' AND answer.question = q.id'; + $answers = xmldb_qtype_ddmarker_index_array_of_records_by_key('question', $DB->get_records_sql($answerssql)); + + $imgfiles = $DB->get_records_sql_menu('SELECT question, qimage FROM {question_imagetarget}'); foreach ($questions as $question) { - $dragssql = 'SELECT drag.* '.$from.', {qtype_ddmarker_drags} drag'.$where.' AND drag.questionid = q.id'; - $drags = index_array_of_records_by_key('questionid', $DB->get_records_sql($dragssql)); - - $dropssql = 'SELECT drop.* '.$from.', {qtype_ddmarker_drops} drop'.$where.' AND drop.questionid = q.id'; - $drops = index_array_of_records_by_key('questionid', $DB->get_records_sql($dropssql)); - - $answerssql = 'SELECT answer.* '.$from.', {question_answers} answer'.$where.' AND answer.question = q.id'; - $answers = index_array_of_records_by_key('question', $DB->get_records_sql($answerssql)); - - $imgfiles = $DB->get_records_sql_menu('SELECT question, qimage FROM {question_imagetarget}'); - - $correctfeedback = ''; - $correctfeedbackformat = 1; - $incorrectfeedback = ''; - $incorrectfeedbackformat = 1; - $foundincorrectanswer = false; - foreach ($answers[$question->id] as $answer) { - $no = 1; - if ('*' !== $answer->answer) { - $drop = new stdClass(); - $drop->questionid = $question->id; - $drop->shape = 'rectangle'; - $drop->no = $no; - list($x1, $y1, $x2, $y2) = explode(',', $answer->answer); - $width = $x2 - $x1; - $height = $y2 - $y1; - $drop->coords = "{$x1},{$y1};{$width},{$height}"; - $drop->choice = 1; - $DB->insert_record('qtype_ddmarker_drops', $drop); - $no++; - $correctfeedback = $answer->feedback; - $correctfeedbackformat = $answer->feedbackformat; - } else { - $foundincorrectanswer = false; - $incorrectfeedback = $answer->feedback; - $incorrectfeedbackformat = $answer->feedbackformat; - } - } - if (count($answers[$question->id]) < 2) { - echo $OUTPUT->notification('There are less than 2 answers. '. - '(Normally we expect at least a correct and incorrect answer). '. - 'For question id '.$question->id.' "'.$question->name.'".', - 'notifyproblem'); - } - if (!$foundincorrectanswer) { - echo $OUTPUT->notification('No incorrect answer found for question id '.$question->id.' "'.$question->name.'".', - 'notifyproblem'); - } - $drag = new stdClass(); - $drag->questionid = $question->id; - $drag->no = 1; - $drag->label = "X"; - $drag->infinite = 0; - $DB->insert_record('qtype_ddmarker_drags', $drag); - - $ddmarker = new stdClass(); - $ddmarker->questionid = $question->id; - $ddmarker->shuffleanswers = 0; - $ddmarker->correctfeedback = $correctfeedback; - $ddmarker->correctfeedbackformat = $correctfeedbackformat; - $ddmarker->partiallycorrectfeedback = ''; - $ddmarker->partiallycorrectfeedbackformat = 1; - $ddmarker->incorrectfeedback = $incorrectfeedback; - $ddmarker->incorrectfeedbackformat = $incorrectfeedbackformat; - $ddmarker->shownumcorrect = 0; - $ddmarker->showmisplaced = 0; - $DB->insert_record('qtype_ddmarker', $ddmarker); - - $newrec = clone($question); - unset($newrec->contextid); - $newrec->qtype = 'ddmarker'; - $newrec->timemodified = time(); - $DB->update_record('question', $newrec); - - $fs = get_file_storage(); - //we need to look in the course legacy files area for file - $bgimagefile = $fs->get_file(course_context_id($question->contextid), - 'course', - 'legacy', - '0', - '/'.dirname($imgfiles[$question->id]).'/', - basename($imgfiles[$question->id])); - if ($bgimagefile === false) { - echo $OUTPUT->notification('File "'.$imgfiles[$question->id].'" not found in legacy course files area. '. - 'For question id '.$question->id.' "'.$question->name.'".', - 'notifyproblem'); - } else { - $newbgimagefile = new stdClass(); - $newbgimagefile->component = 'qtype_ddmarker'; - $newbgimagefile->filearea = 'bgimage'; - $newbgimagefile->filepath = '/'; - $newbgimagefile->itemid = $question->id; - $newbgimagefile->contextid = $question->contextid; - $fs->create_file_from_storedfile($newbgimagefile, $bgimagefile); - } + qtype_ddmarker_convert_image_target_question($question, $imgfiles[$question->id], $answers[$question->id]); } - list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($questions)); $DB->delete_records_select('question_answers', 'question '.$qsql, $qparams); $dbman = $DB->get_manager(); $dbman->drop_table(new xmldb_table('question_imagetarget')); } } +function xmldb_qtype_ddmarker_index_array_of_records_by_key($key, $recs) { + $out = array(); + foreach ($recs as $id => $rec) { + if (!isset($out[$rec->{$key}])) { + $out[$rec->{$key}] = array(); + } + $out[$rec->{$key}][$id] = $rec; + } + return $out; +} diff --git a/question/type/ddmarker/db/upgradelib.php b/question/type/ddmarker/db/upgradelib.php index 2ab9118ddb7..7c854a4c5c9 100644 --- a/question/type/ddmarker/db/upgradelib.php +++ b/question/type/ddmarker/db/upgradelib.php @@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die(); - /** * Class for converting attempt data from imagetarget questions when converting * attempts to the new question engine. diff --git a/question/type/ddmarker/imagetargetconverter.php b/question/type/ddmarker/imagetargetconverter.php index 6533917d38b..ebb8dece159 100644 --- a/question/type/ddmarker/imagetargetconverter.php +++ b/question/type/ddmarker/imagetargetconverter.php @@ -51,75 +51,9 @@ class qtype_ddmarker_question_converter_list_item extends qtype_ddmarker_questio public $imagetargetrecord = null; public $answers = array(); public function process($progresstrace = null, $depth = 0) { - $this->convert_question(); + qtype_ddmarker_convert_image_target_question($this->record, $this->imagetargetrecord->qimage, $this->answers); parent::process($progresstrace, $depth);//outputs progress message } - protected function convert_question() { - global $DB; - foreach ($this->answers as $answer) { - $no = 1; - if ('*' !== $answer->answer) { - $drop = new stdClass(); - $drop->questionid = $this->record->id; - $drop->shape = 'rectangle'; - $drop->no = $no; - list($x1, $y1, $x2, $y2) = explode(',', $answer->answer); - $width = $x2 - $x1; - $height = $y2 - $y1; - $drop->coords = "{$x1},{$y1};{$width},{$height}"; - $drop->choice = 1; - $DB->insert_record('qtype_ddmarker_drops', $drop); - $no++; - $correctfeedback = $answer->feedback; - $correctfeedbackformat = $answer->feedbackformat; - } else { - $incorrectfeedback = $answer->feedback; - $incorrectfeedbackformat = $answer->feedbackformat; - } - } - $drag = new stdClass(); - $drag->questionid = $this->record->id; - $drag->no = 1; - $drag->label = "X"; - $drag->infinite = 0; - $DB->insert_record('qtype_ddmarker_drags', $drag); - - $ddmarker = new stdClass(); - $ddmarker->questionid = $this->record->id; - $ddmarker->shuffleanswers = 0; - $ddmarker->correctfeedback = $correctfeedback; - $ddmarker->correctfeedbackformat = $correctfeedbackformat; - $ddmarker->partiallycorrectfeedback = ''; - $ddmarker->partiallycorrectfeedbackformat = 1; - $ddmarker->incorrectfeedback = $incorrectfeedback; - $ddmarker->incorrectfeedbackformat = $incorrectfeedbackformat; - $ddmarker->shownumcorrect = 0; - $ddmarker->showmisplaced = 0; - $DB->insert_record('qtype_ddmarker', $ddmarker); - - $newrec = clone($this->record); - unset($newrec->contextid); - $newrec->qtype = 'ddmarker'; - $newrec->timemodified = time(); - $DB->update_record('question', $newrec); - - $fs = get_file_storage(); - $bgimagefile = $fs->get_file($this->course_context_id(), - 'course', - 'legacy', - '0', - '/'.dirname($this->imagetargetrecord->qimage).'/', - basename($this->imagetargetrecord->qimage)); - $newbgimagefile = new stdClass(); - $newbgimagefile->component = 'qtype_ddmarker'; - $newbgimagefile->filearea = 'bgimage'; - $newbgimagefile->filepath = '/'; - $newbgimagefile->itemid = $this->record->id; - $fs->create_file_from_storedfile($newbgimagefile, $bgimagefile); - - $DB->delete_records('question_imagetarget', array('question' => $this->record->id)); - $DB->delete_records('question_answers', array('question' => $this->record->id)); - } } $categoryid = optional_param('categoryid', 0, PARAM_INT); @@ -197,6 +131,7 @@ if (!count($questions)) { echo $contextlist->render('listitemlist', true, $top); } } else if (confirm_sesskey()) { + require_once(dirname(__FILE__).'/lib.php'); $questionlist->prepare_for_processing($top); echo '
    '; $top->process(); diff --git a/question/type/ddmarker/lib.php b/question/type/ddmarker/lib.php index 7d2cb6d9bc0..2c7cdae3da3 100644 --- a/question/type/ddmarker/lib.php +++ b/question/type/ddmarker/lib.php @@ -36,3 +36,101 @@ function qtype_ddmarker_pluginfile($course, $cm, $context, $filearea, $args, $fo require_once($CFG->libdir . '/questionlib.php'); question_pluginfile($course, $context, 'qtype_ddmarker', $filearea, $args, $forcedownload); } + + + +function qtype_ddmarker_course_context_id($catcontextid) { + $context = get_context_instance_by_id($catcontextid); + while ($context->contextlevel != CONTEXT_COURSE) { + $context = get_context_instance_by_id(get_parent_contextid($context)); + } + return $context->id; +} + +function qtype_ddmarker_convert_image_target_question($question, $imgfilename, $answers) { + global $DB, $OUTPUT; + $correctfeedback = ''; + $correctfeedbackformat = 1; + $incorrectfeedback = ''; + $incorrectfeedbackformat = 1; + $foundincorrectanswer = false; + foreach ($answers as $answer) { + $no = 1; + if ('*' !== $answer->answer) { + $drop = new stdClass(); + $drop->questionid = $question->id; + $drop->shape = 'rectangle'; + $drop->no = $no; + list($x1, $y1, $x2, $y2) = explode(',', $answer->answer); + $width = $x2 - $x1; + $height = $y2 - $y1; + $drop->coords = "{$x1},{$y1};{$width},{$height}"; + $drop->choice = 1; + $DB->insert_record('qtype_ddmarker_drops', $drop); + $no++; + $correctfeedback = $answer->feedback; + $correctfeedbackformat = $answer->feedbackformat; + } else { + $foundincorrectanswer = true; + $incorrectfeedback = $answer->feedback; + $incorrectfeedbackformat = $answer->feedbackformat; + } + } + if (count($answers) < 2) { + echo $OUTPUT->notification('There are less than 2 answers. '. + '(Normally we expect at least a correct and incorrect answer). '. + 'For question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } + if (!$foundincorrectanswer) { + echo $OUTPUT->notification('No incorrect answer found for question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } + $drag = new stdClass(); + $drag->questionid = $question->id; + $drag->no = 1; + $drag->label = "X"; + $drag->infinite = 0; + $DB->insert_record('qtype_ddmarker_drags', $drag); + + $ddmarker = new stdClass(); + $ddmarker->questionid = $question->id; + $ddmarker->shuffleanswers = 0; + $ddmarker->correctfeedback = $correctfeedback; + $ddmarker->correctfeedbackformat = $correctfeedbackformat; + $ddmarker->partiallycorrectfeedback = ''; + $ddmarker->partiallycorrectfeedbackformat = 1; + $ddmarker->incorrectfeedback = $incorrectfeedback; + $ddmarker->incorrectfeedbackformat = $incorrectfeedbackformat; + $ddmarker->shownumcorrect = 0; + $ddmarker->showmisplaced = 0; + $DB->insert_record('qtype_ddmarker', $ddmarker); + + $newrec = clone($question); + unset($newrec->contextid); + $newrec->qtype = 'ddmarker'; + $newrec->timemodified = time(); + $DB->update_record('question', $newrec); + + $fs = get_file_storage(); + //we need to look in the course legacy files area for file + $bgimagefile = $fs->get_file(qtype_ddmarker_course_context_id($question->contextid), + 'course', + 'legacy', + '0', + '/'.dirname($imgfilename).'/', + basename($imgfilename)); + if ($bgimagefile === false) { + echo $OUTPUT->notification('File "'.$imgfilename.'" not found in legacy course files area. '. + 'For question id '.$question->id.' "'.$question->name.'".', + 'notifyproblem'); + } else { + $newbgimagefile = new stdClass(); + $newbgimagefile->component = 'qtype_ddmarker'; + $newbgimagefile->filearea = 'bgimage'; + $newbgimagefile->filepath = '/'; + $newbgimagefile->itemid = $question->id; + $newbgimagefile->contextid = $question->contextid; + $fs->create_file_from_storedfile($newbgimagefile, $bgimagefile); + } +} \ No newline at end of file From 34ec5ad14dd141ac5456148945ce5d8a41c24931 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Sat, 7 Apr 2012 14:23:18 +0700 Subject: [PATCH 3/5] MDL-47494 ddmarker: NOBUG made string for label into a constant so it is easy to change --- question/type/ddmarker/lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/question/type/ddmarker/lib.php b/question/type/ddmarker/lib.php index 2c7cdae3da3..fc09c0cfb8b 100644 --- a/question/type/ddmarker/lib.php +++ b/question/type/ddmarker/lib.php @@ -27,6 +27,11 @@ defined('MOODLE_INTERNAL') || die(); +/** + * + * @var string label to use for drag items when converting image target questions to ddmarker question type + */ +define('QTYPE_DDMARKER_LABEL_FOR_MARKER_FOR_IMAGE_TARGET_QS', 'X'); /** * Checks file access for essay questions. @@ -89,7 +94,7 @@ function qtype_ddmarker_convert_image_target_question($question, $imgfilename, $ $drag = new stdClass(); $drag->questionid = $question->id; $drag->no = 1; - $drag->label = "X"; + $drag->label = QTYPE_DDMARKER_LABEL_FOR_MARKER_FOR_IMAGE_TARGET_QS; $drag->infinite = 0; $DB->insert_record('qtype_ddmarker_drags', $drag); From 6a3b5993665040f974f8c1ed4ac4afe4b155785e Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Sat, 7 Apr 2012 14:24:25 +0700 Subject: [PATCH 4/5] MDL-47494 ddmarker: NOBUG added progress bar for question conversion during upgrade --- question/type/ddmarker/db/install.php | 5 +++++ question/type/ddmarker/lang/en/qtype_ddmarker.php | 1 + 2 files changed, 6 insertions(+) diff --git a/question/type/ddmarker/db/install.php b/question/type/ddmarker/db/install.php index dfa98f087af..98b000eebef 100644 --- a/question/type/ddmarker/db/install.php +++ b/question/type/ddmarker/db/install.php @@ -52,8 +52,13 @@ function xmldb_qtype_ddmarker_install() { $answers = xmldb_qtype_ddmarker_index_array_of_records_by_key('question', $DB->get_records_sql($answerssql)); $imgfiles = $DB->get_records_sql_menu('SELECT question, qimage FROM {question_imagetarget}'); + $progressbar = new progress_bar('qtype_ddmarker_convert_from_imagetarget'); + $progressbar->create(); + $done = 0; foreach ($questions as $question) { qtype_ddmarker_convert_image_target_question($question, $imgfiles[$question->id], $answers[$question->id]); + $done++; + $progressbar->update($done, count($questions), get_string('convertingimagetargetquestion', 'qtype_ddmarker', $question)); } list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($questions)); $DB->delete_records_select('question_answers', 'question '.$qsql, $qparams); diff --git a/question/type/ddmarker/lang/en/qtype_ddmarker.php b/question/type/ddmarker/lang/en/qtype_ddmarker.php index aa4cc9263b9..071be068250 100644 --- a/question/type/ddmarker/lang/en/qtype_ddmarker.php +++ b/question/type/ddmarker/lang/en/qtype_ddmarker.php @@ -29,6 +29,7 @@ $string['answer'] = 'Answer'; $string['bgimage'] = 'Background image'; $string['confirmimagetargetconversion'] = 'You are about to convert the above image target questions to the drag and drop markers question type.'; $string['coords'] = 'Coords'; +$string['convertingimagetargetquestion'] = 'Converted question "{$a->name}"'; $string['correctansweris'] = 'The correct answer is: {$a}'; $string['ddmarker'] = 'Drag and drop markers'; $string['ddmarker_help'] = 'select a background image file, enter text labels for markers and define the drop zones on the background image to which they must be dragged.'; From b409f1990e0037643fb63598d0ccd7d4d837556b Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Sat, 7 Apr 2012 14:34:58 +0700 Subject: [PATCH 5/5] MDL-47494 ddmarker: NOBUG fixing and updating tags in phpdoc comments --- .../backup/moodle2/backup_qtype_ddmarker_plugin.class.php | 7 ++++--- .../backup/moodle2/restore_qtype_ddmarker_plugin.class.php | 7 ++++--- question/type/ddmarker/db/install.php | 5 +++-- question/type/ddmarker/db/upgradelib.php | 3 ++- question/type/ddmarker/edit_ddmarker_form.php | 3 ++- question/type/ddmarker/imagetargetconverter.php | 3 ++- question/type/ddmarker/lang/en/qtype_ddmarker.php | 3 ++- question/type/ddmarker/lib.php | 6 +++--- question/type/ddmarker/question.php | 6 ++++-- question/type/ddmarker/questiontype.php | 3 ++- question/type/ddmarker/renderer.php | 6 ++++-- question/type/ddmarker/settings.php | 5 +++-- question/type/ddmarker/shapes.php | 6 ++++-- question/type/ddmarker/simpletest/helper.php | 6 ++++-- question/type/ddmarker/simpletest/testquestion.php | 6 ++++-- question/type/ddmarker/simpletest/testquestiontype.php | 6 ++++-- question/type/ddmarker/simpletest/testshapes.php | 3 ++- question/type/ddmarker/simpletest/testwalkthrough.php | 6 ++++-- question/type/ddmarker/version.php | 6 ++++-- 19 files changed, 61 insertions(+), 35 deletions(-) diff --git a/question/type/ddmarker/backup/moodle2/backup_qtype_ddmarker_plugin.class.php b/question/type/ddmarker/backup/moodle2/backup_qtype_ddmarker_plugin.class.php index d304edb9886..fc40930bc67 100644 --- a/question/type/ddmarker/backup/moodle2/backup_qtype_ddmarker_plugin.class.php +++ b/question/type/ddmarker/backup/moodle2/backup_qtype_ddmarker_plugin.class.php @@ -15,9 +15,10 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2011 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); diff --git a/question/type/ddmarker/backup/moodle2/restore_qtype_ddmarker_plugin.class.php b/question/type/ddmarker/backup/moodle2/restore_qtype_ddmarker_plugin.class.php index ea190807504..25e7233c479 100644 --- a/question/type/ddmarker/backup/moodle2/restore_qtype_ddmarker_plugin.class.php +++ b/question/type/ddmarker/backup/moodle2/restore_qtype_ddmarker_plugin.class.php @@ -15,9 +15,10 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2011 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/db/install.php b/question/type/ddmarker/db/install.php index 98b000eebef..45d415c6502 100644 --- a/question/type/ddmarker/db/install.php +++ b/question/type/ddmarker/db/install.php @@ -18,8 +18,9 @@ * ddmarker question type installation code. * * @package qtype - * @subpackage match - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/db/upgradelib.php b/question/type/ddmarker/db/upgradelib.php index 7c854a4c5c9..fd2e3810edd 100644 --- a/question/type/ddmarker/db/upgradelib.php +++ b/question/type/ddmarker/db/upgradelib.php @@ -20,7 +20,8 @@ * * @package qtype * @subpackage ddmarker - * @copyright 2012 Jamie Pratt + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/edit_ddmarker_form.php b/question/type/ddmarker/edit_ddmarker_form.php index 9fc2d8efe76..5969a3367d8 100644 --- a/question/type/ddmarker/edit_ddmarker_form.php +++ b/question/type/ddmarker/edit_ddmarker_form.php @@ -24,7 +24,8 @@ define('QTYPE_DDMARKER_ALLOWED_TAGS_IN_MARKER', '
    * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/imagetargetconverter.php b/question/type/ddmarker/imagetargetconverter.php index ebb8dece159..f5a99a66fea 100644 --- a/question/type/ddmarker/imagetargetconverter.php +++ b/question/type/ddmarker/imagetargetconverter.php @@ -19,7 +19,8 @@ * * @package qtype * @subpackage ddmarker - * @copyright 2012 Jamie Pratt + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/lang/en/qtype_ddmarker.php b/question/type/ddmarker/lang/en/qtype_ddmarker.php index 071be068250..30fb9b249e9 100644 --- a/question/type/ddmarker/lang/en/qtype_ddmarker.php +++ b/question/type/ddmarker/lang/en/qtype_ddmarker.php @@ -18,7 +18,8 @@ * * @package qtype * @subpackage ddmarker - * @copyright 2011 The Open University + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/lib.php b/question/type/ddmarker/lib.php index fc09c0cfb8b..2eb5d3bbbf6 100644 --- a/question/type/ddmarker/lib.php +++ b/question/type/ddmarker/lib.php @@ -17,10 +17,10 @@ /** * Serve question type files * - * @since 2.0 * @package qtype - * @subpackage essay - * @copyright Dongsheng Cai + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/question.php b/question/type/ddmarker/question.php index 22cb99e408d..568313d4b50 100644 --- a/question/type/ddmarker/question.php +++ b/question/type/ddmarker/question.php @@ -17,8 +17,10 @@ /** * Drag-and-drop markers question definition class. * - * @package qtype_ddmarker - * @copyright 2009 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/questiontype.php b/question/type/ddmarker/questiontype.php index 66ffaf7cf61..e65d7945459 100644 --- a/question/type/ddmarker/questiontype.php +++ b/question/type/ddmarker/questiontype.php @@ -19,7 +19,8 @@ * * @package qtype * @subpackage ddmarker - * @copyright 2009 The Open University + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/renderer.php b/question/type/ddmarker/renderer.php index 0c047631d22..ef1285dd1f9 100644 --- a/question/type/ddmarker/renderer.php +++ b/question/type/ddmarker/renderer.php @@ -17,8 +17,10 @@ /** * Drag-and-drop markers question renderer class. * - * @package qtype_ddmarker - * @copyright 2010 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/settings.php b/question/type/ddmarker/settings.php index a523f7128df..e79d78ef513 100644 --- a/question/type/ddmarker/settings.php +++ b/question/type/ddmarker/settings.php @@ -18,8 +18,9 @@ * Admin settings for the Opaque question type. * * @package qtype - * @subpackage opaque - * @copyright 2011 The Open University + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/shapes.php b/question/type/ddmarker/shapes.php index eae350ced22..e645fc76b55 100644 --- a/question/type/ddmarker/shapes.php +++ b/question/type/ddmarker/shapes.php @@ -17,8 +17,10 @@ /** * Drag-and-drop markers classes for dealing with shapes on the server side. * - * @package qtype_ddmarker - * @copyright 2009 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class qtype_ddmarker_shape { diff --git a/question/type/ddmarker/simpletest/helper.php b/question/type/ddmarker/simpletest/helper.php index 1c773da62d3..a78d3e08bcf 100644 --- a/question/type/ddmarker/simpletest/helper.php +++ b/question/type/ddmarker/simpletest/helper.php @@ -17,8 +17,10 @@ /** * Test helpers for the drag-and-drop markers question type. * - * @package qtype_ddmarker - * @copyright 2010 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/simpletest/testquestion.php b/question/type/ddmarker/simpletest/testquestion.php index 705f95a49d0..7d1cafd86e1 100644 --- a/question/type/ddmarker/simpletest/testquestion.php +++ b/question/type/ddmarker/simpletest/testquestion.php @@ -17,8 +17,10 @@ /** * Unit tests for the drag-and-drop markers question definition class. * - * @package qtype_ddmarker - * @copyright 2010 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/simpletest/testquestiontype.php b/question/type/ddmarker/simpletest/testquestiontype.php index 63d0cdd1e7d..4c0b632a46f 100644 --- a/question/type/ddmarker/simpletest/testquestiontype.php +++ b/question/type/ddmarker/simpletest/testquestiontype.php @@ -17,8 +17,10 @@ /** * Unit tests for the drag-and-drop markers question definition class. * - * @package qtype_ddmarker - * @copyright 2010 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/simpletest/testshapes.php b/question/type/ddmarker/simpletest/testshapes.php index 42f8a5bfa0b..17279fc1036 100644 --- a/question/type/ddmarker/simpletest/testshapes.php +++ b/question/type/ddmarker/simpletest/testshapes.php @@ -19,7 +19,8 @@ * * @package qtype * @subpackage ddmarker - * @copyright 2010 The Open University + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/simpletest/testwalkthrough.php b/question/type/ddmarker/simpletest/testwalkthrough.php index 62411531aa9..3fc1a9187a5 100644 --- a/question/type/ddmarker/simpletest/testwalkthrough.php +++ b/question/type/ddmarker/simpletest/testwalkthrough.php @@ -17,8 +17,10 @@ /** * Unit tests for the drag-and-drop markers question type. * - * @package qtype_ddmarker - * @copyright 2010 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/question/type/ddmarker/version.php b/question/type/ddmarker/version.php index d62ee1c6466..8a7e2b24259 100644 --- a/question/type/ddmarker/version.php +++ b/question/type/ddmarker/version.php @@ -17,8 +17,10 @@ /** * Version information for the drag-and-drop markers question type. * - * @package qtype_ddmarker - * @copyright 2011 The Open University + * @package qtype + * @subpackage ddmarker + * @copyright 2012 The Open University + * @author Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */