} /** * Runs all the code required to set up and save an essay question for testing purposes. * Alternate DB table prefix may be used to facilitate data deletion. */ function generate_test($name, $courseid = null) { list($form, $question) = parent::generate_test($name, $courseid); $question->category = $form->category; $form->questiontext = "How old is the sun?"; $form->generalfeedback = "General feedback"; $form->penalty = 0.1; $form->single = 1; $form->shuffleanswers = 1; $form->answernumbering = 'abc'; $form->noanswers = 3; $form->answer = array('Ancient', '5 billion years old', '4.5 billion years old'); $form->fraction = array(0.3, 0.9, 1); $form->feedback = array('True, but lacking in accuracy', 'Close, but no cigar!', 'Yep, that is it!'); $form->correctfeedback = 'Excellent!'; $form->incorrectfeedback = 'Nope!'; $form->partiallycorrectfeedback = 'Not bad'; if ($courseid) { $course = get_record('course', 'id', $courseid); } return $this->save_question($question, $form, $course); } } // Register this question type with the question bank. question_register_questiontype(new question_multichoice_qtype());
$formatoptions->para = false; // Print formulation $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course); $image = get_question_image($question); // Print each answer in a separate row if there are any $anss = array(); if ($answers) { foreach ($answers as $answer) { $a = new stdClass(); $a->text = format_text("{$answer->answer}", FORMAT_MOODLE, $formatoptions, $cmoptions->course); $anss[] = clone $a; } } include "{$CFG->dirroot}/question/type/missingtype/display.html"; } function grade_responses(&$question, &$state, $cmoptions) { return true; } function display_question_editing_page(&$mform, $question, $wizardnow) { print_heading(get_string('warningmissingtype', 'qtype_missingtype')); $mform->display(); } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_missingtype_qtype());
return wrsqz_restore_recode_answer_2('match', 'wmatprom', $info, $answers, $state, $restore); } function export_to_xml($question, $format, $extra = null) { return wrsqz_export_to_xml('match', 'wmatprom', $question, $format, $extra); } function import_from_xml($data, $question, $format, $extra = null) { return wrsqz_import_from_xml('match', 'wmatprom', $data, $question, $format, $extra); } /*Deprecated*/ function print_question_form_end($question, $submitscript = '', $hiddenfields = '') { wrsqz_print_question_form_end('match', 'wmatprom', $question, $submitscript, $hiddenfields); parent::print_question_form_end($question, $submitscript, $hiddenfields); } function display_question_editing_page(&$mform, $question, $wizardnow) { return wrsqz_display_question_editing_page('match', 'wmatprom', $mform, $question, $wizardnow); } function response_summary($question, $state, $length = 80) { return wrsqz_response_summary('match', 'wmatprom', $question, $state, $length); } } if (function_exists('question_register_questiontype')) { question_register_questiontype(new question_matchwiris_qtype()); } else { $QTYPES['matchwiris'] = new question_matchwiris_qtype(); $QTYPE_MENU['matchwiris'] = 'matchwiris'; }
$dataset_form->definition = array(1 => "1-0-a", 2 => "1-0-b"); $dataset_form->nextpageparam = array('forceregeneration' => false); $dataset_form->addbutton = 1; $dataset_form->selectadd = 1; $dataset_form->courseid = $courseid; $dataset_form->cmid = 0; $dataset_form->id = $new_question->id; $this->save_dataset_items($new_question, $dataset_form); return $new_question; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_calculatedobjects_qtype()); function qtype_calculatedobjects_calculate_answer($formula, $individualdata, $tolerance, $tolerancetype, $answerlength, $answerformat = '1', $unit = '') { /// The return value has these properties: /// ->answer the correct answer /// ->min the lower bound for an acceptable response /// ->max the upper bound for an accetpable response /// Exchange formula variables with the correct values... global $QTYPES; $answer = $QTYPES['calculatedobjects']->substitute_variables($formula, $individualdata); if ('1' == $answerformat) { /* Answer is to have $answerlength decimals */ /*** Adjust to the correct number of decimals ***/ if (stripos($answer, 'e') > 0) { $answerlengthadd = strlen($answer) - stripos($answer, 'e'); } else {
$webwork_info = $webworks[$i]; //Now, build the question_webwork record structure $webwork = new stdClass(); $webwork->question = $new_question_id; $webwork->codecheck = backup_todb($webwork_info['#']['CODECHECK']['0']['#']); $webwork->code = backup_todb($webwork_info['#']['CODE']['0']['#']); $webwork->grading = backup_todb($webwork_info['#']['GRADING']['0']['#']); //The structure is equal to the db, so insert the question_shortanswer $newid = insert_record("question_webwork", $webwork); //Do some output if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } if (!$newid) { $status = false; } } return $status; } } // Register this question type with the system. question_register_questiontype(new webwork_qtype()); ?>
$editlink = $this->get_question_edit_link($question, $cmoptions, $options); $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions); $image = get_question_image($question); $generalfeedback = ''; if ($isfinished && $options->generalfeedback) { $generalfeedback = $this->format_text($question->generalfeedback, $question->questiontextformat, $cmoptions); } include "{$CFG->dirroot}/question/type/description/question.html"; } function actual_number_of_questions($question) { /// Used for the feature number-of-questions-per-page /// to determine the actual number of questions wrapped /// by this question. /// The question type description is not even a question /// in itself so it will return ZERO! return 0; } function grade_responses(&$question, &$state, $cmoptions) { $state->raw_grade = 0; $state->penalty = 0; return true; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new description_qtype());
$fileresponses = $info['#']['FILERESPONSE']; // Iterate over fileresponses for ($i = 0; $i < sizeof($fileresponses); $i++) { $frinfo = $fileresponses[$i]; // Now, build the question_fileresponse record structure $fileresponse = new stdClass(); $fileresponse->question = $newquestion; $fileresponse->maxbytes = backup_todb($frinfo['#']['MAXBYTES']['0']['#']); $fileresponse->essay = backup_todb($frinfo['#']['ESSAY']['0']['#']); // The structure is equal to the db, so insert the question_fileresponse $newid = insert_record("question_fileresponse", $fileresponse); // Do some output if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } if (!$newid) { $status = false; } } return $status; } } // Register this question type with the system. question_register_questiontype(new fileresponse_qtype());
{ $placeholder_format = '\\{#[A-Za-z0-9]+\\}'; $err = null; foreach ($answers as $idx => $answer) { if (strlen($answer->placeholder) == 0) { continue; } // no error for empty placeholder if (strlen($answer->placeholder) >= 40) { $err->errors["placeholder[{$idx}]"] = get_string('error_placeholder_too_long', 'qtype_coordinates'); } if (!preg_match('/^' . $placeholder_format . '$/', $answer->placeholder)) { $err->errors["placeholder[{$idx}]"] .= get_string('error_placeholder_format', 'qtype_coordinates'); } $expl = explode($answer->placeholder, $questiontext); if (count($expl) < 2) { $err->errors["placeholder[{$idx}]"] .= get_string('error_placeholder_missing', 'qtype_coordinates'); } if (count($expl) > 2) { $err->errors["placeholder[{$idx}]"] .= get_string('error_placeholder_main_duplicate', 'qtype_coordinates'); } } if (isset($err->errors)) { $err->error = "Placeholder error"; } return $err; } } // Register this question type with the system. question_register_questiontype(new question_coordinates_qtype());
* @param $questionid the id of the question being backed up. * @param $level indent level in the backup file - so it can be formatted nicely. */ function backup($bf, $preferences, $questionid, $level = 6) { return question_backup_answers($bf, $preferences, $questionid, $level); } /** * Runs all the code required to set up and save an poodllrecording question for testing purposes. * Alternate DB table prefix may be used to facilitate data deletion. */ function generate_test($name, $courseid = null) { list($form, $question) = parent::generate_test($name, $courseid); $form->questiontext = "What is the purpose of life?"; $form->feedback = "feedback"; $form->generalfeedback = "General feedback"; $form->fraction = 0; $form->penalty = 0; if ($courseid) { $course = get_record('course', 'id', $courseid); } return $this->save_question($question, $form, $course); } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_poodllrecording_qtype());
} return $subqs; } public function render_cell($x, $y, $readonly = false, $showcorrect = false) { $base = $this->render_cell_base($x, $y, $readonly); if (empty($showcorrect)) { return $base; } $class = ''; $hasanswer = $this->has_answer($this->responses, $x, $y); $weight = array_key_exists($x, $this->weights) && array_key_exists($y, $this->weights[$x]) ? $this->weights[$x][$y] : 0; if ($hasanswer && $weight > 0) { $class = question_get_feedback_class(1); } else { if ($hasanswer && $weight < 0) { $class = question_get_feedback_class(0); } else { if (!$hasanswer && $weight > 0) { $class = question_get_feedback_class(0); } } } $weighttext = $weight ? '<span class="smalltext ' . $class . '">(' . $weight * 100 . '%)</span>' : ''; return $base . $weighttext; } } // end of grading subclasses // Register this question type with the system. question_register_questiontype(new matrix_qtype());
if (parent::backup($bf, $preferences, $question, $level) !== false) { return wrsqz_backup('multianswer', 'wmansprom', $bf, $preferences, $question, $level, $extra_question_fields, $question_id_column_name); } return false; } function restore($old_question_id, $new_question_id, $info, $restore) { if (parent::restore($old_question_id, $new_question_id, $info, $restore) !== false) { return wrsqz_restore('multianswer', 'wmansprom', $old_question_id, $new_question_id, $info, $restore); } return false; } function export_to_xml($question, $format, $extra = null) { return wrsqz_export_to_xml('multianswer', 'wmansprom', $question, $format, $extra); } function import_from_xml($data, $question, $format, $extra = null) { return wrsqz_import_from_xml('multianswer', 'wmansprom', $data, $question, $format, $extra); } function display_question_editing_page(&$mform, $question, $wizardnow) { return wrsqz_display_question_editing_page('multianswer', 'wmansprom', $mform, $question, $wizardnow); } } if (function_exists('question_register_questiontype')) { question_register_questiontype(new question_multianswerwiris_qtype()); } else { $QTYPES['multianswerwiris'] = new question_multianswerwiris_qtype(); $QTYPE_MENU['multianswerwiris'] = 'multianswerwiris'; }
/// RESTORE FUNCTIONS ///////////////// /* * Restores the data in the question * * This is used in question/restorelib.php */ function restore($old_question_id, $new_question_id, $info, $restore) { $status = true; //We have created every match_sub, now create the match $flash = new stdClass(); $flash->question = $new_question_id; // Get options $flash->width = backup_todb($info['#']['FLASHOPTIONS']['0']['#']['WIDTH']['0']['#']); $flash->height = backup_todb($info['#']['FLASHOPTIONS']['0']['#']['HEIGHT']['0']['#']); $flash->optionalfile = backup_todb($info['#']['FLASHOPTIONS']['0']['#']['OPTIONALFILE']['0']['#']); $flash->optionaldata = backup_todb($info['#']['FLASHOPTIONS']['0']['#']['OPTIONALDATA']['0']['#']); //The structure is equal to the db, so insert the question_match_sub $newid = insert_record('question_flash', $flash); if (!$newid) { $status = false; } return $status; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_flash_qtype());
$fileresponses = $info['#']['FILERESPONSE']; // Iterate over fileresponses for ($i = 0; $i < sizeof($fileresponses); $i++) { $frinfo = $fileresponses[$i]; // Now, build the question_fileresponse record structure $fileresponse = new stdClass(); $fileresponse->question = $newquestion; $fileresponse->maxbytes = backup_todb($frinfo['#']['MAXBYTES']['0']['#']); $fileresponse->essay = backup_todb($frinfo['#']['ESSAY']['0']['#']); // The structure is equal to the db, so insert the question_fileresponse $newid = insert_record("question_imagedit", $fileresponse); // Do some output if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } if (!$newid) { $status = false; } } return $status; } } // Register this question type with the system. question_register_questiontype(new imagedit_qtype());
} else { echo 'Could not recode truefalse answer id ' . $state->answer . ' for state ' . $state->oldid . '<br />'; } } } /** * Runs all the code required to set up and save an essay question for testing purposes. * Alternate DB table prefix may be used to facilitate data deletion. */ function generate_test($name, $courseid = null) { list($form, $question) = parent::generate_test($name, $courseid); $question->category = $form->category; $form->questiontext = "This question is really stupid"; $form->penalty = 1; $form->defaultgrade = 1; $form->correctanswer = 0; $form->feedbacktrue = array('Can you justify such a hasty judgment?'); $form->feedbackfalse = array('Wisdom has spoken!'); if ($courseid) { $course = get_record('course', 'id', $courseid); } return $this->save_question($question, $form, $course); } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_truefalse_qtype());
{ $status = true; // Decode links in the question_ddmatch_sub table. if ($subquestions = get_records_list('question_ddmatch_sub', 'question', implode(',', $questionids), '', 'id, questiontext')) { foreach ($subquestions as $subquestion) { $questiontext = restore_decode_content_links_worker($subquestion->questiontext, $restore); if ($questiontext != $subquestion->questiontext) { $subquestion->questiontext = addslashes($questiontext); if (!update_record('question_ddmatch_sub', $subquestion)) { $status = false; } } // Do some output. if (++$i % 5 == 0 && !defined('RESTORE_SILENTLY')) { echo "."; if ($i % 100 == 0) { echo "<br />"; } backup_flush(300); } } } return $status; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_ddmatch_qtype());
$algebra->disallow = backup_todb($alg_info['#']['DISALLOW']['0']['#']); $algebra->answerprefix = backup_todb($alg_info['#']['ANSWERPREFIX']['0']['#']); // Create an array to store the new variable IDs $newvarids = array(); // Restore the variables for this question $status = $status && $this->restore_variables($old_question_id, $new_question_id, $alg_info, $restore, $newvarids); // Convert the new variable IDs into a string to place in the question's data structure $algebra->variables = implode(',', $newvarids); // The structure is now equal to the db, so insert the question_algebra object // and check the the database insert call worked if (!insert_record('question_algebra', $algebra)) { echo get_string('qtype_algebra', 'restoreqdbfailed'), "\n"; $status = false; } // Generate output so that the user can see questions being restored if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } } return $status; } } // INITIATION - Without this line the question type is not in use. question_register_questiontype(new question_algebra_qtype());
{ // set "selectcount" from $count // this used to be ($count - 2) $question->selectcount = $count; // set "selecttype" from $type switch ($type) { case 'ALL': case 'EXACT': $question->selecttype = 0; break; case 'RANDOM': case 'REL': $question->selecttype = 1; break; case 'CONTIGUOUS': case 'CONTIG': $question->selecttype = 2; break; // otherwise // otherwise default: $question->selecttype = $default_type; } } } if ($register_question_type) { class question_ordering_qtype extends qtype_ordering { } question_register_questiontype(new question_ordering_qtype()); }
$dataset_form->definition = array(1 => "1-0-a", 2 => "1-0-b"); $dataset_form->nextpageparam = array('forceregeneration' => false); $dataset_form->addbutton = 1; $dataset_form->selectadd = 1; $dataset_form->courseid = $courseid; $dataset_form->cmid = 0; $dataset_form->id = $new_question->id; $this->save_dataset_items($new_question, $dataset_form); return $new_question; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_calculated_qtype()); function qtype_calculated_calculate_answer($formula, $individualdata, $tolerance, $tolerancetype, $answerlength, $answerformat = '1', $unit = '') { /// The return value has these properties: /// ->answer the correct answer /// ->min the lower bound for an acceptable response /// ->max the upper bound for an accetpable response /// Exchange formula variables with the correct values... global $QTYPES; $answer = $QTYPES['calculated']->substitute_variables($formula, $individualdata); if ('1' == $answerformat) { /* Answer is to have $answerlength decimals */ /*** Adjust to the correct number of decimals ***/ if (stripos($answer, 'e') > 0) { $answerlengthadd = strlen($answer) - stripos($answer, 'e'); } else {
$numerical->answer = backup_todb($num_info['#']['ANSWER']['0']['#']); $numerical->tolerance = backup_todb($num_info['#']['TOLERANCE']['0']['#']); //We have to recode the answer field $answer = backup_getid($restore->backup_unique_code, "question_answers", $numerical->answer); if ($answer) { $numerical->answer = $answer->new_id; } //The structure is equal to the db, so insert the question_numerical $newid = insert_record("question_numerical", $numerical); //Do some output if (($i + 1) % 50 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 1000 == 0) { echo "<br />"; } } backup_flush(300); } //Now restore numerical_units $status = question_restore_numerical_units($old_question_id, $new_question_id, $num_info, $restore); if (!$newid) { $status = false; } } return $status; } } // INITIATION - Without this line the question type is not in use. question_register_questiontype(new question_numerical_qtype());
$wrappedquestion = &$state->options->question; return $QTYPES[$wrappedquestion->qtype] ->get_texsource($wrappedquestion, $state, $cmoptions, $type); } function compare_responses(&$question, $state, $teststate) { global $QTYPES; $wrappedquestion = &$teststate->options->question; return $QTYPES[$wrappedquestion->qtype] ->compare_responses($wrappedquestion, $state, $teststate); } /** * For random question type return empty string which means won't calculate. * @param object $question * @return mixed either a integer score out of 1 that the average random * guess by a student might give or an empty string which means will not * calculate. */ function get_random_guess_score($question) { return ''; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new random_qtype());
//Get the question from backup_ids if (!($que = backup_getid($restore->backup_unique_code, "question", $question_id))) { echo 'Could not recode randomsamatch question ' . $question_id . '<br />'; } if ($answer_id == 0) { // no response yet $ans->new_id = 0; } else { //Get the answer from backup_ids if (!($ans = backup_getid($restore->backup_unique_code, "question_answers", $answer_id))) { echo 'Could not recode randomsamatch answer ' . $answer_id . '<br />'; } } if ($in_first) { $answer_field .= $que->new_id . "-" . $ans->new_id; $in_first = false; } else { $answer_field .= "," . $que->new_id . "-" . $ans->new_id; } //check for next $tok = strtok(","); } return $answer_field; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_randomsamatch_qtype());
$form->feedback = "feedback"; $form->generalfeedback = "General feedback"; $form->fraction = 0; $form->penalty = 0.1; $form->versioning = 0; if ($courseid) { $course = get_record('course', 'id', $courseid); } return $this->save_question($question, $form, $course); } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new embedded_cloze_qtype()); ///////////////////////////////////////////////////////////// //// ADDITIONAL FUNCTIONS //// The functions below deal exclusivly with editing //// of questions with question type 'multianswer'. //// Therefore they are kept in this file. //// They are not in the class as they are not //// likely to be subject for overriding. ///////////////////////////////////////////////////////////// // ANSWER_ALTERNATIVE regexes define("ANSWER_ALTERNATIVE_FRACTION_REGEX", '=|%(-?[0-9]+)%'); // for the syntax '(?<!' see http://www.perl.com/doc/manual/html/pod/perlre.html#item_C define("ANSWER_ALTERNATIVE_ANSWER_REGEX", '.+?(?<!\\\\|&|&)(?=[~#}]|$)'); define("ANSWER_ALTERNATIVE_FEEDBACK_REGEX", '.*?(?<!\\\\)(?=[~}]|$)'); define("ANSWER_ALTERNATIVE_REGEX", '(' . ANSWER_ALTERNATIVE_FRACTION_REGEX . ')?' . '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')' . '(#(' . ANSWER_ALTERNATIVE_FEEDBACK_REGEX . '))?'); // Parenthesis positions for ANSWER_ALTERNATIVE_REGEX
if ($state->last_graded->raw_grade > $state->last_graded->grade) { echo ' '; print_string('gradingdetailsadjustment', 'quiz', $grade); } // print info about new penalty // penalty is relevant only if the answer is not correct and further attempts are possible if ($state->last_graded->raw_grade < $question->maxgrade and QUESTION_EVENTCLOSEANDGRADE != $state->event) { if ('' !== $state->last_graded->penalty && (double) $state->last_graded->penalty > 0.0) { // A penalty was applied so display it echo ' '; print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty); } else { /* No penalty was applied even though the answer was not correct (eg. a syntax error) so tell the student that they were not penalised for the attempt */ echo ' '; print_string('gradingdetailszeropenalty', 'quiz'); } } } echo '</div>'; } } } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_shortanswer_qtype());
* @param $questionid the id of the question being backed up. * @param $level indent level in the backup file - so it can be formatted nicely. */ function backup($bf, $preferences, $questionid, $level = 6) { return question_backup_answers($bf, $preferences, $questionid, $level); } /** * Runs all the code required to set up and save an essay question for testing purposes. * Alternate DB table prefix may be used to facilitate data deletion. */ function generate_test($name, $courseid = null) { list($form, $question) = parent::generate_test($name, $courseid); $form->questiontext = "What is the purpose of life?"; $form->feedback = "feedback"; $form->generalfeedback = "General feedback"; $form->fraction = 0; $form->penalty = 0; if ($courseid) { $course = get_record('course', 'id', $courseid); } return $this->save_question($question, $form, $course); } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new question_essay_qtype());
$expout .= $format->writetext($question->options->feedbackmissed, 4, false); $expout .= " </feedbackmissed>\n"; $questionmedias = array(); $this->map_dragdrop_objects($question, $questionmedias, 1); for ($key = 1; $key <= count($question->options->media); $key++) { $expout .= " <media id=\"{$key}\">\n"; $expout .= $format->writetext($questionmedias['ddmedia[' . $key . ']'], 3, false); $expout .= $format->writeimage($questionmedias['ddmedia[' . $key . ']']); $expout .= " <questiontext>\n"; $expout .= $format->writetext($questionmedias['ddtext[' . $key . ']'], 4, false); $expout .= " </questiontext>\n"; $expout .= " <targetx>{$questionmedias['ddmediatargetx[' . $key . ']']}</targetx>\n "; $expout .= " <targety>{$questionmedias['ddmediatargety[' . $key . ']']}</targety>\n "; $expout .= " <displaywidth>{$questionmedias['ddmediadisplaywidth[' . $key . ']']}</displaywidth>\n "; $expout .= " <displayheight>{$questionmedias['ddmediadisplayheight[' . $key . ']']}</displayheight>\n "; $expout .= " <althotspot>{$questionmedias['althotspots[' . $key . ']']}</althotspot>\n "; $expout .= " <hotspotx>{$questionmedias['ddhotspotx[' . $key . ']']}</hotspotx>\n "; $expout .= " <hotspoty>{$questionmedias['ddhotspoty[' . $key . ']']}</hotspoty>\n "; $expout .= " <hotspotwidth>{$questionmedias['ddhotspotwidth[' . $key . ']']}</hotspotwidth>\n "; $expout .= " <hotspotheight>{$questionmedias['ddhotspotheight[' . $key . ']']}</hotspotheight>\n "; $expout .= " </media>\n"; } return $expout; } } //// END OF CLASS //// ////////////////////////////////////////////////////////////////////////// //// INITIATION - Without this line the question type is not in use... /// ////////////////////////////////////////////////////////////////////////// question_register_questiontype(new dragdrop_qtype());