MDL-20487 - improve accessibility issue for survey page layout and string.
[moodle.git] / course / format / weeks / format.php
CommitLineData
aa6c1ced 1<?php
600149be 2 // Display the whole course as "weeks" made of of modules
3 // Included from "view.php"
ab9ad21d 4/**
5 * Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
aa6c1ced
PS
6 *
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.
ab9ad21d 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.
14 *
aa6c1ced 15 * Target: 3-column graphical view using relative widths for pixel screen sizes
ab9ad21d 16 * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
aa6c1ced 17 *
ab9ad21d 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.
20 *
21 * @copyright &copy; 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
aa6c1ced 24 * @package
ab9ad21d 25 */
f9903ed0 26
644d506a 27 require_once($CFG->libdir.'/filelib.php');
ab9ad21d 28
0cdae0dc 29 $week = optional_param('week', -1, PARAM_INT);
30
0cdae0dc 31 if ($week != -1) {
b86fc0e2 32 $displaysection = course_set_display($course->id, $week);
33 } else {
34 if (isset($USER->display[$course->id])) {
35 $displaysection = $USER->display[$course->id];
600149be 36 } else {
b86fc0e2 37 $displaysection = course_set_display($course->id, 0);
600149be 38 }
39 }
40
a3f24f7c 41 $streditsummary = get_string('editsummary');
42 $stradd = get_string('add');
43 $stractivities = get_string('activities');
44 $strshowallweeks = get_string('showallweeks');
45 $strweek = get_string('week');
46 $strgroups = get_string('groups');
47 $strgroupmy = get_string('groupmy');
48 $editing = $PAGE->user_is_editing();
49
0f3fe4b6 50 if ($editing) {
9101efd3 51 $strweekhide = get_string('hideweekfromothers');
52 $strweekshow = get_string('showweekfromothers');
6cba878d 53 $strmoveup = get_string('moveup');
54 $strmovedown = get_string('movedown');
1ea7c627 55 }
9a223597 56
3924b988 57 $context = get_context_instance(CONTEXT_COURSE, $course->id);
e3568fde 58
59 //Print the Your progress icon if the track completion is enabled
60 $completioninfo = new completion_info($course);
61 $completioninfo->print_help_icon();
62
27ca34af 63 echo $OUTPUT->heading(get_string('weeklyoutline'), 2, 'headingblock header outline');
9a223597 64
ab9ad21d 65 // Note, an ordered list would confuse - "1" could be the clipboard or summary.
66 echo "<ul class='weeks'>\n";
9a223597 67
7977cffd 68/// If currently moving a file then show the current clipboard
69 if (ismoving($course->id)) {
294ce987 70 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
6cba878d 71 $strcancel= get_string('cancel');
ab9ad21d 72 echo '<li class="clipboard">';
d4a1fcaf 73 echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
ab9ad21d 74 echo "</li>\n";
c63bf72a 75 }
7977cffd 76
1ea7c627 77/// Print Section 0 with general activities
9a223597 78
1ea7c627 79 $section = 0;
80 $thissection = $sections[$section];
9a223597 81
830dd6e9 82 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
ab9ad21d 83
84 // Note, 'right side' is BEFORE content.
7e184672 85 echo '<li id="section-0" class="section main clearfix" >';
d4a03c00 86 echo '<div class="left side">&nbsp;</div>';
aa6c1ced 87 echo '<div class="right side" >&nbsp;</div>';
ab9ad21d 88 echo '<div class="content">';
aa6c1ced 89
40901069 90 echo '<div class="summary">';
644d506a 91
92 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
edc0c493 93 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id);
644d506a 94 $summaryformatoptions = new object();
179c9a50 95 $summaryformatoptions->noclean = true;
644d506a 96 echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
5f850588 97
830dd6e9 98 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
ab9ad21d 99 echo '<p><a title="'.$streditsummary.'" '.
b5d0cafc 100 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
ab9ad21d 101 ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
9a223597 102 }
40901069 103 echo '</div>';
aa6c1ced 104
1ea7c627 105 print_section($course, $thissection, $mods, $modnamesused);
9a223597 106
830dd6e9 107 if ($PAGE->user_is_editing()) {
e0161bff 108 print_section_add_menus($course, $section, $modnames);
9a223597 109 }
110
ab9ad21d 111 echo '</div>';
112 echo "</li>\n";
9a223597 113 }
114
115
6cba878d 116/// Now all the normal modules by week
117/// Everything below uses "section" terminology - each "section" is a week.
118
f9903ed0 119 $timenow = time();
120 $weekdate = $course->startdate; // this should be 0:00 Monday of that week
01e1f34e 121 $weekdate += 7200; // Add two hours to avoid possible DST problems
1ea7c627 122 $section = 1;
584ec10e 123 $sectionmenu = array();
01e1f34e 124 $weekofseconds = 604800;
b5fe4c93 125 $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
f9903ed0 126
6cba878d 127 $strftimedateshort = ' '.get_string('strftimedateshort');
dcde9f02 128
e3f0a6a7 129 while ($weekdate < $course->enddate) {
f9903ed0 130
131 $nextweekdate = $weekdate + ($weekofseconds);
1ea7c627 132 $weekday = userdate($weekdate, $strftimedateshort);
01e1f34e 133 $endweekday = userdate($weekdate+518400, $strftimedateshort);
600149be 134
1ea7c627 135 if (!empty($sections[$section])) {
136 $thissection = $sections[$section];
f9903ed0 137
1ea7c627 138 } else {
139 unset($thissection);
140 $thissection->course = $course->id; // Create a new week structure
141 $thissection->section = $section;
6cba878d 142 $thissection->summary = '';
1ea7c627 143 $thissection->visible = 1;
a8f3a651 144 $thissection->id = $DB->insert_record('course_sections', $thissection);
1ea7c627 145 }
f9903ed0 146
3924b988 147 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
f9903ed0 148
8dc93b94 149 if (!empty($displaysection) and $displaysection != $section) { // Check this week is visible
150 if ($showsection) {
82fcab32 151 $sectionmenu[$section] = s("$strweek $section | $weekday - $endweekday");
8dc93b94 152 }
153 $section++;
154 $weekdate = $nextweekdate;
155 continue;
156 }
157
db7da819 158 if ($showsection) {
f9903ed0 159
db7da819 160 $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
f9903ed0 161
e9b9c1d8 162 $currenttext = '';
db7da819 163 if (!$thissection->visible) {
6cba878d 164 $sectionstyle = ' hidden';
db7da819 165 } else if ($currentweek) {
6cba878d 166 $sectionstyle = ' current';
e9b9c1d8 167 $currenttext = get_accesshide(get_string('currentweek','access'));
db7da819 168 } else {
6cba878d 169 $sectionstyle = '';
1ea7c627 170 }
171
7e184672 172 echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >';
dc140b6c 173
4454447d 174 echo '<div class="left side">&nbsp;'.$currenttext.'</div>';
12905134 175
ab9ad21d 176 // Note, 'right side' is BEFORE content.
177 echo '<div class="right side">';
aa6c1ced 178
db7da819 179 if ($displaysection == $section) {
0cdae0dc 180 echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
b5d0cafc 181 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
db7da819 182 } else {
183 $strshowonlyweek = get_string("showonlyweek", "", $section);
6cba878d 184 echo '<a href="view.php?id='.$course->id.'&amp;week='.$section.'" title="'.$strshowonlyweek.'">'.
b5d0cafc 185 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
12905134 186 }
dc140b6c 187
830dd6e9 188 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
db7da819 189 if ($thissection->visible) { // Show the hide/show eye
d4a1fcaf 190 echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
b5d0cafc 191 '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
db7da819 192 } else {
d4a1fcaf 193 echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
b5d0cafc 194 '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
db7da819 195 }
db7da819 196 if ($section > 1) { // Add a arrow to move section up
d4a1fcaf 197 echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'.
b5d0cafc 198 '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
db7da819 199 }
dc140b6c 200
db7da819 201 if ($section < $course->numsections) { // Add a arrow to move section down
d4a1fcaf 202 echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'.
b5d0cafc 203 '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
ab9ad21d 204 }
205 }
206 echo '</div>';
207
0154653b 208 $weekperiod = $weekday.' - '.$endweekday;
209
ab9ad21d 210 echo '<div class="content">';
211 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
7c5286cd 212 echo $OUTPUT->heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', 3, 'weekdates');
ab9ad21d 213
214 } else {
7c5286cd 215 echo $OUTPUT->heading($currenttext.$weekperiod, 3, 'weekdates');
ab9ad21d 216
217 echo '<div class="summary">';
6597e6b7
PS
218 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
219 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course_section', $thissection->id);
220 $summaryformatoptions = new object();
ab9ad21d 221 $summaryformatoptions->noclean = true;
6597e6b7 222 echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
ab9ad21d 223
830dd6e9 224 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
ab9ad21d 225 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
b5d0cafc 226 '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
ab9ad21d 227 }
228 echo '</div>';
229
230 print_section($course, $thissection, $mods, $modnamesused);
231
830dd6e9 232 if ($PAGE->user_is_editing()) {
ab9ad21d 233 print_section_add_menus($course, $section, $modnames);
db7da819 234 }
12905134 235 }
dc140b6c 236
ab9ad21d 237 echo '</div>';
238 echo "</li>\n";
1ea7c627 239 }
240
1ea7c627 241 $section++;
f9903ed0 242 $weekdate = $nextweekdate;
243 }
ab9ad21d 244 echo "</ul>\n";
584ec10e 245
246 if (!empty($sectionmenu)) {
6fe3775a
PS
247 $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'week', $sectionmenu);
248 $select->label = get_string('jumpto');
249 $select->class = 'jumpmenu';
250 $select->formid = 'sectionmenu';
251 echo $OUTPUT->render($select);
584ec10e 252 }