-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa3d0b1
commit 4564a61
Showing
9 changed files
with
250 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,6 @@ | |
* @author Alex Yeung <[email protected]> | ||
*/ | ||
class quiz extends examactivity { | ||
/** @var int Time buffer (20 minutes) before/after exam period. */ | ||
const TIME_BUFFER = 60 * 20; | ||
|
||
/** @var int Exam duration less than this value (5 hours) will be counted as exam */ | ||
const EXAM_DURATION = 3600 * 5; | ||
|
||
/** | ||
* Check if the quiz is an exam activity. | ||
* | ||
|
@@ -39,8 +33,8 @@ class quiz extends examactivity { | |
public function is_exam_activity(): bool { | ||
// Timeopen and timeclose are set. | ||
if ($this->activityinstance->timeopen != 0 && $this->activityinstance->timeclose != 0) { | ||
// Quiz is considered an exam activity if the time between open and close is less than 5 hours. | ||
return ($this->activityinstance->timeclose - $this->activityinstance->timeopen) < self::EXAM_DURATION; | ||
// Quiz is considered an exam activity if the time between open and close is less than configured exam duration. | ||
return ($this->activityinstance->timeclose - $this->activityinstance->timeopen) < $this->examduration; | ||
} | ||
|
||
return false; | ||
|
@@ -54,10 +48,19 @@ public function is_exam_activity(): bool { | |
public function is_active_exam_activity(): bool { | ||
if ($this->is_exam_activity()) { | ||
$now = time(); | ||
return ($this->activityinstance->timeopen - self::TIME_BUFFER < $now && | ||
$this->activityinstance->timeclose + self::TIME_BUFFER > $now); | ||
return ($this->activityinstance->timeopen - $this->timebuffer < $now && | ||
$this->activityinstance->timeclose + $this->timebuffer > $now); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Get the exam end time including buffer time (in unix timestamp). | ||
* | ||
* @return int | ||
*/ | ||
public function get_exam_end_time(): int { | ||
return $this->activityinstance->timeclose + $this->timebuffer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// 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/>. | ||
|
||
namespace local_examguard\output; | ||
|
||
use plugin_renderer_base; | ||
|
||
/** | ||
* Output renderer for local_examguard. | ||
* | ||
* @package local_examguard | ||
* @copyright 2024 onwards University College London {@link https://www.ucl.ac.uk/} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Alex Yeung <[email protected]> | ||
*/ | ||
class renderer extends plugin_renderer_base { | ||
|
||
/** | ||
* Render notification banner. | ||
* | ||
* @param int $examendtime The exam end time. | ||
* @return string | ||
* @throws \moodle_exception | ||
*/ | ||
public function render_notification_banner(int $examendtime): string { | ||
return $this->output->render_from_template( | ||
'local_examguard/notification_banner', | ||
['examendtime' => date('h:i a', $examendtime)] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.