コード例 #1
0
 /**
  * Display a question.
  *
  * @param structure $structure object containing the structure of the quiz.
  * @param \stdClass $question data from the question and quiz_slots tables.
  * @param \moodle_url $pageurl the canonical URL of this page.
  * @return string HTML to output.
  */
 public function question(structure $structure, $question, \moodle_url $pageurl)
 {
     $output = '';
     $output .= html_writer::start_tag('div');
     if ($structure->can_be_edited()) {
         $output .= $this->question_move_icon($question);
     }
     $output .= html_writer::start_div('mod-indent-outer');
     $output .= $this->question_number($question->displayednumber);
     // This div is used to indent the content.
     $output .= html_writer::div('', 'mod-indent');
     // Display the link to the question (or do nothing if question has no url).
     if ($question->qtype == 'random') {
         $questionname = $this->random_question($structure, $question, $pageurl);
     } else {
         $questionname = $this->question_name($structure, $question, $pageurl);
     }
     // Start the div for the activity title, excluding the edit icons.
     $output .= html_writer::start_div('activityinstance');
     $output .= $questionname;
     // Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
     $output .= html_writer::end_tag('div');
     // .activityinstance.
     // Action icons.
     $questionicons = '';
     $questionicons .= $this->question_preview_icon($structure->get_quiz(), $question);
     if ($structure->can_be_edited()) {
         $questionicons .= $this->question_remove_icon($question, $pageurl);
     }
     $questionicons .= $this->marked_out_of_field($structure->get_quiz(), $question);
     $output .= html_writer::span($questionicons, 'actions');
     // Required to add js spinner icon.
     // End of indentation div.
     $output .= html_writer::end_tag('div');
     $output .= html_writer::end_tag('div');
     return $output;
 }
コード例 #2
0
ファイル: edit_renderer.php プロジェクト: alanaipe2015/moodle
 /**
  * Display the icon for whether this question can only be seen if the previous
  * one has been answered.
  *
  * @param structure $structure object containing the structure of the quiz.
  * @param int $slot the first slot on the page we are outputting.
  * @return string HTML to output.
  */
 public function question_dependency_icon($structure, $slot)
 {
     $a = array('thisq' => $structure->get_displayed_number_for_slot($slot), 'previousq' => $structure->get_displayed_number_for_slot(max($slot - 1, 1)));
     if ($structure->is_question_dependent_on_previous_slot($slot)) {
         $title = get_string('questiondependencyremove', 'quiz', $a);
         $image = $this->pix_icon('t/locked', get_string('questiondependsonprevious', 'quiz'), 'moodle', array('title' => ''));
         $action = 'removedependency';
     } else {
         $title = get_string('questiondependencyadd', 'quiz', $a);
         $image = $this->pix_icon('t/unlocked', get_string('questiondependencyfree', 'quiz'), 'moodle', array('title' => ''));
         $action = 'adddependency';
     }
     // Disable the link if quiz has attempts.
     $disabled = null;
     if (!$structure->can_be_edited()) {
         $disabled = 'disabled';
     }
     $extraclass = '';
     if (!$structure->can_question_depend_on_previous_slot($slot)) {
         $extraclass = ' question_dependency_cannot_depend';
     }
     return html_writer::span($this->action_link('#', $image, null, array('title' => $title, 'class' => 'cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)), 'question_dependency_wrapper' . $extraclass);
 }