-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 42d712b
Showing
17 changed files
with
511 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#EXAMUS MOODLE PLUGIN | ||
|
||
## Installation | ||
1. Download zip, open `Administration→Plugins→Install plugins`, put zip there | ||
2. Go to `Administration→WebServices→Manage Tokens`, Add token for service Examus for Admin User. Examus will use this token for integration | ||
|
||
## Usage | ||
1. In course editing mode, `Edit settings` for module, scroll down to `Restrict access` | ||
2. Choose `Add restrictions... → Examus` to enable proctoring for this module. |
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,78 @@ | ||
<?php | ||
|
||
namespace availability_examus; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
use stdClass; | ||
|
||
class condition extends \core_availability\condition | ||
{ | ||
|
||
public function __construct($structure) | ||
{ | ||
} | ||
|
||
public function save() | ||
{ | ||
} | ||
|
||
public function is_available($not, | ||
\core_availability\info $info, $grabthelot, $userid) | ||
{ | ||
if (in_array('examus', $_SESSION)) { | ||
$allow = True; | ||
} else { | ||
$allow = False; | ||
} | ||
|
||
if ($not) { | ||
$allow = !$allow; | ||
} | ||
return $allow; | ||
} | ||
|
||
public function get_description($full, $not, \core_availability\info $info) | ||
{ | ||
return get_string('use_examus', 'availability_examus'); | ||
} | ||
|
||
protected function get_debug_string() | ||
{ | ||
return in_array('examus', $_SESSION) ? 'YES' : 'NO'; | ||
} | ||
|
||
public static function course_module_deleted(\core\event\course_module_deleted $event) | ||
{ | ||
global $DB; | ||
$cmid = $event->contextinstanceid; | ||
$DB->delete_records('availability_examus', array('cmid' => $cmid)); | ||
} | ||
|
||
public static function course_module_updated(\core\event\course_module_updated $event) | ||
{ | ||
global $DB; | ||
$cmid = $event->contextinstanceid; | ||
$course = get_course($event->courseid); | ||
$modinfo = get_fast_modinfo($course); | ||
$cm = $modinfo->get_cm($cmid); | ||
|
||
if (strpos($cm->availability, '"c":[{"type":"examus"}]') !== false) { | ||
$users = get_enrolled_users($event->get_context()); | ||
foreach ($users as $user) { | ||
$entry = $DB->get_record('availability_examus', array( | ||
'userid' => $user->id, 'courseid' => $event->courseid, 'cmid' => $cmid)); | ||
if (!$entry) { | ||
$entry = new stdClass(); | ||
$entry->userid = $user->id; | ||
$entry->courseid = $event->courseid; | ||
$entry->cmid = $cmid; | ||
$entry->accesscode = md5(uniqid(rand(), 1)); | ||
$entry->status = 'not_inited'; | ||
$DB->insert_record('availability_examus', $entry); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace availability_examus; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
class frontend extends \core_availability\frontend { | ||
|
||
protected function get_javascript_strings() { | ||
return array(); | ||
} | ||
|
||
protected function get_javascript_init_params($course, \cm_info $cm = null, | ||
\section_info $section = null) { | ||
return array(); | ||
} | ||
|
||
protected function allow_add($course, \cm_info $cm = null, | ||
\section_info $section = null) { | ||
return true; | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$observers = [ | ||
[ | ||
'eventname' => '\core\event\course_module_deleted', | ||
'callback' => '\availability_examus\condition::course_module_deleted' | ||
], | ||
[ | ||
'eventname' => '\core\event\course_module_updated', | ||
'callback' => '\availability_examus\condition::course_module_updated' | ||
] | ||
]; |
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<XMLDB PATH="availability/condition/examus/db" VERSION="20161021" COMMENT="XMLDB file for Moodle availability/condition/examus" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd" | ||
> | ||
<TABLES> | ||
<TABLE NAME="availability_examus" COMMENT="Default comment for availability_examus, please edit me"> | ||
<FIELDS> | ||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> | ||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="accesscode" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/> | ||
<FIELD NAME="status" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="not_inited" SEQUENCE="false"/> | ||
<FIELD NAME="review" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Review data in JSON format"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> | ||
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/> | ||
<KEY NAME="cmid" TYPE="foreign" FIELDS="cmid" REFTABLE="course_modules" REFFIELDS="id"/> | ||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/> | ||
</KEYS> | ||
</TABLE> | ||
</TABLES> | ||
</XMLDB> |
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,51 @@ | ||
<?php | ||
|
||
// 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/>. | ||
|
||
/** | ||
* Web service local plugin template external functions and service definitions. | ||
* | ||
* @package localwstemplate | ||
* @copyright 2011 Jerome Mouneyrac | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// We defined the web service functions to install. | ||
$functions = array( | ||
'availability_examus_user_proctored_modules' => array( | ||
'classname' => 'availability_examus_external', | ||
'methodname' => 'user_proctored_modules', | ||
'classpath' => 'availability/condition/examus/externallib.php', | ||
'description' => 'Returns modules exams for user', | ||
'type' => 'write', | ||
'services' => 'Examus', | ||
), | ||
'availability_examus_submit_proctoring_review' => array( | ||
'classname' => 'availability_examus_external', | ||
'methodname' => 'submit_proctoring_review', | ||
'classpath' => 'availability/condition/examus/externallib.php', | ||
'description' => 'Accepts review for proctoring session', | ||
'type' => 'write', | ||
'services' => 'Examus', | ||
) | ||
); | ||
|
||
// We define the services to install as pre-build services. A pre-build service is not editable by administrator. | ||
$services = array( | ||
'Examus' => array( | ||
'functions' => array ('availability_examus_user_proctored_modules', 'availability_examus_submit_proctoring_review'), | ||
'restrictedusers' => 0, | ||
'enabled'=>1, | ||
) | ||
); |
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,23 @@ | ||
<?php | ||
require_once('../../../config.php'); | ||
|
||
require_login(); | ||
|
||
global $DB; | ||
|
||
$accesscode = required_param('accesscode', PARAM_RAW); | ||
$entry = $DB->get_record('availability_examus', array('accesscode' => $accesscode)); | ||
|
||
if ($entry) { | ||
$entry->status = 'started'; | ||
$DB->update_record('availability_examus', $entry); | ||
$cmid = $entry->cmid; | ||
|
||
$_SESSION['examus'] = True; | ||
|
||
list($course, $cm) = get_course_and_cm_from_cmid($cmid); | ||
|
||
redirect($cm->url->out(false)); | ||
} | ||
|
||
die; |
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,144 @@ | ||
<?php | ||
|
||
require_once($CFG->libdir . "/externallib.php"); | ||
|
||
class availability_examus_external extends external_api | ||
{ | ||
|
||
/** | ||
* Returns description of method parameters | ||
* @return external_function_parameters | ||
*/ | ||
public static function user_proctored_modules_parameters() | ||
{ | ||
return new external_function_parameters( | ||
array('useremail' => new external_value(PARAM_TEXT, 'User Email')) | ||
); | ||
} | ||
|
||
/** | ||
* Returns welcome message | ||
* @return string welcome message | ||
*/ | ||
public static function user_proctored_modules($useremail) | ||
{ | ||
global $USER; | ||
global $DB; | ||
|
||
$params = self::validate_parameters(self::user_proctored_modules_parameters(), | ||
array('useremail' => $useremail)); | ||
|
||
$context = get_context_instance(CONTEXT_USER, $USER->id); | ||
self::validate_context($context); | ||
|
||
//Capability checking | ||
//OPTIONAL but in most web service it should present | ||
if (!has_capability('moodle/user:viewdetails', $context)) { | ||
throw new moodle_exception('cannotviewprofile'); | ||
} | ||
|
||
$user = $DB->get_record('user', array('email' => $useremail)); | ||
|
||
$entries = $DB->get_records('availability_examus', array('userid' => $user->id)); | ||
|
||
$answer = array(); | ||
foreach ($entries as $entry) { | ||
$course = get_course($entry->courseid); | ||
$modinfo = get_fast_modinfo($course); | ||
$cm = $modinfo->get_cm($entry->cmid); | ||
$url = new moodle_url( | ||
'/availability/condition/examus/entry.php', | ||
array('accesscode' => $entry->accesscode)); | ||
array_push($answer, | ||
array( | ||
'id' => $entry->id, | ||
'name' => $cm->get_formatted_name(), | ||
'url' => $url->out(), | ||
'course_name' => $course->fullname, | ||
'course_id' => $course->id, | ||
'is_proctored' => True, | ||
'time_limit_mins' => 60, | ||
// 'start' => new external_value(PARAM_TEXT, 'exam start', VALUE_OPTIONAL), | ||
// 'end' => new external_value(PARAM_TEXT, 'exam end', VALUE_OPTIONAL), | ||
) | ||
); | ||
} | ||
|
||
return array('modules' => $answer); | ||
} | ||
|
||
/** | ||
* Returns description of method result value | ||
* @return external_description | ||
*/ | ||
public static function user_proctored_modules_returns() | ||
{ | ||
return new external_single_structure( | ||
array('modules' => new external_multiple_structure( | ||
new external_single_structure( | ||
array( | ||
'id' => new external_value(PARAM_INT, 'exam id'), | ||
'name' => new external_value(PARAM_TEXT, 'exam name'), | ||
'url' => new external_value(PARAM_TEXT, 'exam url'), | ||
'course_name' => new external_value(PARAM_TEXT, 'exam course name', VALUE_OPTIONAL), | ||
'time_limit_mins' => new external_value(PARAM_INT, 'exxam duration', VALUE_OPTIONAL), | ||
'is_proctored' => new external_value(PARAM_BOOL, 'exam proctored'), | ||
'start' => new external_value(PARAM_TEXT, 'exam start', VALUE_OPTIONAL), | ||
'end' => new external_value(PARAM_TEXT, 'exam end', VALUE_OPTIONAL), | ||
), 'module') | ||
),) | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Returns description of method parameters | ||
* @return external_function_parameters | ||
*/ | ||
public static function submit_proctoring_review_parameters() | ||
{ | ||
return new external_function_parameters( | ||
array('accesscode' => new external_value(PARAM_TEXT, 'Access Code'), | ||
'review_link' => new external_value(PARAM_TEXT, 'Link to review page'), | ||
'status' => new external_value(PARAM_TEXT, 'Status of review')) | ||
); | ||
} | ||
|
||
/** | ||
* Returns welcome message | ||
* @return string welcome message | ||
*/ | ||
public static function submit_proctoring_review($accesscode, $review_link, $status) | ||
{ | ||
global $DB; | ||
|
||
$params = self::validate_parameters(self::submit_proctoring_review_parameters(), | ||
array('accesscode' => $accesscode, 'review_link' => $review_link, 'status' => $status)); | ||
|
||
$entry = $DB->get_record('availability_examus', array('accesscode' => $accesscode)); | ||
|
||
if ($entry) { | ||
$entry->review_link = $review_link; | ||
$entry->status = $status; | ||
|
||
$DB->update_record('availability_examus', $entry); | ||
return array('success' => True, 'error'=>null); | ||
} | ||
return array('success' => False, 'error'=>'Entry was not found'); | ||
|
||
} | ||
|
||
/** | ||
* Returns description of method result value | ||
* @return external_description | ||
*/ | ||
public static function submit_proctoring_review_returns() | ||
{ | ||
return new external_single_structure( | ||
array( | ||
'success' => new external_value(PARAM_BOOL, 'request success status'), | ||
'error' => new external_value(PARAM_TEXT, 'error message') | ||
) | ||
); | ||
} | ||
} |
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,8 @@ | ||
<?php | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$string['description'] = 'Allows students to use Examus proctoring service'; | ||
$string['pluginname'] = 'Proctoring by Examus'; | ||
$string['title'] = 'Examus'; | ||
|
||
$string['use_examus'] = 'Use examus app to view this module'; |
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,9 @@ | ||
<?php | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$plugin->component = 'availability_examus'; | ||
$plugin->version = 2016103100; | ||
$plugin->release = 'v3.1-r1'; | ||
$plugin->requires = 2016052300; | ||
$plugin->maturity = MATURITY_STABLE; |
Oops, something went wrong.