public function on_generate_feedbacks() { parent::on_generate_feedbacks(); // Question combined feedback. $responsenodes = $this->questions->nodeList('plugin_qtype_shortanswer_question//answer', $this->question_node); $count = 0; foreach ($responsenodes as $respnode) { $content = $this->questions->nodeValue('feedback', $respnode); if (empty($content)) { continue; } $correct = (int) $this->questions->nodeValue('fraction', $respnode) == 1; $answerid = (int) $this->questions->nodeValue('@id', $respnode); $result = cc_helpers::process_linked_files($content, $this->manifest, $this->rootpath, $this->contextid, $this->outdir); $ident = $correct ? 'correct' : 'incorrect'; $ident .= '_' . $count . '_fb'; cc_assesment_helper::add_feedback($this->qitem, $result[0], cc_qti_values::htmltype, $ident); pkg_resource_dependencies::instance()->add($result[1]); if ($correct) { $this->correct_feedbacks[$answerid] = $ident; } else { $this->incorrect_feedbacks[$answerid] = $ident; } ++$count; } }
public function convert($outdir) { $rt = new basicltil1_resurce_file(); $contextid = $this->doc->nodeValue('/activity/@contextid'); $title = $this->doc->nodeValue('/activity/lti/name'); $text = $this->doc->nodeValue('/activity/lti/intro'); $rt->set_title($title); $result = cc_helpers::process_linked_files($text, $this->manifest, $this->rootpath, $contextid, $outdir); $rt->set_description($result[0]); $rt->set_launch_url($this->doc->nodeValue('/activity/lti/toolurl')); $rt->set_launch_icon(''); $this->store($rt, $outdir, $title, $result[1]); return true; }
public function convert($outdir) { $rt = new assesment11_resurce_file(); $title = $this->doc->nodeValue('/activity/quiz/name'); $rt->set_title($title); // Metadata. $metadata = new cc_assesment_metadata(); $rt->set_metadata($metadata); $metadata->enable_feedback(); $metadata->enable_hints(); $metadata->enable_solutions(); // Attempts. $max_attempts = (int) $this->doc->nodeValue('/activity/quiz/attempts_number'); if ($max_attempts > 0) { // Qti does not support number of specific attempts bigger than 5 (??) if ($max_attempts > 5) { $max_attempts = cc_qti_values::unlimited; } $metadata->set_maxattempts($max_attempts); } // Time limit must be converted into minutes. $timelimit = (int) floor((int) $this->doc->nodeValue('/activity/quiz/timelimit') / 60); if ($timelimit > 0) { $metadata->set_timelimit($timelimit); $metadata->enable_latesubmissions(false); } $contextid = $this->doc->nodeValue('/activity/@contextid'); $result = cc_helpers::process_linked_files($this->doc->nodeValue('/activity/quiz/intro'), $this->manifest, $this->rootpath, $contextid, $outdir); cc_assesment_helper::add_assesment_description($rt, $result[0], cc_qti_values::htmltype); // Section. $section = new cc_assesment_section(); $rt->set_section($section); // Process the actual questions. $ndeps = cc_assesment_helper::process_questions($this->doc, $this->manifest, $section, $this->rootpath, $contextid, $outdir); if ($ndeps === false) { // No exportable questions in quiz or quiz has no questions // so just skip it. return true; } // Store any additional dependencies. $deps = array_merge($result[1], $ndeps); // Store everything. $this->store($rt, $outdir, $title, $deps); return true; }
public function convert($outdir) { $rt = new forum11_resurce_file(); $title = $this->doc->nodeValue('/activity/forum/name'); $rt->set_title($title); $text = $this->doc->nodeValue('/activity/forum/intro'); $deps = null; if (!empty($text)) { $textformat = intval($this->doc->nodeValue('/activity/forum/introformat')); $contextid = $this->doc->nodeValue('/activity/@contextid'); $result = cc_helpers::process_linked_files($text, $this->manifest, $this->rootpath, $contextid, $outdir); $textformat = $textformat == 1 ? 'text/html' : 'text/plain'; $rt->set_text($result[0], $textformat); $deps = $result[1]; } $this->store($rt, $outdir, $title, $deps); return true; }
public function convert($outdir) { $rt = new page11_resurce_file(); $title = $this->doc->nodeValue('/activity/page/name'); $intro = $this->doc->nodeValue('/activity/page/intro'); $contextid = $this->doc->nodeValue('/activity/@contextid'); $pagecontent = $this->doc->nodeValue('/activity/page/content'); $rt->set_title($title); $rawname = str_replace(' ', '_', strtolower(trim(clean_param($title, PARAM_FILE)))); if (!empty($rawname)) { $this->defaultname = $rawname . ".html"; } $result = cc_helpers::process_linked_files($pagecontent, $this->manifest, $this->rootpath, $contextid, $outdir, true); $rt->set_content($result[0]); $rt->set_intro($intro); //store everything $this->store($rt, $outdir, $title, $result[1]); return true; }
public function on_generate_answers() { // Add responses holder. $qresponse_lid = new cc_response_lidtype(); $this->qresponse_lid = $qresponse_lid; $this->qpresentation->set_response_lid($qresponse_lid); $qresponse_choice = new cc_assesment_render_choicetype(); $qresponse_lid->set_render_choice($qresponse_choice); // Mark that question has only one correct answer - // which applies for multiple choice and yes/no questions. $qresponse_lid->set_rcardinality(cc_qti_values::Single); // Are we to shuffle the responses? $shuffle_answers = (int) $this->quiz->nodeValue('/activity/quiz/shuffleanswers') > 0; $qresponse_choice->enable_shuffle($shuffle_answers); $answerlist = array(); $qa_responses = $this->questions->nodeList('plugin_qtype_truefalse_question/answers/answer', $this->question_node); foreach ($qa_responses as $node) { $answer_content = $this->questions->nodeValue('answertext', $node); $id = (int) $this->questions->nodeValue('@id', $node) == $this->correct_answer_node_id; $qresponse_label = cc_assesment_helper::add_answer($qresponse_choice, $answer_content, cc_qti_values::htmltype); $answer_ident = strtolower(trim($answer_content)); $qresponse_label->set_ident($answer_ident); $feedback_ident = $id ? 'correct_fb' : 'incorrect_fb'; if (empty($this->correct_answer_ident) && $id) { $this->correct_answer_ident = $answer_ident; } // Add answer specific feedback if not empty. $content = $this->questions->nodeValue('feedback', $node); if (!empty($content)) { $result = cc_helpers::process_linked_files($content, $this->manifest, $this->rootpath, $this->contextid, $this->outdir); cc_assesment_helper::add_feedback($this->qitem, $result[0], cc_qti_values::htmltype, $feedback_ident); pkg_resource_dependencies::instance()->add($result[1]); $answerlist[$answer_ident] = $feedback_ident; } } $this->answerlist = $answerlist; }
public function on_generate_feedbacks() { parent::on_generate_feedbacks(); //Question combined feedbacks $correct_question_fb = $this->questions->nodeValue('plugin_qtype_multichoice_question/multichoice/correctfeedback', $this->question_node); $incorrect_question_fb = $this->questions->nodeValue('plugin_qtype_multichoice_question/multichoice/incorrectfeedback', $this->question_node); if (empty($correct_question_fb)) { //Hardcode some text for now $correct_question_fb = 'Well done!'; } if (empty($incorrect_question_fb)) { //Hardcode some text for now $incorrect_question_fb = 'Better luck next time!'; } $proc = array('correct_fb' => $correct_question_fb, 'incorrect_fb' => $incorrect_question_fb); foreach ($proc as $ident => $content) { if (empty($content)) { continue; } $result = cc_helpers::process_linked_files($content, $this->manifest, $this->rootpath, $this->contextid, $this->outdir); cc_assesment_helper::add_feedback($this->qitem, $result[0], cc_qti_values::htmltype, $ident); pkg_resource_dependencies::instance()->add($result[1]); if ($ident == 'correct_fb') { $this->correct_feedbacks[$ident] = $ident; } else { $this->incorrect_feedbacks[$ident] = $ident; } } }