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 // some defines for time periods (all are seconds)
29 define( 'SECONDS_ONEWEEK', 604800 );
30 define( 'SECONDS_SIXDAYS', 518400 );
31 define( 'SECONDS_TWOHOURS', 7200 );
33 $week = optional_param('week', -1, PARAM_INT
);
36 $displaysection = course_set_display($course->id
, $week);
38 if (isset($USER->display
[$course->id
])) {
39 $displaysection = $USER->display
[$course->id
];
41 $displaysection = course_set_display($course->id
, 0);
45 $streditsummary = get_string('editsummary');
46 $stradd = get_string('add');
47 $stractivities = get_string('activities');
48 $strshowallweeks = get_string('showallweeks');
49 $strweek = get_string('week');
50 $strgroups = get_string('groups');
51 $strgroupmy = get_string('groupmy');
52 $editing = $PAGE->user_is_editing();
55 $strstudents = moodle_strtolower($course->students
);
56 $strweekhide = get_string('weekhide', '', $strstudents);
57 $strweekshow = get_string('weekshow', '', $strstudents);
58 $strmoveup = get_string('moveup');
59 $strmovedown = get_string('movedown');
62 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
63 /* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
64 Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)
69 <style type
="text/css">
70 .weekscss
-format
{ width
: expression(document
.body
.clientWidth
< 800 ?
"752px" : "auto"); }
74 /// Layout the whole page as three big columns (was, id="layout-table")
75 echo '<div class="weekscss-format">';
77 /// The left column ...
79 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
80 echo '<div id="left-column">';
81 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
85 /// The right column, BEFORE the middle-column.
86 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
87 echo '<div id="right-column">';
88 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
93 echo '<div id="middle-column">'. skip_main_destination();
95 print_heading_block(get_string('weeklyoutline'), 'outline');
97 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
98 echo "<ul class='weekscss'>\n";
100 /// If currently moving a file then show the current clipboard
101 if (ismoving($course->id
)) {
102 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
103 $strcancel= get_string('cancel');
104 echo '<li class="clipboard">';
105 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
109 /// Print Section 0 with general activities
112 $thissection = $sections[$section];
114 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
116 // Note, no need for a 'left side' cell or DIV.
117 // Note, 'right side' is BEFORE content.
118 echo '<li id="section-0" class="section main" >';
119 echo '<div class="right side" > </div>';
120 echo '<div class="content">';
122 echo '<div class="summary">';
123 $summaryformatoptions->noclean
= true;
124 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
126 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
127 echo '<p><a title="'.$streditsummary.'" '.
128 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
129 ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
133 print_section($course, $thissection, $mods, $modnamesused);
135 if (isediting($course->id
)) {
136 print_section_add_menus($course, $section, $modnames);
144 /// Now all the normal modules by week
145 /// Everything below uses "section" terminology - each "section" is a week.
148 $weekdate = $course->startdate
; // this should be 0:00 Monday of that week
149 $weekdate +
= SECONDS_TWOHOURS
; // Add two hours to avoid possible DST problems
151 $sectionmenu = array();
152 $weekofseconds = SECONDS_ONEWEEK
;
153 $course->enddate
= $course->startdate +
($weekofseconds * $course->numsections
);
155 $strftimedateshort = ' '.get_string('strftimedateshort');
157 while ($weekdate < $course->enddate
) {
159 $nextweekdate = $weekdate +
($weekofseconds);
160 $weekday = userdate($weekdate, $strftimedateshort);
161 $endweekday = userdate($weekdate+SECONDS_SIXDAYS
, $strftimedateshort);
163 if (!empty($sections[$section])) {
164 $thissection = $sections[$section];
168 $thissection->course
= $course->id
; // Create a new week structure
169 $thissection->section
= $section;
170 $thissection->summary
= '';
171 $thissection->visible
= 1;
172 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
173 notify('Error inserting new week!');
177 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
179 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
181 $sectionmenu['week='.$section] = s("$strweek $section | $weekday - $endweekday");
184 $weekdate = $nextweekdate;
190 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
193 if (!$thissection->visible
) {
194 $sectionstyle = ' hidden';
195 } else if ($currentweek) {
196 $sectionstyle = ' current';
197 $currenttext = get_accesshide(get_string('currentweek','access'));
202 echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side"> </div>';
204 // Note, 'right side' is BEFORE content.
205 echo '<div class="right side">';
207 if ($displaysection == $section) {
208 echo '<a href="view.php?id='.$course->id
.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
209 '<img src="'.$CFG->pixpath
.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
211 $strshowonlyweek = get_string("showonlyweek", "", $section);
212 echo '<a href="view.php?id='.$course->id
.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
213 '<img src="'.$CFG->pixpath
.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
216 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
217 if ($thissection->visible
) { // Show the hide/show eye
218 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekhide.'">'.
219 '<img src="'.$CFG->pixpath
.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
221 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekshow.'">'.
222 '<img src="'.$CFG->pixpath
.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
224 if ($section > 1) { // Add a arrow to move section up
225 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
226 '<img src="'.$CFG->pixpath
.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
229 if ($section < $course->numsections
) { // Add a arrow to move section down
230 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
231 '<img src="'.$CFG->pixpath
.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
236 $weekperiod = $weekday.' - '.$endweekday;
238 echo '<div class="content">';
239 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
240 print_heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', null, 3, 'weekdates');
243 print_heading($currenttext.$weekperiod, null, 3, 'weekdates');
245 echo '<div class="summary">';
246 $summaryformatoptions->noclean
= true;
247 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
249 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
250 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
251 '<img src="'.$CFG->pixpath
.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
255 print_section($course, $thissection, $mods, $modnamesused);
257 if (isediting($course->id
)) {
258 print_section_add_menus($course, $section, $modnames);
267 $weekdate = $nextweekdate;
271 if (!empty($sectionmenu)) {
272 echo '<div align="center" class="jumpmenu">';
273 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
274 'sectionmenu', '', get_string('jumpto'), '', '', true);
281 echo '<div class="clearer"></div>';