/** * Render the question flag, assuming $flagsoption allows it. You will probably * never need to override this method. * * @param object $question the question * @param object $state its current state * @param integer $flagsoption the option that says whether flags should be displayed. */ protected function print_question_flag($question, $state, $flagsoption) { global $CFG, $PAGE; switch ($flagsoption) { case QUESTION_FLAGSSHOWN: $flagcontent = $this->get_question_flag_tag($state->flagged); break; case QUESTION_FLAGSEDITABLE: $id = $question->name_prefix . '_flagged'; if ($state->flagged) { $checked = 'checked="checked" '; } else { $checked = ''; } $qsid = $state->questionsessionid; $aid = $state->attempt; $qid = $state->question; $checksum = question_get_toggleflag_checksum($aid, $qid, $qsid); $postdata = "qsid={$qsid}&aid={$aid}&qid={$qid}&checksum={$checksum}&sesskey=" . sesskey() . '&newstate='; $flagcontent = '<input type="checkbox" id="' . $id . '" name="' . $id . '" class="questionflagcheckbox" value="1" ' . $checked . ' />' . '<input type="hidden" value="' . s($postdata) . '" class="questionflagpostdata" />' . '<label id="' . $id . 'label" for="' . $id . '" class="questionflaglabel">' . $this->get_question_flag_tag($state->flagged, $id . 'img') . '</label>' . "\n"; question_init_qengine_js(); break; default: $flagcontent = ''; } if ($flagcontent) { echo '<div class="questionflag">' . $flagcontent . "</div>\n"; } }
/** * Give the questions in $questionlist a chance to request the CSS or JavaScript * they need, before the header is printed. * * If your code is going to call the print_question function, it must call this * funciton before print_header. * * @param array $questionlist a list of questionids of the questions what will appear on this page. * @param array $questions an array of question objects, whose keys are question ids. * Must contain all the questions in $questionlist * @param array $states an array of question state objects, whose keys are question ids. * Must contain the state of all the questions in $questionlist */ function question_get_html_head_contributions($questionlist, &$questions, &$states) { global $CFG, $PAGE, $QTYPES; // The question engine's own JavaScript. question_init_qengine_js(); // Anything that questions on this page need. foreach ($questionlist as $questionid) { $question = $questions[$questionid]; $QTYPES[$question->qtype]->get_html_head_contributions($question, $states[$questionid]); } }
/** * Give the questions in $questionlist a chance to request the CSS or JavaScript * they need, before the header is printed. * * If your code is going to call the print_question function, it must call this * funciton before print_header. * * @param array $questionlist a list of questionids of the questions what will appear on this page. * @param array $questions an array of question objects, whose keys are question ids. * Must contain all the questions in $questionlist * @param array $states an array of question state objects, whose keys are question ids. * Must contain the state of all the questions in $questionlist */ function get_html_head_contributions($questionlist, &$questions, &$states) { global $CFG, $PAGE, $QTYPES; // The question engine's own JavaScript. $PAGE->requires->yui_lib('connection'); $PAGE->requires->js('question/qengine.js'); question_init_qengine_js(); // Anything that questions on this page need. foreach ($questionlist as $questionid) { $question = $questions[$questionid]; $QTYPES[$question->qtype]->get_html_head_contributions($question, $states[$questionid]); } }