echo html_writer::span(get_string('partcheckedwithoutresult', 'offlinequiz', array('count' => $checkedwithoutresult, 'url' => $checkedwithoutresulturl->out())));
                echo '<br />';
                echo html_writer::span(get_string('partuncheckedwithresult', 'offlinequiz', array('count' => $uncheckedwithresult, 'url' => $uncheckedwithresulturl->out())));
                echo '<br />';
                echo html_writer::span(get_string('partuncheckedwithoutresult', 'offlinequiz', $uncheckedwithoutresult));
                foreach ($plists as $listid => $plist) {
                    $membercount = $DB->count_records('offlinequiz_participants', array('listid' => $plist->id));
                }
            }
            echo '</div>';
        }
    }
} else {
    if (has_capability('mod/offlinequiz:attempt', $context)) {
        $select = "SELECT *\n                 FROM {offlinequiz_results} qa\n                WHERE qa.offlinequizid = :offlinequizid\n                  AND qa.userid = :userid\n                  AND qa.status = 'complete'";
        if ($result = $DB->get_record_sql($select, array('offlinequizid' => $offlinequiz->id, 'userid' => $USER->id)) and offlinequiz_results_open($offlinequiz)) {
            $options = offlinequiz_get_review_options($offlinequiz, $result, $context);
            if ($result->timefinish and ($options->attempt == question_display_options::VISIBLE or $options->marks >= question_display_options::MAX_ONLY or $options->sheetfeedback == question_display_options::VISIBLE or $options->gradedsheetfeedback == question_display_options::VISIBLE)) {
                echo '<div class="offlinequizinfo">';
                $url = new moodle_url($CFG->wwwroot . '/mod/offlinequiz/review.php', array('q' => $offlinequiz->id, 'resultid' => $result->id));
                echo $OUTPUT->single_button($url, get_string('viewresults', 'offlinequiz'));
                echo '</div>';
            }
        } else {
            if (!empty($offlinequiz->time) and $offlinequiz->time < time()) {
                echo '<div class="offlinequizinfo">' . get_string('nogradesseelater', 'offlinequiz', fullname($USER)) . '</div>';
            } else {
                if ($offlinequiz->showtutorial) {
                    // JZ: UNIVIS-15097.
                    echo '<br/><div class="offlinequizinfo">';
                    $url = new moodle_url($CFG->wwwroot . '/mod/offlinequiz/tutorial/index.php', array('id' => $cm->id));
}
$grade = offlinequiz_rescale_grade($result->sumgrades, $offlinequiz, $group);
require_login($course->id, false, $cm);
$context = context_module::instance($cm->id);
$isteacher = has_capability('mod/offlinequiz:viewreports', $context);
$options = offlinequiz_get_review_options($offlinequiz, $result, $context);
if (!$isteacher) {
    if (!$result->timefinish) {
        redirect('view.php?q=' . $offlinequiz->id);
    }
    // If not even responses or scanner feedback are to be shown in review then we
    // don't allow any review.
    if ($options->attempt == question_display_options::HIDDEN and $options->marks < question_display_options::MAX_ONLY and $options->sheetfeedback == question_display_options::HIDDEN and $options->gradedsheetfeedback == question_display_options::HIDDEN) {
        redirect('view.php?q=' . $offlinequiz->id);
    }
    if (!offlinequiz_results_open($offlinequiz)) {
        redirect('view.php?q=' . $offlinequiz->id, get_string("noreview", "offlinequiz"));
    }
    if ($result->userid != $USER->id) {
        print_error("This is not your result!", 'view.php?q=' . $offlinequiz->id);
    }
}
$strscore = get_string("marks", "offlinequiz");
$strgrade = get_string("grade");
$letterstr = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Setup the page and print the page header.
$url = new moodle_url('/mod/offlinequiz/review.php', array('resultid' => $resultid, 'page' => $page));
$PAGE->set_url($url);
$PAGE->set_title(format_string($offlinequiz->name));
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('report');