3 // Display the whole course as "topics" made of of modules
4 // Included from "view.php"
6 * Evaluation topics format for course display - NO layout tables, for accessibility, etc.
8 * A duplicate course format to enable the Moodle development team to evaluate
9 * CSS for the multi-column layout in place of layout tables.
10 * Less risk for the Moodle 1.6 beta release.
11 * 1. Straight copy of topics/format.php
12 * 2. Replace <table> and <td> with DIVs; inline styles.
13 * 3. Reorder columns so that in linear view content is first then blocks;
14 * styles to maintain original graphical (side by side) view.
16 * Target: 3-column graphical view using relative widths for pixel screen sizes
17 * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
19 * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
20 * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
22 * @copyright © 2006 The Open University
23 * @author N.D.Freear@open.ac.uk, and others.
24 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
28 defined('MOODLE_INTERNAL') || die();
30 require_once($CFG->libdir.'/filelib.php');
31 require_once($CFG->libdir.'/completionlib.php');
33 $topic = optional_param('topic', -1, PARAM_INT);
36 $displaysection = course_set_display($course->id, $topic);
38 $displaysection = course_get_display($course->id);
41 $context = get_context_instance(CONTEXT_COURSE, $course->id);
43 if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
44 $course->marker = $marker;
45 course_set_marker($course->id, $marker);
48 $streditsummary = get_string('editsummary');
49 $stradd = get_string('add');
50 $stractivities = get_string('activities');
51 $strshowalltopics = get_string('showalltopics');
52 $strtopic = get_string('topic');
53 $strgroups = get_string('groups');
54 $strgroupmy = get_string('groupmy');
55 $editing = $PAGE->user_is_editing();
58 $strtopichide = get_string('hidefromothers', 'format_topics');
59 $strtopicshow = get_string('showfromothers', 'format_topics');
60 $strmarkthistopic = get_string('markthistopic');
61 $strmarkedthistopic = get_string('markedthistopic');
62 $strmoveup = get_string('moveup');
63 $strmovedown = get_string('movedown');
66 // Print the Your progress icon if the track completion is enabled
67 $completioninfo = new completion_info($course);
68 echo $completioninfo->display_help_icon();
70 echo $OUTPUT->heading(get_string('topicoutline'), 2, 'headingblock header outline');
72 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
73 echo "<ul class='topics'>\n";
75 /// If currently moving a file then show the current clipboard
76 if (ismoving($course->id)) {
77 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
78 $strcancel= get_string('cancel');
79 echo '<li class="clipboard">';
80 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)';
84 /// Print Section 0 with general activities
87 $thissection = $sections[$section];
90 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
92 // Note, no need for a 'left side' cell or DIV.
93 // Note, 'right side' is BEFORE content.
94 echo '<li id="section-0" class="section main clearfix" >';
95 echo '<div class="left side"> </div>';
96 echo '<div class="right side" > </div>';
97 echo '<div class="content">';
98 if (!is_null($thissection->name)) {
99 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname');
101 echo '<div class="summary">';
103 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
104 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
105 $summaryformatoptions = new stdClass();
106 $summaryformatoptions->noclean = true;
107 $summaryformatoptions->overflowdiv = true;
108 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
110 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) {
111 echo '<a title="'.$streditsummary.'" '.
112 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
113 ' class="iconsmall edit" alt="'.$streditsummary.'" /></a>';
117 print_section($course, $thissection, $mods, $modnamesused);
119 if ($PAGE->user_is_editing()) {
120 print_section_add_menus($course, $section, $modnames);
128 /// Now all the normal modules by topic
129 /// Everything below uses "section" terminology - each "section" is a topic.
132 $sectionmenu = array();
134 while ($section <= $course->numsections) {
136 if (!empty($sections[$section])) {
137 $thissection = $sections[$section];
140 $thissection = new stdClass;
141 $thissection->course = $course->id; // Create a new section structure
142 $thissection->section = $section;
143 $thissection->name = null;
144 $thissection->summary = '';
145 $thissection->summaryformat = FORMAT_HTML;
146 $thissection->visible = 1;
147 $thissection->id = $DB->insert_record('course_sections', $thissection);
150 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
152 if (!empty($displaysection) and $displaysection != $section) { // Check this topic is visible
154 $sectionmenu[$section] = get_section_name($course, $thissection);
162 $currenttopic = ($course->marker == $section);
165 if (!$thissection->visible) {
166 $sectionstyle = ' hidden';
167 } else if ($currenttopic) {
168 $sectionstyle = ' current';
169 $currenttext = get_accesshide(get_string('currenttopic','access'));
174 echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >'; //'<div class="left side"> </div>';
176 echo '<div class="left side">'.$currenttext.$section.'</div>';
177 // Note, 'right side' is BEFORE content.
178 echo '<div class="right side">';
180 if ($displaysection == $section) { // Show the zoom boxes
181 echo '<a href="view.php?id='.$course->id.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
182 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon" alt="'.$strshowalltopics.'" /></a><br />';
184 $strshowonlytopic = get_string("showonlytopic", "", $section);
185 echo '<a href="view.php?id='.$course->id.'&topic='.$section.'" title="'.$strshowonlytopic.'">'.
186 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
189 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
191 if ($course->marker == $section) { // Show the "light globe" on/off
192 echo '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'" class="editing_highlight">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" class="icon"/></a><br />';
194 echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'" class="editing_highlight">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" class="icon"/></a><br />';
197 if ($thissection->visible) { // Show the hide/show eye
198 echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'" class="editing_showhide">'.
199 '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
201 echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'" class="editing_showhide">'.
202 '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
204 if ($section > 1) { // Add a arrow to move section up
205 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'" class="moveup">'.
206 '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
209 if ($section < $course->numsections) { // Add a arrow to move section down
210 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'" class="movedown">'.
211 '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
216 echo '<div class="content">';
217 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
218 echo get_string('notavailable');
220 if (!is_null($thissection->name)) {
221 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname');
223 echo '<div class="summary">';
224 if ($thissection->summary) {
225 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
226 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
227 $summaryformatoptions = new stdClass();
228 $summaryformatoptions->noclean = true;
229 $summaryformatoptions->overflowdiv = true;
230 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
235 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
236 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
237 '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
241 print_section($course, $thissection, $mods, $modnamesused);
243 if ($PAGE->user_is_editing()) {
244 print_section_add_menus($course, $section, $modnames);
252 unset($sections[$section]);
256 if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
257 // print stealth sections if present
258 $modinfo = get_fast_modinfo($course);
259 foreach ($sections as $section=>$thissection) {
260 if (empty($modinfo->sections[$section])) {
264 echo '<li id="section-'.$section.'" class="section main clearfix orphaned hidden">'; //'<div class="left side"> </div>';
266 echo '<div class="left side">';
268 // Note, 'right side' is BEFORE content.
269 echo '<div class="right side">';
271 echo '<div class="content">';
272 echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
273 print_section($course, $thissection, $mods, $modnamesused);
282 if (!empty($sectionmenu)) {
283 $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'topic', $sectionmenu);
284 $select->label = get_string('jumpto');
285 $select->class = 'jumpmenu';
286 $select->formid = 'sectionmenu';
287 echo $OUTPUT->render($select);
290 // Include course format js module
291 $PAGE->requires->js('/course/format/topics/format.js');