/**
 * Prints local lib tabs
 *
 * @param \mod_activequiz\activequiz $RTQ Realtime quiz class
 * @param                            $currenttab
 *
 * @return string HTML string of the tabs
 */
function activequiz_view_tabs($RTQ, $currenttab)
{
    $tabs = array();
    $row = array();
    $inactive = array();
    $activated = array();
    if ($RTQ->has_capability('mod/activequiz:attempt')) {
        $row[] = new tabobject('view', new moodle_url('/mod/activequiz/view.php', array('id' => $RTQ->getCM()->id)), get_string('view', 'activequiz'));
    }
    if ($RTQ->has_capability('mod/activequiz:editquestions')) {
        $row[] = new tabobject('edit', new moodle_url('/mod/activequiz/edit.php', array('cmid' => $RTQ->getCM()->id)), get_string('edit', 'activequiz'));
    }
    if ($RTQ->has_capability('mod/activequiz:seeresponses')) {
        $row[] = new tabobject('responses', new moodle_url('/mod/activequiz/responses.php', array('id' => $RTQ->getCM()->id)), get_string('responses', 'activequiz'));
    }
    if ($currenttab == 'view' && count($row) == 1) {
        // No tabs for students
        echo '<br />';
    } else {
        $tabs[] = $row;
    }
    if ($currenttab == 'responses') {
        $activated[] = 'responses';
    }
    if ($currenttab == 'edit') {
        $activated[] = 'edit';
    }
    if ($currenttab == 'view') {
        $activated[] = 'view';
    }
    return print_tabs($tabs, $currenttab, $inactive, $activated, true);
}
 /**
  * Render the list questions view for the edit page
  *
  * @param array  $questions Array of questions
  * @param string $questionbankview HTML for the question bank view
  */
 public function editrender_listquestions($questions, $questionbankview)
 {
     global $CFG;
     echo html_writer::start_div('row', array('id' => 'questionrow'));
     echo html_writer::start_div('span6');
     echo html_writer::tag('h2', get_string('questionlist', 'activequiz'));
     echo html_writer::div('', 'rtqstatusbox rtqhiddenstatus', array('id' => 'editstatus'));
     echo $this->show_questionlist($questions);
     echo html_writer::end_div();
     echo html_writer::start_div('span6');
     echo $questionbankview;
     echo html_writer::end_div();
     echo html_writer::end_div();
     $this->page->requires->js('/mod/activequiz/js/core.js');
     $this->page->requires->js('/mod/activequiz/js/sortable/sortable.min.js');
     $this->page->requires->js('/mod/activequiz/js/edit_quiz.js');
     // next set up a class to pass to js for js info
     $jsinfo = new stdClass();
     $jsinfo->sesskey = sesskey();
     $jsinfo->siteroot = $CFG->wwwroot;
     $jsinfo->cmid = $this->rtq->getCM()->id;
     // print jsinfo to javascript
     echo html_writer::start_tag('script', array('type' => 'text/javascript'));
     echo "rtqinitinfo = " . json_encode($jsinfo);
     echo html_writer::end_tag('script');
     $this->page->requires->strings_for_js(array('success', 'error'), 'core');
 }
 /**
  * Construct an instance of question manager
  *
  * @param activequiz               $rtq
  * @param \mod_activequiz_renderer $renderer The realtime quiz renderer to render visual elements
  * @param array                    $pagevars page variables array
  */
 public function __construct($rtq, $renderer, $pagevars = array())
 {
     global $DB;
     $this->rtq = $rtq;
     $this->renderer = $renderer;
     $this->pagevars = $pagevars;
     $this->orderedquestions = array();
     if (!empty($this->pagevars)) {
         $this->baseurl = $this->pagevars['pageurl'];
     } else {
         $params = array('id' => $this->rtq->getCM()->id);
         $this->baseurl = new \moodle_url('/mod/activequiz/edit.php', $params);
     }
     // load questions
     $this->refresh_questions();
 }