Exemplo n.º 1
0
 /**
  * Initialise the JS etc. required by one question.
  * @param int $questionid the question id.
  */
 public function get_question_html_head_contributions($slot)
 {
     return $this->quba->render_question_head_html($slot) . question_engine::initialise_js();
 }
Exemplo n.º 2
0
    $displaynumber = 'i';
}
$restartdisabled = '';
$finishdisabled = '';
$filldisabled = '';
if ($quba->get_question_state($slot)->is_finished()) {
    $finishdisabled = ' disabled="disabled"';
    $filldisabled = ' disabled="disabled"';
}
if (!$previewid) {
    $restartdisabled = ' disabled="disabled"';
}

// Output
$title = get_string('previewquestion', 'question', format_string($question->name));
$headtags = question_engine::initialise_js() . $quba->render_question_head_html($slot);
$PAGE->set_title($title);
$PAGE->set_heading($title);
echo $OUTPUT->header();

// Start the question form.
echo '<form method="post" action="' . $actionurl .
        '" enctype="multipart/form-data" id="responseform">', "\n";
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />', "\n";
echo '<input type="hidden" name="slots" value="' . $slot . '" />', "\n";

// Output the question.
echo $quba->render_question($slot, $options, $displaynumber);

echo '<p class="notifytiny">' . get_string('behaviourbeingused', 'question',
        question_engine::get_behaviour_name(
// Check the access rules.
$accessmanager = $attemptobj->get_access_manager(time());
$accessmanager->setup_attempt_page($PAGE);
// Complete masquerading as the mod-quiz-attempt page. Must be done after setup_attempt_page.
$PAGE->set_pagetype('mod-quiz-attempt');
// Get the renderer.
$output = $PAGE->get_renderer('mod_quiz');
$messages = $accessmanager->prevent_access();
if (!$attemptobj->is_preview_user() && $messages) {
    print_error('attempterror', 'quiz', $attemptobj->view_url(), $output->access_messages($messages));
}
if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
    redirect($attemptobj->start_attempt_url(null, $page));
}
// Initialise the JavaScript.
question_engine::initialise_js();
$PAGE->requires->js_module(quiz_get_js_module());
$autosaveperiod = get_config('quiz', 'autosaveperiod');
if (!$autosaveperiod) {
    // Offline mode only works with autosave, so if it is off for normal quizzes,
    // use a sensible default.
    $autosaveperiod = 60;
}
$PAGE->requires->yui_module('moodle-quizaccess_offlinemode-autosave', 'M.quizaccess_offlinemode.autosave.init', array($autosaveperiod));
$PAGE->requires->yui_module('moodle-quizaccess_offlinemode-navigation', 'M.quizaccess_offlinemode.navigation.init', array($page));
if (!empty($USER->idnumber)) {
    $user = '******' . $USER->idnumber;
} else {
    $user = '******' . $USER->id;
}
$emergencysavefilename = clean_filename(format_string($attemptobj->get_quiz_name()) . $user . '-a' . $attemptid . '-d197001010000.attemptdata');
Exemplo n.º 4
0
 protected function display_grading_interface($slot, $questionid, $grade, $pagesize, $page, $shownames, $showidnumbers, $order, $counts)
 {
     global $OUTPUT;
     if ($pagesize * $page >= $counts->{$grade}) {
         $page = 0;
     }
     list($qubaids, $count) = $this->get_usage_ids_where_question_in_state($grade, $slot, $questionid, $order, $page, $pagesize);
     $attempts = $this->load_attempts_by_usage_ids($qubaids);
     // Prepare the form.
     $hidden = array('id' => $this->cm->id, 'mode' => 'grading', 'slot' => $slot, 'qid' => $questionid, 'page' => $page);
     if (array_key_exists('includeauto', $this->viewoptions)) {
         $hidden['includeauto'] = $this->viewoptions['includeauto'];
     }
     $mform = new quiz_grading_settings_form($hidden, $counts, $shownames, $showidnumbers);
     // Tell the form the current settings.
     $settings = new stdClass();
     $settings->grade = $grade;
     $settings->pagesize = $pagesize;
     $settings->order = $order;
     $mform->set_data($settings);
     // Print the heading and form.
     echo question_engine::initialise_js();
     $a = new stdClass();
     $a->number = $this->questions[$slot]->number;
     $a->questionname = format_string($counts->name);
     echo $OUTPUT->heading(get_string('gradingquestionx', 'quiz_grading', $a), 3);
     echo html_writer::tag('p', html_writer::link($this->list_questions_url(), get_string('backtothelistofquestions', 'quiz_grading')), array('class' => 'mdl-align'));
     $mform->display();
     // Paging info.
     $a = new stdClass();
     $a->from = $page * $pagesize + 1;
     $a->to = min(($page + 1) * $pagesize, $count);
     $a->of = $count;
     echo $OUTPUT->heading(get_string('gradingattemptsxtoyofz', 'quiz_grading', $a), 3);
     if ($count > $pagesize && $order != 'random') {
         echo $OUTPUT->paging_bar($count, $page, $pagesize, $this->grade_question_url($slot, $questionid, $grade, false));
     }
     // Display the form with one section for each attempt.
     $sesskey = sesskey();
     $qubaidlist = implode(',', $qubaids);
     echo html_writer::start_tag('form', array('method' => 'post', 'action' => $this->grade_question_url($slot, $questionid, $grade, $page), 'class' => 'mform', 'id' => 'manualgradingform')) . html_writer::start_tag('div') . html_writer::input_hidden_params(new moodle_url('', array('qubaids' => $qubaidlist, 'slots' => $slot, 'sesskey' => $sesskey)));
     foreach ($qubaids as $qubaid) {
         $attempt = $attempts[$qubaid];
         $quba = question_engine::load_questions_usage_by_activity($qubaid);
         $displayoptions = quiz_get_review_options($this->quiz, $attempt, $this->context);
         $displayoptions->hide_all_feedback();
         $displayoptions->history = question_display_options::HIDDEN;
         $displayoptions->manualcomment = question_display_options::EDITABLE;
         $heading = $this->get_question_heading($attempt, $shownames, $showidnumbers);
         if ($heading) {
             echo $OUTPUT->heading($heading, 4);
         }
         echo $quba->render_question($slot, $displayoptions, $this->questions[$slot]->number);
     }
     echo html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('saveandnext', 'quiz_grading'))), array('class' => 'mdl-align')) . html_writer::end_tag('div') . html_writer::end_tag('form');
 }
 /**
  * Initialize the head contributions from the question engine
  *
  * @return string
  */
 public function get_html_head_contributions()
 {
     $result = '';
     // get the slots ids from the quba layout
     $slots = explode(',', $this->attempt->qubalayout);
     // next load the slot headhtml and initialize question engine js
     foreach ($slots as $slot) {
         $result .= $this->quba->render_question_head_html($slot);
     }
     $result .= \question_engine::initialise_js();
     return $result;
 }