Exemplo n.º 1
0
if ($quiz_reordertool) {
    echo '<div class="repaginatecommand"><button id="repaginatecommand" ' . $repaginatingdisabledhtml . '>' . get_string('repaginatecommand', 'quiz') . '...</button>';
    echo '</div>';
}
if ($quiz_reordertool) {
    echo $OUTPUT->heading_with_help(get_string('orderingquizx', 'quiz', format_string($quiz->name)), 'orderandpaging', 'quiz');
} else {
    echo $OUTPUT->heading(get_string('editingquizx', 'quiz', format_string($quiz->name)), 2);
    echo $OUTPUT->help_icon('editingquiz', 'quiz', get_string('basicideasofquiz', 'quiz'));
}
quiz_print_status_bar($quiz);
$tabindex = 0;
quiz_print_grading_form($quiz, $thispageurl, $tabindex);
$notifystrings = array();
if ($quizhasattempts) {
    $reviewlink = quiz_attempt_summary_link_to_reports($quiz, $cm, $contexts->lowest());
    $notifystrings[] = get_string('cannoteditafterattempts', 'quiz', $reviewlink);
}
if ($quiz->shufflequestions) {
    $updateurl = new moodle_url("{$CFG->wwwroot}/course/mod.php", array('return' => 'true', 'update' => $quiz->cmid, 'sesskey' => sesskey()));
    $updatelink = '<a href="' . $updateurl->out() . '">' . get_string('updatethis', '', get_string('modulename', 'quiz')) . '</a>';
    $notifystrings[] = get_string('shufflequestionsselected', 'quiz', $updatelink);
}
if (!empty($notifystrings)) {
    echo $OUTPUT->box('<p>' . implode('</p><p>', $notifystrings) . '</p>', 'statusdisplay');
}
if ($quiz_reordertool) {
    $perpage = array();
    $perpage[0] = get_string('allinone', 'quiz');
    for ($i = 1; $i <= 50; ++$i) {
        $perpage[$i] = $i;
Exemplo n.º 2
0
 /**
  * Get any warnings to show at the top of the edit page.
  * @return string[] array of strings.
  */
 public function get_edit_page_warnings()
 {
     $warnings = array();
     if (quiz_has_attempts($this->quizobj->get_quizid())) {
         $reviewlink = quiz_attempt_summary_link_to_reports($this->quizobj->get_quiz(), $this->quizobj->get_cm(), $this->quizobj->get_context());
         $warnings[] = get_string('cannoteditafterattempts', 'quiz', $reviewlink);
     }
     if ($this->is_shuffled()) {
         $updateurl = new \moodle_url('/course/mod.php', array('return' => 'true', 'update' => $this->quizobj->get_cmid(), 'sesskey' => sesskey()));
         $updatelink = '<a href="' . $updateurl->out() . '">' . get_string('updatethis', '', get_string('modulename', 'quiz')) . '</a>';
         $warnings[] = get_string('shufflequestionsselected', 'quiz', $updatelink);
     }
     return $warnings;
 }
Exemplo n.º 3
0
/// Print quiz name and description
echo $OUTPUT->heading(format_string($quiz->name));
if (trim(strip_tags($quiz->intro))) {
    echo $OUTPUT->box(format_module_intro('quiz', $quiz, $cm->id), 'generalbox', 'intro');
}
/// Display information about this quiz.
$messages = $accessmanager->describe_rules();
if ($quiz->attempts != 1) {
    $messages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod));
}
echo $OUTPUT->box_start('quizinfo');
$accessmanager->print_messages($messages);
echo $OUTPUT->box_end();
/// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
    if ($strattemptnum = quiz_attempt_summary_link_to_reports($quiz, $cm, $context)) {
        echo '<div class="quizattemptcounts">' . $strattemptnum . "</div>\n";
    }
}
/// Guests can't do a quiz, so offer them a choice of logging in or going back.
if (isguestuser()) {
    echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
    echo $OUTPUT->footer();
    exit;
}
/// If they are not enrolled in this course in a good enough role, tell them to enrol.
if (!($canattempt || $canpreview || $canreviewmine)) {
    echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" . $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) . "</p>\n", 'generalbox', 'notice');
    echo $OUTPUT->footer();
    exit;
}
Exemplo n.º 4
0
 /**
  * Get any warnings to show at the top of the edit page.
  * @return string[] array of strings.
  */
 public function get_edit_page_warnings()
 {
     $warnings = array();
     if (quiz_has_attempts($this->quizobj->get_quizid())) {
         $reviewlink = quiz_attempt_summary_link_to_reports($this->quizobj->get_quiz(), $this->quizobj->get_cm(), $this->quizobj->get_context());
         $warnings[] = get_string('cannoteditafterattempts', 'quiz', $reviewlink);
     }
     return $warnings;
 }
Exemplo n.º 5
0
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Rest endpoint for ajax editing for paging operations on the quiz structure.
 *
 * @package   mod_quiz
 * @copyright 2014 The Open University
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . '/../../config.php';
require_once $CFG->dirroot . '/mod/quiz/locallib.php';
$cmid = required_param('cmid', PARAM_INT);
$quizid = required_param('quizid', PARAM_INT);
$slotnumber = required_param('slot', PARAM_INT);
$repagtype = required_param('repag', PARAM_INT);
require_sesskey();
$quizobj = quiz::create($quizid);
require_login($quizobj->get_course(), false, $quizobj->get_cm());
require_capability('mod/quiz:manage', $quizobj->get_context());
if (quiz_has_attempts($quizid)) {
    $reportlink = quiz_attempt_summary_link_to_reports($quizobj->get_quiz(), $quizobj->get_cm(), $quizobj->get_context());
    throw new \moodle_exception('cannoteditafterattempts', 'quiz', new moodle_url('/mod/quiz/edit.php', array('cmid' => $cmid)), $reportlink);
}
$slotnumber++;
$repage = new \mod_quiz\repaginate($quizid);
$repage->repaginate_slots($slotnumber, $repagtype);
$structure = $quizobj->get_structure();
$slots = $structure->refresh_page_numbers_and_update_db($structure->get_quiz());
redirect(new moodle_url('edit.php', array('cmid' => $quizobj->get_cmid())));
Exemplo n.º 6
0
        $class = ' class="dimmed"';
    }
    $data[] = "<a$class href=\"view.php?id=$quiz->coursemodule\">" .
            format_string($quiz->name, true) . '</a>';

    // Close date.
    if ($quiz->timeclose) {
        $data[] = userdate($quiz->timeclose);
    } else if ($showclosingheader) {
        $data[] = '';
    }

    if ($showing == 'stats') {
        // The $quiz objects returned by get_all_instances_in_course have the necessary $cm
        // fields set to make the following call work.
        $data[] = quiz_attempt_summary_link_to_reports($quiz, $cm, $context);

    } else if ($showing == 'grades') {
        // Grade and feedback.
        $attempts = quiz_get_user_attempts($quiz->id, $USER->id, 'all');
        list($someoptions, $alloptions) = quiz_get_combined_reviewoptions(
                $quiz, $attempts, $context);

        $grade = '';
        $feedback = '';
        if ($quiz->grade && array_key_exists($quiz->id, $grades)) {
            if ($alloptions->marks >= question_display_options::MARK_AND_MAX) {
                $a = new stdClass();
                $a->grade = quiz_format_grade($quiz, $grades[$quiz->id]);
                $a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
                $grade = get_string('outofshort', 'quiz', $a);