-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
83 lines (62 loc) · 3 KB
/
view.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
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require_once('../../config.php');
require_once('lib.php');
$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
$a = optional_param('a', 0, PARAM_INT); // programming ID
if ($id) {
if (! $cm = get_coursemodule_from_id('programming', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (! $programming = get_record('programming', 'id', $cm->instance)) {
error('Course module is incorrect');
}
} else {
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);
if (!$cm->visible) {
require_capability('moodle/course:viewhiddenactivities', $context);
}
require_capability('mod/programming:viewcontent', $context);
$viewatanytime = has_capability('mod/programming:viewcontentatanytime', $context);
$viewpubtestcase = has_capability('mod/programming:viewpubtestcase', $context);
add_to_log($course->id, 'programming', 'view', 'view.php?id='.$programming->id, $programming->name);
/// Print the page header
$pagename = get_string('view', 'programming');
$CFG->scripts[] = 'js/dp/shCore.js';
$CFG->scripts[] = 'js/dp/shBrushCSharp.js';
$CFG->scripts[] = 'view.js';
$CFG->stylesheets[] = 'js/dp/SyntaxHighlighter.css';
include_once('pageheader.php');
/// Print tabs
$currenttab = 'view';
include_once('tabs.php');
/// Print the main part of the page
$strshowasplaintext = get_string('showasplaintext', 'programming');
$time = time();
$pubtests = get_records_sql("SELECT * FROM {$CFG->prefix}programming_tests WHERE programmingid=$programming->id AND pub=1 ORDER BY id");
if (!is_array($pubtests)) $pubtests = array();
$submits = get_records_sql("SELECT * FROM {$CFG->prefix}programming_submits WHERE programmingid={$programming->id} AND userid={$USER->id} ORDER BY timemodified DESC");
if (is_array($submits)) {
$submit = current($submits);
$results = get_records('programming_test_results', 'submitid', $submit->id);
}
$presetcodes = get_records('programming_presetcode', 'programmingid', $programming->id, 'sequence');
$datafiles = get_records('programming_datafile', 'programmingid', $programming->id, 'seq', 'id, programmingid, filename, isbinary, datasize, checkdatasize');
$notlate = $programming->allowlate || $time <= $programming->timeclose;
include_once('view.tpl.php');
/// Finish the page
print_footer($course);
?>