2 // Display the whole course as "weeks" made of of modules
3 // Included from "view.php"
5 * Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
7 * A duplicate course format to enable the Moodle development team to evaluate
8 * CSS for the multi-column layout in place of layout tables.
9 * Less risk for the Moodle 1.6 beta release.
10 * 1. Straight copy of weeks/format.php
11 * 2. Replace <table> and <td> with DIVs; inline styles.
12 * 3. Reorder columns so that in linear view content is first then blocks;
13 * styles to maintain original graphical (side by side) view.
15 * Target: 3-column graphical view using relative widths for pixel screen sizes
16 * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
18 * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
19 * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
21 * @copyright © 2006 The Open University
22 * @author N.D.Freear@open.ac.uk, and others.
23 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
27 defined('MOODLE_INTERNAL') || die();
29 require_once($CFG->libdir.'/filelib.php');
30 require_once($CFG->libdir.'/completionlib.php');
32 $week = optional_param('week', -1, PARAM_INT);
35 $displaysection = course_set_display($course->id, $week);
37 $displaysection = course_get_display($course->id);
40 $streditsummary = get_string('editsummary');
41 $stradd = get_string('add');
42 $stractivities = get_string('activities');
43 $strshowallweeks = get_string('showallweeks');
44 $strweek = get_string('week');
45 $strgroups = get_string('groups');
46 $strgroupmy = get_string('groupmy');
47 $editing = $PAGE->user_is_editing();
50 $strweekhide = get_string('hideweekfromothers');
51 $strweekshow = get_string('showweekfromothers');
52 $strmoveup = get_string('moveup');
53 $strmovedown = get_string('movedown');
56 $context = get_context_instance(CONTEXT_COURSE, $course->id);
58 //Print the Your progress icon if the track completion is enabled
59 $completioninfo = new completion_info($course);
60 echo $completioninfo->display_help_icon();
62 echo $OUTPUT->heading(get_string('weeklyoutline'), 2, 'headingblock header outline');
64 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
65 echo "<ul class='weeks'>\n";
67 /// If currently moving a file then show the current clipboard
68 if (ismoving($course->id)) {
69 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
70 $strcancel= get_string('cancel');
71 echo '<li class="clipboard">';
72 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)';
76 /// Print Section 0 with general activities
79 $thissection = $sections[$section];
82 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
84 // Note, 'right side' is BEFORE content.
85 echo '<li id="section-0" class="section main clearfix" >';
86 echo '<div class="left side"> </div>';
87 echo '<div class="right side" > </div>';
88 echo '<div class="content">';
90 if (!empty($thissection->name)) {
91 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname');
94 echo '<div class="summary">';
96 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
97 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
98 $summaryformatoptions = new stdClass;
99 $summaryformatoptions->noclean = true;
100 $summaryformatoptions->overflowdiv = true;
101 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
103 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
104 echo '<p><a title="'.$streditsummary.'" '.
105 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
106 ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
110 print_section($course, $thissection, $mods, $modnamesused);
112 if ($PAGE->user_is_editing()) {
113 print_section_add_menus($course, $section, $modnames);
121 /// Now all the normal modules by week
122 /// Everything below uses "section" terminology - each "section" is a week.
125 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
126 $weekdate += 7200; // Add two hours to avoid possible DST problems
128 $sectionmenu = array();
129 $weekofseconds = 604800;
130 $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
132 $strftimedateshort = ' '.get_string('strftimedateshort');
134 while ($weekdate < $course->enddate) {
136 $nextweekdate = $weekdate + ($weekofseconds);
137 $weekday = userdate($weekdate, $strftimedateshort);
138 $endweekday = userdate($weekdate+518400, $strftimedateshort);
140 if (!empty($sections[$section])) {
141 $thissection = $sections[$section];
145 $thissection->course = $course->id; // Create a new week structure
146 $thissection->section = $section;
147 $thissection->name = null;
148 $thissection->summary = '';
149 $thissection->summaryformat = FORMAT_HTML;
150 $thissection->visible = 1;
151 $thissection->id = $DB->insert_record('course_sections', $thissection);
154 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
156 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
158 $sectionmenu[$section] = get_section_name($course, $thissection);
161 $weekdate = $nextweekdate;
167 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
170 if (!$thissection->visible) {
171 $sectionstyle = ' hidden';
172 } else if ($currentweek) {
173 $sectionstyle = ' current';
174 $currenttext = get_accesshide(get_string('currentweek','access'));
179 echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >';
181 echo '<div class="left side"> '.$currenttext.'</div>';
183 // Note, 'right side' is BEFORE content.
184 echo '<div class="right side">';
186 if ($displaysection == $section) {
187 echo '<a href="view.php?id='.$course->id.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
188 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
190 $strshowonlyweek = get_string("showonlyweek", "", $section);
191 echo '<a href="view.php?id='.$course->id.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
192 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
195 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
196 if ($thissection->visible) { // Show the hide/show eye
197 echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
198 '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
200 echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
201 '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
203 if ($section > 1) { // Add a arrow to move section up
204 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
205 '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
208 if ($section < $course->numsections) { // Add a arrow to move section down
209 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
210 '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
215 $weekperiod = $weekday.' - '.$endweekday;
217 echo '<div class="content">';
218 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
219 echo $OUTPUT->heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', 3, 'weekdates');
222 if (isset($thissection->name) && ($thissection->name !== NULL)) { // empty string is ok
223 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'weekdates');
225 echo $OUTPUT->heading($currenttext.$weekperiod, 3, 'weekdates');
227 echo '<div class="summary">';
228 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
229 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
230 $summaryformatoptions = new stdClass;
231 $summaryformatoptions->noclean = true;
232 $summaryformatoptions->overflowdiv = true;
233 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="icon 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]);
254 $weekdate = $nextweekdate;
257 if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
258 // print stealth sections if present
259 $modinfo = get_fast_modinfo($course);
260 foreach ($sections as $section=>$thissection) {
261 if (empty($modinfo->sections[$section])) {
265 echo '<li id="section-'.$section.'" class="section main clearfix stealth hidden">'; //'<div class="left side"> </div>';
267 echo '<div class="left side">';
269 // Note, 'right side' is BEFORE content.
270 echo '<div class="right side">';
272 echo '<div class="content">';
273 echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
274 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)), 'week', $sectionmenu);
284 $select->label = get_string('jumpto');
285 $select->class = 'jumpmenu';
286 $select->formid = 'sectionmenu';
287 echo $OUTPUT->render($select);