📄 qti_classes.php
字号:
// Only add references for actually existing comments/feedbacks. if( !empty($this->trueFeedback) ) { $out.= ' <displayfeedback feedbacktype="Response" linkrefid="' . $this->trueFeedback . '" />' . "\n"; } $out .= '</respcondition>' . "\n"; // false $response_ident = $questionIdent. '_A_false'; $feedback_ident = $questionIdent . '_F_false'; $condition_ident = $questionIdent . '_C_false'; $out .= '<respcondition title="' . $condition_ident . '"><conditionvar>' . "\n" . ' <varequal respident="TF_' . $questionIdent . '">' . $response_ident . '</varequal>' . "\n" . ' </conditionvar>' . "\n" . ' <setvar action="Add">' . $this->falseGrade . '</setvar>' . "\n"; // Only add references for actually existing comments/feedbacks. if( !empty($this->falseFeedback) ) { $out.= ' <displayfeedback feedbacktype="Response" linkrefid="' . $feedback_ident . '" />' . "\n"; } $out .= '</respcondition>' . "\n"; return $out; } /** * Export the feedback (comments to selected answers) to IMS/QTI * * @author Amand Tihon <amand@alrj.org> */ function imsExportFeedback($questionIdent) { $out = ""; if( !empty($this->trueFeedback) ) { $feedback_ident = $questionIdent . '_F_true'; $out.= '<itemfeedback ident="' . $feedback_ident . '" view="Candidate"><flow_mat><material>' . "\n" . ' <mattext><![CDATA[' . $this->trueFeedback . "]]></mattext>\n" . "</material></flow_mat></itemfeedback>\n"; } if( !empty($this->falseFeedback) ) { $feedback_ident = $questionIdent . '_F_false'; $out.= '<itemfeedback ident="' . $feedback_ident . '" view="Candidate"><flow_mat><material>' . "\n" . ' <mattext><![CDATA[' . $this->falseFeedback . "]]></mattext>\n" . "</material></flow_mat></itemfeedback>\n"; } return $out; }}class ImsAnswerFillInBlanks extends answerFillInBlanks { /** * Export the text with missing words. * * As a side effect, it stores two lists in the class : * the missing words and their respective weightings. * * @author Amand Tihon <amand@alrj.org> */ function imsExportResponses($questionIdent) { global $charset; $out = "<flow>\n"; $responsePart = explode(']', $this->answer); $i = 0; // Used for the reference generation. foreach($responsePart as $part) { $response_ident = $questionIdent . "_A_" . $i; if( strpos($part,'[') !== false ) { list($rawText, $blank) = explode('[', $part); } else { $rawText = $part; $blank = ""; } if ($rawText!="") { $out.=" <material><mattext><![CDATA[" . $rawText . "]]></mattext></material>\n"; } if ($blank!="") { $out.= ' <response_str ident="' . $response_ident . '" rcardinality="Single" rtiming="No">' . "\n" . ' <render_fib fibtype="String" prompt="Box" encoding="' . $charset . '">' . "\n" . ' <response_label ident="A"/>' . "\n" . " </render_fib>\n" . " </response_str>\n"; } $i++; } $out.="</flow>\n"; return $out; } /** * Exports the response processing. * * It uses the two lists build by export_responses(). This implies that export_responses MUST * be called before. * * @author Amand Tihon <amand@alrj.org> */ function imsExportProcessing($questionIdent) { $out = ""; $answerCount = count($this->answerList); for( $i = 0; $i < $answerCount ; $i++ ) { $response_ident = $questionIdent . "_A_" . $i; $out.= ' <respcondition continue="Yes"><conditionvar>' . "\n" . ' <varequal respident="' . $response_ident . '" case="No"><![CDATA[' . $this->answerList[$i] . ']]></varequal>' . "\n" . ' </conditionvar><setvar action="Add">' . $this->gradeList[$i] . "</setvar>\n" . " </respcondition>\n"; } return $out; } /** * Export the feedback (comments to selected answers) to IMS/QTI * * @author Amand Tihon <amand@alrj.org> */ function imsExportFeedback($questionIdent) { // no feedback in this question type return ''; } /** * allow to import the answers, feedbacks, and grades of a question * * @param questionArray is an array that must contain all the information needed to build the question * @author Guillaume Lederer <guillaume@claroline.net> */ function import($questionArray) { $answerArray = $questionArray['answer']; $this->answerText = str_replace ("\n","",$questionArray['response_text']); if ($questionArray['subtype'] == "TEXTFIELD_FILL") $this->type = TEXTFIELD_FILL; if ($questionArray['subtype'] == "LISTBOX_FILL") { $this->wrongAnswerList = $questionArray['wrong_answers']; $this->type = LISTBOX_FILL; } //build correct_answsers array if (isset($questionArray['weighting'])) { $this->gradeList = $questionArray['weighting']; } }}class ImsAnswerMatching extends answerMatching{ /** * Export the question part as a matrix-choice, with only one possible answer per line. * @author Amand Tihon <amand@alrj.org> */ function imsExportResponses($questionIdent) { $out = ""; // Now, loop again, finding questions (rows) foreach( $this->leftList as $leftElt ) { $responseIdent = $questionIdent . "_A_" . $leftElt['code']; $out.= '<response_lid ident="' . $responseIdent . '" rcardinality="Single" rtiming="No">' . "\n" . '<material><mattext><![CDATA[' . $leftElt['answer'] . "]]></mattext></material>\n" . ' <render_choice shuffle="No"><flow_label>' . "\n"; foreach( $this->rightList as $rightElt ) { $out.= ' <response_label ident="' . $rightElt['code'] . '"><material>' . "\n" . " <mattext><![CDATA[" . $rightElt['answer'] . "]]></mattext>\n" . " </material></response_label>\n"; } $out.= "</flow_label></render_choice></response_lid>\n"; } return $out; } /** * Export the response processing part * @author Amand Tihon <amand@alrj.org> */ function imsExportProcessing($questionIdent) { $out = ""; foreach( $this->leftList as $leftElt ) { $responseIdent = $questionIdent . "_A_" . $leftElt['code']; $out.= ' <respcondition continue="Yes"><conditionvar>' . "\n" . ' <varequal respident="' . $responseIdent . '">' . $leftElt['match'] . "</varequal>\n" . ' </conditionvar><setvar action="Add">' . $leftElt['grade'] . "</setvar>\n" . " </respcondition>\n"; } return $out; } /** * Export the feedback (comments to selected answers) to IMS/QTI * * @author Amand Tihon <amand@alrj.org> */ function imsExportFeedback($questionIdent) { // no feedback in this question type return ''; } /** * allow to import the answers, feedbacks, and grades of a question * * @param questionArray is an array that must contain all the information needed to build the question * @author Guillaume Lederer <guillaume@claroline.net> */ function import($questionArray) { $answerArray = $questionArray['answer']; //This tick to remove examples in the answers!!!! $this->leftList = array(); $this->rightList = array(); //find right and left column $right_column = array_pop($answerArray); $left_column = array_pop($answerArray); //1- build answers foreach ($right_column as $right_key => $right_element) { $code = $this->addRight($right_element); foreach ($left_column as $left_key => $left_element) { $matched_pattern = $left_key." ".$right_key; $matched_pattern_inverted = $right_key." ".$left_key; if (in_array($matched_pattern, $questionArray['correct_answers']) || in_array($matched_pattern_inverted, $questionArray['correct_answers'])) { if (isset($questionArray['weighting'][$matched_pattern])) { $grade = $questionArray['weighting'][$matched_pattern]; } else { $grade = 0; } $this->addLeft($left_element, $code, $grade); } } } }} ?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -