Exemple #1
0
 /**
  * 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();
             $flagcontent = '<input type="checkbox" id="' . $id . '" name="' . $id . '" value="1" ' . $checked . ' />' . '<label id="' . $id . 'label" for="' . $id . '">' . $this->get_question_flag_tag($state->flagged, $id . 'img') . '</label>' . "\n";
             $PAGE->requires->js_function_call('question_flag_changer.init_flag', array($id, $postdata));
             break;
         default:
             $flagcontent = '';
     }
     if ($flagcontent) {
         echo '<div class="questionflag">' . $flagcontent . "</div>\n";
     }
 }
Exemple #2
0
 /**
  * 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";
     }
 }