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
26 //TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
28 $week = optional_param('week', -1, PARAM_INT
);
31 $displaysection = course_set_display($course->id
, $week);
33 if (isset($USER->display
[$course->id
])) {
34 $displaysection = $USER->display
[$course->id
];
36 $displaysection = course_set_display($course->id
, 0);
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 $strstudents = moodle_strtolower($course->students
);
51 $strweekhide = get_string('weekhide', '', $strstudents);
52 $strweekshow = get_string('weekshow', '', $strstudents);
53 $strmoveup = get_string('moveup');
54 $strmovedown = get_string('movedown');
57 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
58 /* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
59 Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)
64 <style type
="text/css">
65 .weekscss
-format
{ width
: expression(document
.body
.clientWidth
< 800 ?
"752px" : "auto"); }
69 /// Layout the whole page as three big columns (was, id="layout-table")
70 echo '<div class="weekscss-format">';
72 /// The left column ...
74 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
75 echo '<div id="left-column">';
76 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
80 /// The right column, BEFORE the middle-column.
81 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
82 echo '<div id="right-column">';
83 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
88 echo '<div id="middle-column">'. skip_main_destination();
90 print_heading_block(get_string('weeklyoutline'), 'outline');
92 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
93 echo "<ul class='weekscss'>\n";
95 /// If currently moving a file then show the current clipboard
96 if (ismoving($course->id
)) {
97 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
98 $strcancel= get_string('cancel');
99 echo '<li class="clipboard">';
100 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
104 /// Print Section 0 with general activities
107 $thissection = $sections[$section];
109 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
111 // Note, no need for a 'left side' cell or DIV.
112 // Note, 'right side' is BEFORE content.
113 echo '<li id="section-0" class="section main" >';
114 echo '<div class="right side" > </div>';
115 echo '<div class="content">';
117 echo '<div class="summary">';
118 $summaryformatoptions->noclean
= true;
119 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
121 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
122 echo '<p><a title="'.$streditsummary.'" '.
123 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
124 ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
128 print_section($course, $thissection, $mods, $modnamesused);
130 if (isediting($course->id
)) {
131 print_section_add_menus($course, $section, $modnames);
139 /// Now all the normal modules by week
140 /// Everything below uses "section" terminology - each "section" is a week.
143 $weekdate = $course->startdate
; // this should be 0:00 Monday of that week
144 $weekdate +
= 7200; // Add two hours to avoid possible DST problems
146 $sectionmenu = array();
147 $weekofseconds = 604800;
148 $course->enddate
= $course->startdate +
($weekofseconds * $course->numsections
);
150 $strftimedateshort = ' '.get_string('strftimedateshort');
152 while ($weekdate < $course->enddate
) {
154 $nextweekdate = $weekdate +
($weekofseconds);
155 $weekday = userdate($weekdate, $strftimedateshort);
156 $endweekday = userdate($weekdate+
518400, $strftimedateshort);
158 if (!empty($sections[$section])) {
159 $thissection = $sections[$section];
163 $thissection->course
= $course->id
; // Create a new week structure
164 $thissection->section
= $section;
165 $thissection->summary
= '';
166 $thissection->visible
= 1;
167 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
168 notify('Error inserting new week!');
172 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
174 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
176 $sectionmenu['week='.$section] = s("$strweek $section | $weekday - $endweekday");
179 $weekdate = $nextweekdate;
185 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
188 if (!$thissection->visible
) {
189 $sectionstyle = ' hidden';
190 } else if ($currentweek) {
191 $sectionstyle = ' current';
192 $currenttext = get_accesshide(get_string('currentweek','access'));
197 echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side"> </div>';
199 // Note, 'right side' is BEFORE content.
200 echo '<div class="right side">';
202 if ($displaysection == $section) {
203 echo '<a href="view.php?id='.$course->id
.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
204 '<img src="'.$CFG->pixpath
.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
206 $strshowonlyweek = get_string("showonlyweek", "", $section);
207 echo '<a href="view.php?id='.$course->id
.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
208 '<img src="'.$CFG->pixpath
.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
211 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
212 if ($thissection->visible
) { // Show the hide/show eye
213 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekhide.'">'.
214 '<img src="'.$CFG->pixpath
.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
216 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekshow.'">'.
217 '<img src="'.$CFG->pixpath
.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
219 if ($section > 1) { // Add a arrow to move section up
220 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
221 '<img src="'.$CFG->pixpath
.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
224 if ($section < $course->numsections
) { // Add a arrow to move section down
225 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
226 '<img src="'.$CFG->pixpath
.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
231 $weekperiod = $weekday.' - '.$endweekday;
233 echo '<div class="content">';
234 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
235 print_heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', null, 3, 'weekdates');
238 print_heading($currenttext.$weekperiod, null, 3, 'weekdates');
240 echo '<div class="summary">';
241 $summaryformatoptions->noclean
= true;
242 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
244 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
245 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
246 '<img src="'.$CFG->pixpath
.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
250 print_section($course, $thissection, $mods, $modnamesused);
252 if (isediting($course->id
)) {
253 print_section_add_menus($course, $section, $modnames);
262 $weekdate = $nextweekdate;
266 if (!empty($sectionmenu)) {
267 echo '<div align="center" class="jumpmenu">';
268 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
269 'sectionmenu', '', get_string('jumpto'), '', '', true);
276 echo '<div class="clearer"></div>';