/** * sets up what is displayed for each question on the edit quiz question listing * * @param \mod_activequiz\activequiz_question $question * @param int $qnum The question number we're currently on * @param int $qcount The total number of questions * * @return string */ protected function display_question_block($question, $qnum, $qcount) { $return = ''; $dragicon = new pix_icon('i/dragdrop', 'dragdrop'); $return .= html_writer::div($this->output->render($dragicon), 'dragquestion'); $return .= html_writer::div(print_question_icon($question->getQuestion()), 'icon'); $namehtml = html_writer::start_tag('p'); $namehtml .= $question->getQuestion()->name . '<br />'; $namehtml .= get_string('points', 'activequiz') . ': ' . $question->getPoints(); $namehtml .= html_writer::end_tag('p'); $return .= html_writer::div($namehtml, 'name'); $controlHTML = ''; $spacericon = new pix_icon('spacer', 'space', null, array('class' => 'smallicon space')); $controlHTML .= html_writer::start_tag('noscript'); if ($qnum > 1) { // if we're on a later question than the first one add the move up control $moveupurl = clone $this->pageurl; $moveupurl->param('action', 'moveup'); $moveupurl->param('questionid', $question->getId()); // add the rtqqid so that the question manager handles the translation $alt = get_string('questionmoveup', 'mod_activequiz', $qnum); $upicon = new pix_icon('t/up', $alt); $controlHTML .= html_writer::link($moveupurl, $this->output->render($upicon)); } else { $controlHTML .= $this->output->render($spacericon); } if ($qnum < $qcount) { // if we're not on the last question add the move down control $movedownurl = clone $this->pageurl; $movedownurl->param('action', 'movedown'); $movedownurl->param('questionid', $question->getId()); $alt = get_string('questionmovedown', 'mod_activequiz', $qnum); $downicon = new pix_icon('t/down', $alt); $controlHTML .= html_writer::link($movedownurl, $this->output->render($downicon)); } else { $controlHTML .= $this->output->render($spacericon); } $controlHTML .= html_writer::end_tag('noscript'); // always add edit and delete icons $editurl = clone $this->pageurl; $editurl->param('action', 'editquestion'); $editurl->param('rtqquestionid', $question->getId()); $alt = get_string('questionedit', 'activequiz', $qnum); $deleteicon = new pix_icon('t/edit', $alt); $controlHTML .= html_writer::link($editurl, $this->output->render($deleteicon)); $deleteurl = clone $this->pageurl; $deleteurl->param('action', 'deletequestion'); $deleteurl->param('questionid', $question->getId()); $alt = get_string('questiondelete', 'mod_activequiz', $qnum); $deleteicon = new pix_icon('t/delete', $alt); $controlHTML .= html_writer::link($deleteurl, $this->output->render($deleteicon)); $return .= html_writer::div($controlHTML, 'controls'); return $return; }
/** * Gets the slot for the activequiz question * * @param \mod_activequiz\activequiz_question $q * * @return int */ public function get_question_slot(\mod_activequiz\activequiz_question $q) { // build if not available if (empty($this->slotsbyquestionid) || !is_array($this->slotsbyquestionid)) { // build n array of slots keyed by the questionid they match to $slotsbyquestionid = array(); foreach ($this->getSlots() as $slot) { $slotsbyquestionid[$this->quba->get_question($slot)->id] = $slot; } $this->slotsbyquestionid = $slotsbyquestionid; } return !empty($this->slotsbyquestionid[$q->getQuestion()->id]) ? $this->slotsbyquestionid[$q->getQuestion()->id] : false; }