-
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.
Merge pull request #13 from examus/hyper
Various work on the plugin
- Loading branch information
Showing
21 changed files
with
820 additions
and
277 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,51 @@ | ||
<?php | ||
namespace availability_examus; | ||
use \stdClass; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
class common { | ||
public static function reset_entry($conditions){ | ||
global $DB; | ||
$oldentry = $DB->get_record('availability_examus', $conditions); | ||
if ($oldentry and $oldentry->status != 'Not inited') { | ||
$entries = $DB->get_records('availability_examus', [ | ||
'userid' => $oldentry->userid, | ||
'courseid' => $oldentry->courseid, | ||
'cmid' => $oldentry->cmid, | ||
'status' => 'Not inited']); | ||
if (count($entries) == 0) { | ||
$timenow = time(); | ||
$entry = new stdClass(); | ||
$entry->userid = $oldentry->userid; | ||
$entry->courseid = $oldentry->courseid; | ||
$entry->cmid = $oldentry->cmid; | ||
$entry->accesscode = md5(uniqid(rand(), 1)); | ||
$entry->status = 'Not inited'; | ||
$entry->timecreated = $timenow; | ||
$entry->timemodified = $timenow; | ||
$DB->insert_record('availability_examus', $entry); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
public static function delete_empty_entries($userid, $courseid, $cmid = null){ | ||
global $DB; | ||
|
||
$condition = [ | ||
'userid' => $userid, | ||
'courseid' => $courseid, | ||
'status' => 'Not inited' | ||
]; | ||
|
||
if(!empty($cmid)) { | ||
$condition['cmid'] = $cmid; | ||
} | ||
|
||
$DB->delete_records('availability_examus', $condition); | ||
} | ||
|
||
|
||
} |
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.