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 $week = optional_param('week', -1, PARAM_INT
);
9 // Bounds for block widths
10 // more flexible for theme designers taken from theme config.php
11 $lmin = (empty($THEME->block_l_min_width
)) ?
100 : $THEME->block_l_min_width
;
12 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
13 $rmin = (empty($THEME->block_r_min_width
)) ?
100 : $THEME->block_r_min_width
;
14 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
16 define('BLOCK_L_MIN_WIDTH', $lmin);
17 define('BLOCK_L_MAX_WIDTH', $lmax);
18 define('BLOCK_R_MIN_WIDTH', $rmin);
19 define('BLOCK_R_MAX_WIDTH', $rmax);
21 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
23 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
27 $displaysection = course_set_display($course->id
, $week);
29 if (isset($USER->display
[$course->id
])) {
30 $displaysection = $USER->display
[$course->id
];
32 $displaysection = course_set_display($course->id
, 0);
36 $streditsummary = get_string('editsummary');
37 $stradd = get_string('add');
38 $stractivities = get_string('activities');
39 $strshowallweeks = get_string('showallweeks');
40 $strweek = get_string('week');
41 $strgroups = get_string('groups');
42 $strgroupmy = get_string('groupmy');
43 $editing = $PAGE->user_is_editing();
46 $strstudents = moodle_strtolower($course->students
);
47 $strweekhide = get_string('weekhide', '', $strstudents);
48 $strweekshow = get_string('weekshow', '', $strstudents);
49 $strmoveup = get_string('moveup');
50 $strmovedown = get_string('movedown');
53 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
54 /// Layout the whole page as three big columns.
55 echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>';
56 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
57 foreach ($lt as $column) {
61 /// The left column ...
63 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$editing) {
64 echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
66 print_container_start();
67 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
68 print_container_end();
75 echo '<td id="middle-column">';
77 print_container_start();
79 echo skip_main_destination();
81 print_heading_block(get_string('weeklyoutline'), 'outline');
83 echo '<table class="weeks" width="100%" summary="'.get_string('layouttable').'">';
85 /// If currently moving a file then show the current clipboard
86 if (ismoving($course->id
)) {
87 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname
)));
88 $strcancel= get_string('cancel');
89 echo '<tr class="clipboard">';
90 echo '<td colspan="3">';
91 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey
.'">'.$strcancel.'</a>)';
96 /// Print Section 0 with general activities
99 $thissection = $sections[$section];
101 if ($thissection->summary
or $thissection->sequence
or isediting($course->id
)) {
102 echo '<tr id="section-0" class="section main">';
103 echo '<td class="left side"> </td>';
104 echo '<td class="content">';
106 echo '<div class="summary">';
107 $summaryformatoptions->noclean
= true;
108 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
110 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
111 echo '<a title="'.$streditsummary.'" '.
112 ' href="editsection.php?id='.$thissection->id
.'"><img src="'.$CFG->pixpath
.'/t/edit.gif" '.
113 'class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
117 print_section($course, $thissection, $mods, $modnamesused);
119 if (isediting($course->id
)) {
120 print_section_add_menus($course, $section, $modnames);
124 echo '<td class="right side"> </td>';
126 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
131 /// Now all the normal modules by week
132 /// Everything below uses "section" terminology - each "section" is a week.
135 $weekdate = $course->startdate
; // this should be 0:00 Monday of that week
136 $weekdate +
= 7200; // Add two hours to avoid possible DST problems
138 $sectionmenu = array();
139 $weekofseconds = 604800;
140 $course->enddate
= $course->startdate +
($weekofseconds * $course->numsections
);
142 $strftimedateshort = ' '.get_string('strftimedateshort');
144 while ($weekdate < $course->enddate
) {
146 $nextweekdate = $weekdate +
($weekofseconds);
147 $weekday = userdate($weekdate, $strftimedateshort);
148 $endweekday = userdate($weekdate+
518400, $strftimedateshort);
150 if (!empty($sections[$section])) {
151 $thissection = $sections[$section];
155 $thissection->course
= $course->id
; // Create a new week structure
156 $thissection->section
= $section;
157 $thissection->summary
= '';
158 $thissection->visible
= 1;
159 if (!$thissection->id
= insert_record('course_sections', $thissection)) {
160 notify('Error inserting new week!');
164 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible
or !$course->hiddensections
);
166 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
168 $sectionmenu['week='.$section] = s("$strweek $section | $weekday - $endweekday");
171 $weekdate = $nextweekdate;
177 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
180 if (!$thissection->visible
) {
181 $sectionstyle = ' hidden';
182 } else if ($currentweek) {
183 $sectionstyle = ' current';
184 $currenttext = get_accesshide(get_string('currentweek','access'));
189 echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">';
190 echo '<td class="left side"> '.$currenttext.'</td>';
192 $weekperiod = $weekday.' - '.$endweekday;
194 echo '<td class="content">';
195 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible
) { // Hidden for students
196 print_heading($weekperiod.' ('.get_string('notavailable').')', null, 3, 'weekdates');
199 print_heading($weekperiod, null, 3, 'weekdates');
201 echo '<div class="summary">';
202 $summaryformatoptions->noclean
= true;
203 echo format_text($thissection->summary
, FORMAT_HTML
, $summaryformatoptions);
205 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
206 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id
.'">'.
207 '<img src="'.$CFG->pixpath
.'/t/edit.gif" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
211 print_section($course, $thissection, $mods, $modnamesused);
213 if (isediting($course->id
)) {
214 print_section_add_menus($course, $section, $modnames);
219 echo '<td class="right side">';
221 if ($displaysection == $section) {
222 echo '<a href="view.php?id='.$course->id
.'&week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
223 '<img src="'.$CFG->pixpath
.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
225 $strshowonlyweek = get_string("showonlyweek", "", $section);
226 echo '<a href="view.php?id='.$course->id
.'&week='.$section.'" title="'.$strshowonlyweek.'">'.
227 '<img src="'.$CFG->pixpath
.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
230 if (isediting($course->id
) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE
, $course->id
))) {
231 if ($thissection->visible
) { // Show the hide/show eye
232 echo '<a href="view.php?id='.$course->id
.'&hide='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekhide.'">'.
233 '<img src="'.$CFG->pixpath
.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
235 echo '<a href="view.php?id='.$course->id
.'&show='.$section.'&sesskey='.$USER->sesskey
.'#section-'.$section.'" title="'.$strweekshow.'">'.
236 '<img src="'.$CFG->pixpath
.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
238 if ($section > 1) { // Add a arrow to move section up
239 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey
.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
240 '<img src="'.$CFG->pixpath
.'/t/up.gif" class="iconsmall up" alt="'.$strmoveup.'" /></a><br />';
243 if ($section < $course->numsections
) { // Add a arrow to move section down
244 echo '<a href="view.php?id='.$course->id
.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey
.'#section-'.($section+
1).'" title="'.$strmovedown.'">'.
245 '<img src="'.$CFG->pixpath
.'/t/down.gif" class="iconsmall down" alt="'.$strmovedown.'" /></a><br />';
250 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
254 $weekdate = $nextweekdate;
258 if (!empty($sectionmenu)) {
259 echo '<div align="center" class="jumpmenu">';
260 echo popup_form($CFG->wwwroot
.'/course/view.php?id='.$course->id
.'&', $sectionmenu,
261 'sectionmenu', '', get_string('jumpto'), '', '', true);
265 print_container_end();
272 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$editing) {
273 echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
275 print_container_start();
276 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
277 print_container_end();
285 echo '</tr></table>';