/** * 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); }