forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
108 lines (78 loc) · 3.47 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
<?PHP // $Id$
/// This page lists all the instances of wiki in a particular course
/// Replace wiki with the name of your module
require_once("../../config.php");
require_once("lib.php");
$id = required_param('id', PARAM_INT); // course
if (!$course = $DB->get_record('course', array('id'=>$id))) {
print_error('invalidcourseid');
}
require_course_login($course);
add_to_log($course->id, "wiki", "view all", "index.php?id=$course->id", "");
/// Get all required strings
$strwikis = get_string("modulenameplural", "wiki");
$strwiki = get_string("modulename", "wiki");
/// Print the header
$navlinks = array();
$navlinks[] = array('name' => $strwikis, 'link' => "index.php?id=$course->id", 'type' => 'activity');
$navigation = build_navigation($navlinks);
print_header_simple("$strwikis", "", $navigation, "", "", true, "", navmenu($course));
/// Get all the appropriate data
if (! $wikis = get_all_instances_in_course("wiki", $course)) {
notice(get_string('thereareno', 'moodle', $strwikis), "../../course/view.php?id=$course->id");
die;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string('wikiname', 'wiki');
$strsummary = get_string('summary');
$strtype = get_string('wikitype', 'wiki');
$strlastmodified = get_string('lastmodified');
$strweek = get_string('week');
$strtopic = get_string('topic');
if ($course->format == "weeks") {
$table->head = array ($strweek, $strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
} else if ($course->format == "topics") {
$table->head = array ($strtopic, $strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
} else {
$table->head = array ($strname, $strsummary, $strtype, $strlastmodified);
$table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
}
foreach ($wikis as $wiki) {
if (!$wiki->visible) {
//Show dimmed if the mod is hidden
$link = '<a class="dimmed" href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
} else {
//Show normal if the mod is visible
$link = '<a href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
}
$timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
$options = (object)array('noclean'=>true);
$summary = '<div class="smallinfo">'.format_module_intro('wiki', $wiki, $wiki->coursemodule).'</div>';
$site = get_site();
switch ($wiki->wtype) {
case 'teacher':
$wtype = get_string('defaultcoursestudent');
break;
case 'student':
$wtype = get_string('defaultcoursestudent');
break;
case 'group':
default:
$wtype = get_string('group');
break;
}
$wtype = '<span class="smallinfo">'.$wtype.'</span>';
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
} else {
$table->data[] = array ($link, $summary, $wtype, $timmod);
}
}
echo "<br />";
print_table($table);
/// Finish the page
echo $OUTPUT->footer();
?>