-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.php
58 lines (43 loc) · 1.73 KB
/
history.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
<?php
require_once('../../config.php');
require_once('lib.php');
$a = optional_param('a', 0, PARAM_INT); // programming ID
$userid = optional_param('userid', 0, PARAM_INT);
$submitid = optional_param('submitid', 0, PARAM_INT);
if (! $programming = get_record('programming', 'id', $a)) {
error('Course module is incorrect');
}
if (! $course = get_record('course', 'id', $programming->course)) {
error('Course is misconfigured');
}
if (! $cm = get_coursemodule_from_instance('programming', $programming->id, $course->id)) {
error('Course Module ID was incorrect');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id);
require_capability('mod/programming:viewhistory', $context);
if (!$userid) $userid = $USER->id;
$submits = get_records_select('programming_submits', 'programmingid='.$programming->id.' AND userid='.$userid, 'id DESC');
if ($programming->presetcode) {
if (is_array($submits)) {
foreach ($submits as $submit) {
$submit->code = programming_format_code($programming, $submit);
}
}
}
add_to_log($course->id, 'programming', 'history', me(), $programming->name);
/// Print the page header
$pagename = get_string('submithistory', 'programming');
$CFG->scripts[] = 'js/dp/shCore.js';
$CFG->scripts[] = 'js/dp/shBrushCSharp.js';
$CFG->scripts[] = 'history.js';
$CFG->stylesheets[] = 'js/dp/SyntaxHighlighter.css';
include_once('pageheader.php');
/// Print tabs
$currenttab = 'history';
include_once('tabs.php');
/// Print page content
include_once('history.tpl.php');
/// Finish the page
print_footer($course);
?>