-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.php
70 lines (58 loc) · 1.63 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once('../../../config.php');
//require the lpr db class
require_once($CFG->dirroot.'/blocks/cgr/db/db.php');
/**
*
*
* @copyright © @{YEAR} University of London Computer Centre
* @author http://www.ulcc.ac.uk, http://moodle.ulcc.ac.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package
* @version
*/
/**
* Changes the status of a CGR
*
*
* @param $cgr_id
* @param $status
*/
function change_cgr_status($cgr_id,$status) {
$db = new cgr_db();
$cgr = $db->get_cgr($cgr_id);
$cgr->complete = $status;
$db->update_cgr($cgr);
}
/**
* Removes a cgr and all records that reference it in the db
*
* @param int $cgr_id the id of the cgr that you want to delete
*/
function remove_cgr($cgr_id) {
$db = new cgr_db();
$db->delete_cgr($cgr_id);
}
function series_end($cgr_id) {
$db = new cgr_db();
$cgr = $db->get_cgr($cgr_id);
$seriescgrs = $db->get_series_cgrs($cgr->coursecode,$cgr->series);
if (!empty($seriescgrs)) {
foreach ($seriescgrs as $sc) {
$sc->seriesend = 1;
$db->update_cgr($sc);
}
}
}
function get_course_series_number($coursecode) {
$db = new cgr_db();
$cgrs = $db->get_incomplete_series($coursecode);
if (!empty($cgrs)) {
foreach($cgrs as $c) {
$seriesnumber = $c->series;
}
return (!empty($seriesnumber)) ? $seriesnumber : 1;
} else { $lastseries = $db->get_last_series_number($coursecode);
return (!empty($lastseries)) ? $lastseries->num + 1 : 1;
}
}