Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/course/format/weeks/format.php
Go to the documentation of this file.
00001 <?php
00002       // Display the whole course as "weeks" made of of modules
00003       // Included from "view.php"
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029     require_once($CFG->libdir.'/filelib.php');
00030     require_once($CFG->libdir.'/completionlib.php');
00031 
00032     $week = optional_param('week', -1, PARAM_INT);
00033 
00034     if ($week != -1) {
00035         $displaysection = course_set_display($course->id, $week);
00036     } else {
00037         $displaysection = course_get_display($course->id);
00038     }
00039 
00040     $streditsummary  = get_string('editsummary');
00041     $stradd          = get_string('add');
00042     $stractivities   = get_string('activities');
00043     $strshowallweeks = get_string('showallweeks');
00044     $strweek         = get_string('week');
00045     $strgroups       = get_string('groups');
00046     $strgroupmy      = get_string('groupmy');
00047     $editing         = $PAGE->user_is_editing();
00048 
00049     if ($editing) {
00050         $strweekhide = get_string('hideweekfromothers');
00051         $strweekshow = get_string('showweekfromothers');
00052         $strmoveup   = get_string('moveup');
00053         $strmovedown = get_string('movedown');
00054     }
00055 
00056     $context = get_context_instance(CONTEXT_COURSE, $course->id);
00057 
00058     //Print the Your progress icon if the track completion is enabled
00059     $completioninfo = new completion_info($course);
00060     echo $completioninfo->display_help_icon();
00061 
00062     echo $OUTPUT->heading(get_string('weeklyoutline'), 2, 'headingblock header outline');
00063 
00064     // Note, an ordered list would confuse - "1" could be the clipboard or summary.
00065     echo "<ul class='weeks'>\n";
00066 
00068     if (ismoving($course->id)) {
00069         $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
00070         $strcancel= get_string('cancel');
00071         echo '<li class="clipboard">';
00072         echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
00073         echo "</li>\n";
00074     }
00075 
00077 
00078     $section = 0;
00079     $thissection = $sections[$section];
00080     unset($sections[0]);
00081 
00082     if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
00083 
00084         // Note, 'right side' is BEFORE content.
00085         echo '<li id="section-0" class="section main clearfix" >';
00086         echo '<div class="left side">&nbsp;</div>';
00087         echo '<div class="right side" >&nbsp;</div>';
00088         echo '<div class="content">';
00089 
00090         if (!empty($thissection->name)) {
00091             echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname');
00092         }
00093 
00094         echo '<div class="summary">';
00095 
00096         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
00097         $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
00098         $summaryformatoptions = new stdClass;
00099         $summaryformatoptions->noclean = true;
00100         $summaryformatoptions->overflowdiv = true;
00101         echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
00102 
00103         if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
00104             echo '<p><a title="'.$streditsummary.'" '.
00105                  ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
00106                  ' class="iconsmall edit" alt="'.$streditsummary.'" /></a></p>';
00107         }
00108         echo '</div>';
00109 
00110         print_section($course, $thissection, $mods, $modnamesused);
00111 
00112         if ($PAGE->user_is_editing()) {
00113             print_section_add_menus($course, $section, $modnames);
00114         }
00115 
00116         echo '</div>';
00117         echo "</li>\n";
00118     }
00119 
00120 
00123 
00124     $timenow = time();
00125     $weekdate = $course->startdate;    // this should be 0:00 Monday of that week
00126     $weekdate += 7200;                 // Add two hours to avoid possible DST problems
00127     $section = 1;
00128     $sectionmenu = array();
00129     $weekofseconds = 604800;
00130     $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
00131 
00132     $strftimedateshort = ' '.get_string('strftimedateshort');
00133 
00134     while ($weekdate < $course->enddate) {
00135 
00136         $nextweekdate = $weekdate + ($weekofseconds);
00137         $weekday = userdate($weekdate, $strftimedateshort);
00138         $endweekday = userdate($weekdate+518400, $strftimedateshort);
00139 
00140         if (!empty($sections[$section])) {
00141             $thissection = $sections[$section];
00142 
00143         } else {
00144             $thissection = new stdClass();
00145             $thissection->course = $course->id;   // Create a new week structure
00146             $thissection->section = $section;
00147             $thissection->name    = null;
00148             $thissection->summary = '';
00149             $thissection->summaryformat = FORMAT_HTML;
00150             $thissection->visible = 1;
00151             $thissection->id = $DB->insert_record('course_sections', $thissection);
00152         }
00153 
00154         $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
00155 
00156         if (!empty($displaysection) and $displaysection != $section) {  // Check this week is visible
00157             if ($showsection) {
00158                 $sectionmenu[$section] = get_section_name($course, $thissection);
00159             }
00160             $section++;
00161             $weekdate = $nextweekdate;
00162             continue;
00163         }
00164 
00165         if ($showsection) {
00166 
00167             $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
00168 
00169             $currenttext = '';
00170             if (!$thissection->visible) {
00171                 $sectionstyle = ' hidden';
00172             } else if ($currentweek) {
00173                 $sectionstyle = ' current';
00174                 $currenttext = get_accesshide(get_string('currentweek','access'));
00175             } else {
00176                 $sectionstyle = '';
00177             }
00178 
00179             echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >';
00180 
00181             echo '<div class="left side">&nbsp;'.$currenttext.'</div>';
00182 
00183             // Note, 'right side' is BEFORE content.
00184             echo '<div class="right side">';
00185 
00186             if ($displaysection == $section) {
00187                 echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
00188                      '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
00189             } else {
00190                 $strshowonlyweek = get_string("showonlyweek", "", $section);
00191                 echo '<a href="view.php?id='.$course->id.'&amp;week='.$section.'" title="'.$strshowonlyweek.'">'.
00192                      '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
00193             }
00194 
00195             if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
00196                 if ($thissection->visible) {        // Show the hide/show eye
00197                     echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
00198                          '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
00199                 } else {
00200                     echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekshow.'">'.
00201                          '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
00202                 }
00203                 if ($section > 1) {                       // Add a arrow to move section up
00204                     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.'">'.
00205                          '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
00206                 }
00207 
00208                 if ($section < $course->numsections) {    // Add a arrow to move section down
00209                     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.'">'.
00210                          '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
00211                 }
00212             }
00213             echo '</div>';
00214 
00215             $weekperiod = $weekday.' - '.$endweekday;
00216 
00217             echo '<div class="content">';
00218             if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
00219                 echo $OUTPUT->heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', 3, 'weekdates');
00220 
00221             } else {
00222                 if (isset($thissection->name) && ($thissection->name !== NULL)) {  // empty string is ok
00223                     echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'weekdates');
00224                 } else {
00225                     echo $OUTPUT->heading($currenttext.$weekperiod, 3, 'weekdates');
00226                 }
00227                 echo '<div class="summary">';
00228                 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
00229                 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
00230                 $summaryformatoptions = new stdClass;
00231                 $summaryformatoptions->noclean = true;
00232                 $summaryformatoptions->overflowdiv = true;
00233                 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
00234 
00235                 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
00236                     echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
00237                          '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall edit" alt="'.$streditsummary.'" /></a><br /><br />';
00238                 }
00239                 echo '</div>';
00240 
00241                 print_section($course, $thissection, $mods, $modnamesused);
00242 
00243                 if ($PAGE->user_is_editing()) {
00244                     print_section_add_menus($course, $section, $modnames);
00245                 }
00246             }
00247 
00248             echo '</div>';
00249             echo "</li>\n";
00250         }
00251 
00252         unset($sections[$section]);
00253         $section++;
00254         $weekdate = $nextweekdate;
00255     }
00256 
00257     if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
00258         // print stealth sections if present
00259         $modinfo = get_fast_modinfo($course);
00260         foreach ($sections as $section=>$thissection) {
00261             if (empty($modinfo->sections[$section])) {
00262                 continue;
00263             }
00264 
00265             echo '<li id="section-'.$section.'" class="section main clearfix stealth hidden">'; //'<div class="left side">&nbsp;</div>';
00266 
00267             echo '<div class="left side">';
00268             echo '</div>';
00269             // Note, 'right side' is BEFORE content.
00270             echo '<div class="right side">';
00271             echo '</div>';
00272             echo '<div class="content">';
00273             echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
00274             print_section($course, $thissection, $mods, $modnamesused);
00275             echo '</div>';
00276             echo "</li>\n";
00277         }
00278     }
00279 
00280     echo "</ul>\n";
00281 
00282     if (!empty($sectionmenu)) {
00283         $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'week', $sectionmenu);
00284         $select->label = get_string('jumpto');
00285         $select->class = 'jumpmenu';
00286         $select->formid = 'sectionmenu';
00287         echo $OUTPUT->render($select);
00288     }
 All Data Structures Namespaces Files Functions Variables Enumerations