-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory_fetch_code.php
More file actions
31 lines (28 loc) · 1.06 KB
/
history_fetch_code.php
File metadata and controls
31 lines (28 loc) · 1.06 KB
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
<?php
include_once('../../config.php');
include_once('lib.php');
$submitid = optional_param('submitid', 0, PARAM_INT);
$submit = get_record('programming_submits', 'id', $submitid);
if (! $programming = get_record('programming', 'id', $submit->programmingid)) {
error('Course module is incorrect');
}
if ($submit->userid != $USER->id) {
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);
if (!has_capability('mod/programming:viewotherprogram', $context)) {
$submit = null;
}
}
if ($programming->presetcode) {
$submit->code = programming_format_code($programming, $submit);
}
if ($submit) {
echo str_replace("\r\n", "\r", $submit->code);
}
?>