2 // Display the whole course as "weeks" made of of modules
3 // Included from "view.php"
5 require_once($CFG->libdir
.'/ajax/ajaxlib.php');
7 if (!empty($THEME->customcorners
)) {
8 require_once($CFG->dirroot
.'/lib/custom_corners_lib.php');
11 $week = optional_param('week', -1, PARAM_INT
);
13 // Bounds for block widths
14 // more flexible for theme designers taken from theme config.php
15 $lmin = (empty($THEME->block_l_min_width
)) ?
100 : $THEME->block_l_min_width
;
16 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
17 $rmin = (empty($THEME->block_r_min_width
)) ?
100 : $THEME->block_r_min_width
;
18 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
20 define('BLOCK_L_MIN_WIDTH', $lmin);
21 define('BLOCK_L_MAX_WIDTH', $lmax);
22 define('BLOCK_R_MIN_WIDTH', $rmin);
23 define('BLOCK_R_MAX_WIDTH', $rmax);
25 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
27 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
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 /// Layout the whole page as three big columns.
59 echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>';
60 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
61 foreach ($lt as $column) {
65 /// The left column ...
67 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
68 echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
70 if (!empty($THEME->customcorners
)) print_custom_corners_start();
71 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
72 if (!empty($THEME->customcorners
)) print_custom_corners_end();
79 echo '<td id="middle-column">';
81 if (!empty($THEME->customcorners
)) print_custom_corners_start();
83 echo '<a name="startofcontent"></a>';
85 print_heading_block(get_string('weeklyoutline'), 'outline');
87 echo '<table class="weeks" width="100%" summary="'.get_string('layouttable').'">';
89 /// If currently moving a file then show the current clipboard
90 if (ismoving($course->id
)) {
91 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
92 $strcancel= get_string('cancel');
93 echo '<tr class="clipboard">';
94 echo '<td colspan="3">';
95 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
100 /// Print Section 0 with general activities
103 $thissection = $sections[$section];
105 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
106 echo '<tr id="section-0" class="section main">';
107 echo '<td class="left side"> </td>';
108 echo '<td class="content">';
110 echo '<div class="summary">';
111 $summaryformatoptions->noclean
= true;
112 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
114 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
115 echo '<a title="'.$streditsummary.'" '.
116 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
117 'class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
121 print_section($course, $thissection, $mods, $modnamesused);
123 if (isediting($course->id
)) {
124 print_section_add_menus($course, $section, $modnames);
128 echo '<td class="right side"> </td>';
130 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
135 /// Now all the normal modules by week
136 /// Everything below uses "section" terminology - each "section" is a week.
139 $weekdate = $course->startdate
; // this should be 0:00 Monday of that week
140 $weekdate +
= 7200; // Add two hours to avoid possible DST problems
142 $sectionmenu = array();
143 $weekofseconds = 604800;
144 $course->enddate
= $course->startdate +
($weekofseconds * $course->numsections
);
146 $strftimedateshort = ' '.get_string('strftimedateshort');
148 while ($weekdate < $course->enddate
) {
150 $nextweekdate = $weekdate +
($weekofseconds);
151 $weekday = userdate($weekdate, $strftimedateshort);
152 $endweekday = userdate($weekdate+
518400, $strftimedateshort);
154 if (!empty($sections[$section])) {
155 $thissection = $sections[$section];
159 $thissection->course
= $course->id
; // Create a new week structure
160 $thissection->section
= $section;
161 $thissection->summary
= '';
162 $thissection->visible
= 1;
163 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
164 notify('Error inserting new week!');
168 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
170 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
172 $sectionmenu['week='.$section] = s("$strweek $section | $weekday - $endweekday");
175 $weekdate = $nextweekdate;
181 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
183 if (!$thissection->visible
) {
184 $sectionstyle = ' hidden';
185 } else if ($currentweek) {
186 $sectionstyle = ' current';
191 echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">';
192 echo '<td class="left side"> </td>';
195 if (ajaxenabled() && $editing) {
196 // Temporarily hide the dates for the weeks. We do it this way
197 // for now. Eventually, we'll have to modify the javascript code
198 // to handle re-calculation of dates when sections are moved
199 // around. For now, just hide all the dates to avoid confusion.
202 $weekperiod = $weekday.' - '.$endweekday;
206 echo '<td class="content">';
207 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
208 echo '<div class="weekdates">'.$weekperiod.' ('.get_string('notavailable').')</div>';
211 echo '<div class="weekdates">'.$weekperiod.'</div>';
213 echo '<div class="summary">';
214 $summaryformatoptions->noclean
= true;
215 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
217 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
218 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
219 '<img src="'.$CFG->pixpath
.'/t/edit.gif" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
223 print_section($course, $thissection, $mods, $modnamesused);
225 if (isediting($course->id
)) {
226 print_section_add_menus($course, $section, $modnames);
231 echo '<td class="right side">';
233 if ($displaysection == $section) {
234 echo '<a href="view.php?id='.$course->id
.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
235 '<img src="'.$CFG->pixpath
.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
237 $strshowonlyweek = get_string("showonlyweek", "", $section);
238 echo '<a href="view.php?id='.$course->id
.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
239 '<img src="'.$CFG->pixpath
.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
242 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
243 if ($thissection->visible
) { // Show the hide/show eye
244 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekhide.'">'.
245 '<img src="'.$CFG->pixpath
.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
247 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekshow.'">'.
248 '<img src="'.$CFG->pixpath
.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
250 if ($section > 1) { // Add a arrow to move section up
251 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
252 '<img src="'.$CFG->pixpath
.'/t/up.gif" class="iconsmall up" alt="'.$strmoveup.'" /></a><br />';
255 if ($section < $course->numsections
) { // Add a arrow to move section down
256 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
257 '<img src="'.$CFG->pixpath
.'/t/down.gif" class="iconsmall down" alt="'.$strmovedown.'" /></a><br />';
262 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
266 $weekdate = $nextweekdate;
270 if (!empty($sectionmenu)) {
271 echo '<div align="center" class="jumpmenu">';
272 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
273 'sectionmenu', '', get_string('jumpto'), '', '', true);
277 if (!empty($THEME->customcorners
)) print_custom_corners_end();
284 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
285 echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
287 if (!empty($THEME->customcorners
)) print_custom_corners_start();
288 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
289 if (!empty($THEME->customcorners
)) print_custom_corners_end();
297 echo '</tr></table>';