Beispiel #1
0
$id = required_param('id', PARAM_INT);
// Course Module ID
$pageid = optional_param('pageid', null, PARAM_INT);
// Lesson Page ID
$edit = optional_param('edit', -1, PARAM_BOOL);
$userpassword = optional_param('userpassword', '', PARAM_RAW);
$backtocourse = optional_param('backtocourse', false, PARAM_RAW);
$cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
if ($backtocourse) {
    redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
}
// Apply overrides.
$lesson->update_effective_access($USER->id);
// Mark as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$url = new moodle_url('/mod/lesson/view.php', array('id' => $id));
if ($pageid !== null) {
    $url->param('pageid', $pageid);
}
$PAGE->set_url($url);
$context = context_module::instance($cm->id);
$canmanage = has_capability('mod/lesson:manage', $context);
$lessonoutput = $PAGE->get_renderer('mod_lesson');
$reviewmode = false;
$userhasgrade = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id));
if ($userhasgrade && !$lesson->retake) {
    $reviewmode = true;
Beispiel #2
0
}
$PAGE->set_url($url);
$currentgroup = groups_get_activity_group($cm, true);
$attempt = new stdClass();
$user = new stdClass();
$attemptid = optional_param('attemptid', 0, PARAM_INT);
$formattextdefoptions = new stdClass();
$formattextdefoptions->noclean = true;
$formattextdefoptions->para = false;
$formattextdefoptions->context = $context;
if ($attemptid > 0) {
    $attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid));
    $answer = $DB->get_record('lesson_answers', array('lessonid' => $lesson->id, 'pageid' => $attempt->pageid));
    $user = $DB->get_record('user', array('id' => $attempt->userid));
    // Apply overrides.
    $lesson->update_effective_access($user->id);
    $scoreoptions = array();
    if ($lesson->custom) {
        $i = $answer->score;
        while ($i >= 0) {
            $scoreoptions[$i] = (string) $i;
            $i--;
        }
    } else {
        $scoreoptions[0] = get_string('nocredit', 'lesson');
        $scoreoptions[1] = get_string('credit', 'lesson');
    }
}
/// Handle any preprocessing before header is printed - based on $mode
switch ($mode) {
    case 'grade':