-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.php
executable file
·113 lines (92 loc) · 3.36 KB
/
index.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
//
// Capability definitions for the activequiz module.
//
// The capabilities are loaded into the database table when the module is
// installed or updated. Whenever the capability definitions are updated,
// the module version number should be bumped up.
//
// The system has four possible values for a capability:
// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
//
//
// CAPABILITY NAMING CONVENTION
//
// It is important that capability names are unique. The naming convention
// for capabilities that are specific to modules and blocks is as follows:
// [mod/block]/<component_name>:<capabilityname>
//
// component_name should be the same as the directory name of the mod or block.
//
// Core moodle capabilities are defined thus:
// moodle/<capabilityclass>:<capabilityname>
//
// Examples: mod/forum:viewpost
// block/recent_activity:view
// moodle/site:deleteuser
//
// The variable name for the capability definitions array follows the format
// $<componenttype>_<component_name>_capabilities
//
// For the core capabilities, the variable is $moodle_capabilities.
/**
* This page lists all the instances of activequiz in a particular course
*
* @author: Davosmith
* @package activequiz
**/
require_once("../../config.php");
require_once("lib.php");
$id = required_param('id', PARAM_INT); // course
if (!$course = $DB->get_record('course', array('id' => $id))) {
error("Course ID is incorrect");
}
$PAGE->set_url(new moodle_url('/mod/activequiz/index.php', array('id' => $course->id)));
require_course_login($course);
$PAGE->set_pagelayout('incourse');
/// Get all required strings
$stractivequizzes = get_string("modulenameplural", "activequiz");
$stractivequiz = get_string("modulename", "activequiz");
$PAGE->navbar->add($stractivequizzes);
$PAGE->set_title(strip_tags($course->shortname . ': ' . $stractivequizzes));
//$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
/// Get all the appropriate data
if (!$activequizs = get_all_instances_in_course("activequiz", $course)) {
notice("There are no activequizes", "../../course/view.php?id=$course->id");
die;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string("name");
$strweek = get_string("week");
$strtopic = get_string("topic");
$table = new html_table();
if ($course->format == "weeks") {
$table->head = array($strweek, $strname);
$table->align = array("center", "left");
} else if ($course->format == "topics") {
$table->head = array($strtopic, $strname);
$table->align = array("center", "left");
} else {
$table->head = array($strname);
$table->align = array("left", "left");
}
foreach ($activequizs as $activequiz) {
$url = new moodle_url('/mod/activequiz/view.php', array('id' => $activequiz->coursemodule));
if (!$activequiz->visible) {
//Show dimmed if the mod is hidden
$link = '<a class="dimmed" href="' . $url . '">' . $activequiz->name . '</a>';
} else {
//Show normal if the mod is visible
$link = '<a href="' . $url . '">' . $activequiz->name . '</a>';
}
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array($activequiz->section, $link);
} else {
$table->data[] = array($link);
}
}
echo html_writer::table($table);
/// Finish the page
echo $OUTPUT->footer();