mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-57688-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
5b95bd50df
@ -243,7 +243,7 @@ class mod_lesson_external extends external_api {
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
protected static function validate_attempt(lesson $lesson, $params, $return = false) {
|
||||
global $USER;
|
||||
global $USER, $CFG;
|
||||
|
||||
$errors = array();
|
||||
|
||||
@ -316,6 +316,43 @@ class mod_lesson_external extends external_api {
|
||||
}
|
||||
$errors[key($error)] = current($error);
|
||||
}
|
||||
} else {
|
||||
if (!$timers = $lesson->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1)) {
|
||||
$error = ["cannotfindtimer" => null];
|
||||
if (!$return) {
|
||||
throw new moodle_exception(key($error), 'lesson');
|
||||
}
|
||||
$errors[key($error)] = current($error);
|
||||
} else {
|
||||
$timer = current($timers);
|
||||
if (!$lesson->check_time($timer)) {
|
||||
$error = ["eolstudentoutoftime" => null];
|
||||
if (!$return) {
|
||||
throw new moodle_exception(key($error), 'lesson');
|
||||
}
|
||||
$errors[key($error)] = current($error);
|
||||
}
|
||||
|
||||
// Check if the user want to review an attempt he just finished.
|
||||
if (!empty($params['review'])) {
|
||||
// Allow review only for completed attempts during active session time.
|
||||
if ($timer->completed and ($timer->lessontime + $CFG->sessiontimeout > time()) ) {
|
||||
$ntries = $lesson->count_user_retries($USER->id);
|
||||
if ($attempts = $lesson->get_attempts($ntries)) {
|
||||
$lastattempt = end($attempts);
|
||||
$USER->modattempts[$lesson->id] = $lastattempt->pageid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($USER->modattempts[$lesson->id])) {
|
||||
$error = ["studentoutoftimeforreview" => null];
|
||||
if (!$return) {
|
||||
throw new moodle_exception(key($error), 'lesson');
|
||||
}
|
||||
$errors[key($error)] = current($error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
@ -1041,4 +1078,104 @@ class mod_lesson_external extends external_api {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the parameters for launch_attempt.
|
||||
*
|
||||
* @return external_external_function_parameters
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public static function launch_attempt_parameters() {
|
||||
return new external_function_parameters (
|
||||
array(
|
||||
'lessonid' => new external_value(PARAM_INT, 'lesson instance id'),
|
||||
'password' => new external_value(PARAM_RAW, 'optional password (the lesson may be protected)', VALUE_DEFAULT, ''),
|
||||
'pageid' => new external_value(PARAM_RAW, 'page id to continue from (only when continuing an attempt)', VALUE_DEFAULT, 0),
|
||||
'review' => new external_value(PARAM_RAW, 'if we want to review just after finishing', VALUE_DEFAULT, false),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new attempt or continues an existing one.
|
||||
*
|
||||
* @param int $lessonid lesson instance id
|
||||
* @param str $password optional password (the lesson may be protected)
|
||||
* @param int $pageid page id to continue from (only when continuing an attempt)
|
||||
* @param bool $review if we want to review just after finishing
|
||||
* @return array of warnings and status result
|
||||
* @since Moodle 3.3
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function launch_attempt($lessonid, $password = '', $pageid = 0, $review = false) {
|
||||
global $CFG, $USER;
|
||||
|
||||
$params = array('lessonid' => $lessonid, 'password' => $password, 'pageid' => $pageid, 'review' => $review);
|
||||
$params = self::validate_parameters(self::launch_attempt_parameters(), $params);
|
||||
$warnings = $messages = array();
|
||||
|
||||
list($lesson, $course, $cm, $context) = self::validate_lesson($params['lessonid']);
|
||||
self::validate_attempt($lesson, $params);
|
||||
|
||||
$newpageid = 0;
|
||||
// Starting a new lesson attempt.
|
||||
if (empty($params['pageid'])) {
|
||||
// Check if there is a recent timer created during the active session.
|
||||
$alreadystarted = false;
|
||||
if ($timers = $lesson->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1)) {
|
||||
$timer = array_shift($timers);
|
||||
$endtime = $lesson->timelimit > 0 ? min($CFG->sessiontimeout, $lesson->timelimit) : $CFG->sessiontimeout;
|
||||
if (!$timer->completed && $timer->starttime > time() - $endtime) {
|
||||
$alreadystarted = true;
|
||||
}
|
||||
}
|
||||
if (!$alreadystarted && !$lesson->can_manage()) {
|
||||
$lesson->start_timer();
|
||||
}
|
||||
} else {
|
||||
if ($params['pageid'] == LESSON_EOL) {
|
||||
throw new moodle_exception('endoflesson', 'lesson');
|
||||
}
|
||||
$timer = $lesson->update_timer(true, true);
|
||||
if (!$lesson->check_time($timer)) {
|
||||
throw new moodle_exception('eolstudentoutoftime', 'lesson');
|
||||
}
|
||||
}
|
||||
foreach ($lesson->messages as $message) {
|
||||
$messages[] = array(
|
||||
'message' => $message[0],
|
||||
'type' => $message[1],
|
||||
);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'status' => true,
|
||||
'messages' => $messages,
|
||||
'warnings' => $warnings,
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the launch_attempt return value.
|
||||
*
|
||||
* @return external_single_structure
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public static function launch_attempt_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'messages' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'message' => new external_value(PARAM_RAW, 'Message'),
|
||||
'type' => new external_value(PARAM_ALPHANUMEXT, 'Message type: usually a CSS identifier like:
|
||||
success, info, warning, error, notifyproblem, notifyerror, notifytiny, notifysuccess')
|
||||
), 'The lesson generated messages'
|
||||
)
|
||||
),
|
||||
'warnings' => new external_warnings(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -53,16 +53,9 @@ $PAGE->navbar->add(get_string('continue', 'lesson'));
|
||||
if (!$canmanage) {
|
||||
$lesson->displayleft = lesson_displayleftif($lesson);
|
||||
$timer = $lesson->update_timer();
|
||||
if ($lesson->timelimit) {
|
||||
$timeleft = ($timer->starttime + $lesson->timelimit) - time();
|
||||
if ($timeleft <= 0) {
|
||||
// Out of time
|
||||
$lesson->add_message(get_string('eolstudentoutoftime', 'lesson'));
|
||||
redirect(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id,'pageid'=>LESSON_EOL, 'outoftime'=>'normal')));
|
||||
} else if ($timeleft < 60) {
|
||||
// One minute warning
|
||||
$lesson->add_message(get_string("studentoneminwarning", "lesson"));
|
||||
}
|
||||
if (!$lesson->check_time($timer)) {
|
||||
redirect(new moodle_url('/mod/lesson/view.php', array('id' => $cm->id, 'pageid' => LESSON_EOL, 'outoftime' => 'normal')));
|
||||
die; // Shouldn't be reached, but make sure.
|
||||
}
|
||||
} else {
|
||||
$timer = new stdClass;
|
||||
|
@ -100,4 +100,12 @@ $functions = array(
|
||||
'capabilities' => 'mod/lesson:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
'mod_lesson_launch_attempt' => array(
|
||||
'classname' => 'mod_lesson_external',
|
||||
'methodname' => 'launch_attempt',
|
||||
'description' => 'Starts a new attempt or continues an existing one.',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'mod/lesson:view',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
|
||||
),
|
||||
);
|
||||
|
@ -2454,6 +2454,77 @@ class lesson extends lesson_base {
|
||||
$params = array('lessonid' => $this->properties->id, 'userid' => $userid);
|
||||
return $DB->get_records('lesson_timer', $params, $sort, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is out of time in a timed lesson.
|
||||
*
|
||||
* @param stdClass $timer timer object
|
||||
* @return bool True if the user is on time, false is the user ran out of time
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function check_time($timer) {
|
||||
if ($this->properties->timelimit) {
|
||||
$timeleft = $timer->starttime + $this->properties->timelimit - time();
|
||||
if ($timeleft <= 0) {
|
||||
// Out of time.
|
||||
$this->add_message(get_string('eolstudentoutoftime', 'lesson'));
|
||||
return false;
|
||||
} else if ($timeleft < 60) {
|
||||
// One minute warning.
|
||||
$this->add_message(get_string('studentoneminwarning', 'lesson'));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add different informative messages to the given page.
|
||||
*
|
||||
* @param lesson_page $page page object
|
||||
* @param reviewmode $bool whether we are in review mode or not
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public function add_messages_on_page_view(lesson_page $page, $reviewmode) {
|
||||
global $DB, $USER;
|
||||
|
||||
if (!$this->can_manage()) {
|
||||
if ($page->qtype == LESSON_PAGE_BRANCHTABLE && $this->properties->minquestions) {
|
||||
// Tell student how many questions they have seen, how many are required and their grade.
|
||||
$ntries = $DB->count_records("lesson_grades", array("lessonid" => $this->properties->id, "userid" => $USER->id));
|
||||
$gradeinfo = lesson_grade($this, $ntries);
|
||||
if ($gradeinfo->attempts) {
|
||||
if ($gradeinfo->nquestions < $this->properties->minquestions) {
|
||||
$a = new stdClass;
|
||||
$a->nquestions = $gradeinfo->nquestions;
|
||||
$a->minquestions = $this->properties->minquestions;
|
||||
$this->add_message(get_string('numberofpagesviewednotice', 'lesson', $a));
|
||||
}
|
||||
|
||||
if (!$reviewmode && !$this->properties->retake) {
|
||||
$this->add_message(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'notify');
|
||||
if ($this->properties->grade != GRADE_TYPE_NONE) {
|
||||
$a = new stdClass;
|
||||
$a->grade = number_format($gradeinfo->grade * $this->properties->grade / 100, 1);
|
||||
$a->total = $this->properties->grade;
|
||||
$this->add_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($this->properties->timelimit) {
|
||||
$this->add_message(get_string('teachertimerwarning', 'lesson'));
|
||||
}
|
||||
if (lesson_display_teacher_warning($this)) {
|
||||
// This is the warning msg for teachers to inform them that cluster
|
||||
// and unseen does not work while logged in as a teacher.
|
||||
$warningvars = new stdClass();
|
||||
$warningvars->cluster = get_string('clusterjump', 'lesson');
|
||||
$warningvars->unseen = get_string('unseenpageinbranch', 'lesson');
|
||||
$this->add_message(get_string('teacherjumpwarning', 'lesson', $warningvars));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,6 +295,24 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
|
||||
$validation = testable_mod_lesson_external::validate_attempt($lesson, ['password' => ''], true);
|
||||
$this->assertEquals('noretake', key($validation));
|
||||
$this->assertCount(1, $validation);
|
||||
|
||||
// Test time limit restriction.
|
||||
$timenow = time();
|
||||
// Create a timer for the current user.
|
||||
$timer1 = new stdClass;
|
||||
$timer1->lessonid = $this->lesson->id;
|
||||
$timer1->userid = $this->student->id;
|
||||
$timer1->completed = 0;
|
||||
$timer1->starttime = $timenow - DAYSECS;
|
||||
$timer1->lessontime = $timenow;
|
||||
$timer1->id = $DB->insert_record("lesson_timer", $timer1);
|
||||
|
||||
// Out of time.
|
||||
$DB->set_field('lesson', 'timelimit', HOURSECS, array('id' => $this->lesson->id));
|
||||
$lesson = new lesson($DB->get_record('lesson', array('id' => $this->lesson->id)));
|
||||
$validation = testable_mod_lesson_external::validate_attempt($lesson, ['password' => '', 'pageid' => 1], true);
|
||||
$this->assertEquals('eolstudentoutoftime', key($validation));
|
||||
$this->assertCount(1, $validation);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -735,4 +753,152 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertArrayNotHasKey('title', $page);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test launch_attempt. Time restrictions already tested in test_validate_attempt.
|
||||
*/
|
||||
public function test_launch_attempt() {
|
||||
global $DB, $SESSION;
|
||||
|
||||
// Test time limit restriction.
|
||||
$timenow = time();
|
||||
// Create a timer for the current user.
|
||||
$timer1 = new stdClass;
|
||||
$timer1->lessonid = $this->lesson->id;
|
||||
$timer1->userid = $this->student->id;
|
||||
$timer1->completed = 0;
|
||||
$timer1->starttime = $timenow;
|
||||
$timer1->lessontime = $timenow;
|
||||
$timer1->id = $DB->insert_record("lesson_timer", $timer1);
|
||||
|
||||
$DB->set_field('lesson', 'timelimit', 30, array('id' => $this->lesson->id));
|
||||
|
||||
unset($SESSION->lesson_messages);
|
||||
$result = mod_lesson_external::launch_attempt($this->lesson->id, '', 1);
|
||||
$result = external_api::clean_returnvalue(mod_lesson_external::launch_attempt_returns(), $result);
|
||||
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(2, $result['messages']);
|
||||
$messages = [];
|
||||
foreach ($result['messages'] as $message) {
|
||||
$messages[] = $message['type'];
|
||||
}
|
||||
sort($messages);
|
||||
$this->assertEquals(['center', 'notifyproblem'], $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test launch_attempt not finished forcing review mode.
|
||||
*/
|
||||
public function test_launch_attempt_not_finished_in_review_mode() {
|
||||
global $DB, $SESSION;
|
||||
|
||||
// Create a timer for the current user.
|
||||
$timenow = time();
|
||||
$timer1 = new stdClass;
|
||||
$timer1->lessonid = $this->lesson->id;
|
||||
$timer1->userid = $this->student->id;
|
||||
$timer1->completed = 0;
|
||||
$timer1->starttime = $timenow;
|
||||
$timer1->lessontime = $timenow;
|
||||
$timer1->id = $DB->insert_record("lesson_timer", $timer1);
|
||||
|
||||
unset($SESSION->lesson_messages);
|
||||
$this->setUser($this->teacher);
|
||||
$result = mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
$result = external_api::clean_returnvalue(mod_lesson_external::launch_attempt_returns(), $result);
|
||||
// Everything ok as teacher.
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(0, $result['messages']);
|
||||
// Should fails as student.
|
||||
$this->setUser($this->student);
|
||||
// Now, try to review this attempt. We should not be able because is a non-finished attempt.
|
||||
$this->setExpectedException('moodle_exception');
|
||||
mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test launch_attempt just finished forcing review mode.
|
||||
*/
|
||||
public function test_launch_attempt_just_finished_in_review_mode() {
|
||||
global $DB, $SESSION, $USER;
|
||||
|
||||
// Create a timer for the current user.
|
||||
$timenow = time();
|
||||
$timer1 = new stdClass;
|
||||
$timer1->lessonid = $this->lesson->id;
|
||||
$timer1->userid = $this->student->id;
|
||||
$timer1->completed = 1;
|
||||
$timer1->starttime = $timenow;
|
||||
$timer1->lessontime = $timenow;
|
||||
$timer1->id = $DB->insert_record("lesson_timer", $timer1);
|
||||
|
||||
// Create attempt.
|
||||
$newpageattempt = [
|
||||
'lessonid' => $this->lesson->id,
|
||||
'pageid' => $this->page2->id,
|
||||
'userid' => $this->student->id,
|
||||
'answerid' => 0,
|
||||
'retry' => 1,
|
||||
'correct' => 1,
|
||||
'useranswer' => '1',
|
||||
'timeseen' => time(),
|
||||
];
|
||||
$DB->insert_record('lesson_attempts', (object) $newpageattempt);
|
||||
// Create grade.
|
||||
$record = [
|
||||
'lessonid' => $this->lesson->id,
|
||||
'userid' => $this->student->id,
|
||||
'grade' => 100,
|
||||
'late' => 0,
|
||||
'completed' => 1,
|
||||
];
|
||||
$DB->insert_record('lesson_grades', (object) $record);
|
||||
|
||||
unset($SESSION->lesson_messages);
|
||||
$this->setUser($this->teacher);
|
||||
$result = mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
$result = external_api::clean_returnvalue(mod_lesson_external::launch_attempt_returns(), $result);
|
||||
// Everything ok as teacher.
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(0, $result['messages']);
|
||||
|
||||
$this->setUser($this->student);
|
||||
$result = mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
$result = external_api::clean_returnvalue(mod_lesson_external::launch_attempt_returns(), $result);
|
||||
// Everything ok as student.
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(0, $result['messages']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test launch_attempt not just finished forcing review mode.
|
||||
*/
|
||||
public function test_launch_attempt_not_just_finished_in_review_mode() {
|
||||
global $DB, $CFG, $SESSION;
|
||||
|
||||
// Create a timer for the current user.
|
||||
$timenow = time();
|
||||
$timer1 = new stdClass;
|
||||
$timer1->lessonid = $this->lesson->id;
|
||||
$timer1->userid = $this->student->id;
|
||||
$timer1->completed = 1;
|
||||
$timer1->starttime = $timenow - DAYSECS;
|
||||
$timer1->lessontime = $timenow - $CFG->sessiontimeout - HOURSECS;
|
||||
$timer1->id = $DB->insert_record("lesson_timer", $timer1);
|
||||
|
||||
unset($SESSION->lesson_messages);
|
||||
|
||||
// Everything ok as teacher.
|
||||
$this->setUser($this->teacher);
|
||||
$result = mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
$result = external_api::clean_returnvalue(mod_lesson_external::launch_attempt_returns(), $result);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertCount(0, $result['messages']);
|
||||
|
||||
// Fail as student.
|
||||
$this->setUser($this->student);
|
||||
$this->setExpectedException('moodle_exception');
|
||||
mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016120508; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2016120509; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016112900; // Requires this Moodle version
|
||||
$plugin->component = 'mod_lesson'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 0;
|
||||
|
@ -193,6 +193,8 @@ if ($pageid != LESSON_EOL) {
|
||||
|
||||
$lesson->set_module_viewed();
|
||||
|
||||
$timer = null;
|
||||
|
||||
// This is where several messages (usually warnings) are displayed
|
||||
// all of this is displayed above the actual page
|
||||
|
||||
@ -204,57 +206,16 @@ if ($pageid != LESSON_EOL) {
|
||||
$restart = ($continue && $startlastseen == 'yes');
|
||||
$timer = $lesson->update_timer($continue, $restart);
|
||||
|
||||
if ($lesson->timelimit) {
|
||||
$timeleft = $timer->starttime + $lesson->timelimit - time();
|
||||
if ($timeleft <= 0) {
|
||||
// Out of time
|
||||
$lesson->add_message(get_string('eolstudentoutoftime', 'lesson'));
|
||||
redirect(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id,'pageid'=>LESSON_EOL, 'outoftime'=>'normal')));
|
||||
die; // Shouldn't be reached, but make sure
|
||||
} else if ($timeleft < 60) {
|
||||
// One minute warning
|
||||
$lesson->add_message(get_string('studentoneminwarning', 'lesson'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($page->qtype == LESSON_PAGE_BRANCHTABLE && $lesson->minquestions) {
|
||||
// tell student how many questions they have seen, how many are required and their grade
|
||||
$ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
|
||||
$gradeinfo = lesson_grade($lesson, $ntries);
|
||||
if ($gradeinfo->attempts) {
|
||||
if ($gradeinfo->nquestions < $lesson->minquestions) {
|
||||
$a = new stdClass;
|
||||
$a->nquestions = $gradeinfo->nquestions;
|
||||
$a->minquestions = $lesson->minquestions;
|
||||
$lesson->add_message(get_string('numberofpagesviewednotice', 'lesson', $a));
|
||||
}
|
||||
|
||||
if (!$reviewmode && !$lesson->retake){
|
||||
$lesson->add_message(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'notify');
|
||||
if ($lesson->grade != GRADE_TYPE_NONE) {
|
||||
$a = new stdClass;
|
||||
$a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1);
|
||||
$a->total = $lesson->grade;
|
||||
$lesson->add_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$timer = null;
|
||||
if ($lesson->timelimit) {
|
||||
$lesson->add_message(get_string('teachertimerwarning', 'lesson'));
|
||||
}
|
||||
if (lesson_display_teacher_warning($lesson)) {
|
||||
// This is the warning msg for teachers to inform them that cluster
|
||||
// and unseen does not work while logged in as a teacher
|
||||
$warningvars = new stdClass();
|
||||
$warningvars->cluster = get_string('clusterjump', 'lesson');
|
||||
$warningvars->unseen = get_string('unseenpageinbranch', 'lesson');
|
||||
$lesson->add_message(get_string('teacherjumpwarning', 'lesson', $warningvars));
|
||||
// Check time limit.
|
||||
if (!$lesson->check_time($timer)) {
|
||||
redirect(new moodle_url('/mod/lesson/view.php', array('id' => $cm->id, 'pageid' => LESSON_EOL, 'outoftime' => 'normal')));
|
||||
die; // Shouldn't be reached, but make sure.
|
||||
}
|
||||
}
|
||||
|
||||
// Add different informative messages to the given page.
|
||||
$lesson->add_messages_on_page_view($page, $reviewmode);
|
||||
|
||||
$PAGE->set_subpage($page->id);
|
||||
$currenttab = 'view';
|
||||
$extraeditbuttons = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user