|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // Display the whole course as "topics" made of of modules 00004 // Included from "view.php" 00028 defined('MOODLE_INTERNAL') || die(); 00029 00030 require_once($CFG->libdir.'/filelib.php'); 00031 require_once($CFG->libdir.'/completionlib.php'); 00032 00033 $topic = optional_param('topic', -1, PARAM_INT); 00034 00035 if ($topic != -1) { 00036 $displaysection = course_set_display($course->id, $topic); 00037 } else { 00038 $displaysection = course_get_display($course->id); 00039 } 00040 00041 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00042 00043 if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { 00044 $course->marker = $marker; 00045 $DB->set_field("course", "marker", $marker, array("id"=>$course->id)); 00046 } 00047 00048 $streditsummary = get_string('editsummary'); 00049 $stradd = get_string('add'); 00050 $stractivities = get_string('activities'); 00051 $strshowalltopics = get_string('showalltopics'); 00052 $strtopic = get_string('topic'); 00053 $strgroups = get_string('groups'); 00054 $strgroupmy = get_string('groupmy'); 00055 $editing = $PAGE->user_is_editing(); 00056 00057 if ($editing) { 00058 $strtopichide = get_string('hidetopicfromothers'); 00059 $strtopicshow = get_string('showtopicfromothers'); 00060 $strmarkthistopic = get_string('markthistopic'); 00061 $strmarkedthistopic = get_string('markedthistopic'); 00062 $strmoveup = get_string('moveup'); 00063 $strmovedown = get_string('movedown'); 00064 } 00065 00066 // Print the Your progress icon if the track completion is enabled 00067 $completioninfo = new completion_info($course); 00068 echo $completioninfo->display_help_icon(); 00069 00070 echo $OUTPUT->heading(get_string('topicoutline'), 2, 'headingblock header outline'); 00071 00072 // Note, an ordered list would confuse - "1" could be the clipboard or summary. 00073 echo "<ul class='topics'>\n"; 00074 00076 if (ismoving($course->id)) { 00077 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname)); 00078 $strcancel= get_string('cancel'); 00079 echo '<li class="clipboard">'; 00080 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)'; 00081 echo "</li>\n"; 00082 } 00083 00085 00086 $section = 0; 00087 $thissection = $sections[$section]; 00088 unset($sections[0]); 00089 00090 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) { 00091 00092 // Note, no need for a 'left side' cell or DIV. 00093 // Note, 'right side' is BEFORE content. 00094 echo '<li id="section-0" class="section main clearfix" >'; 00095 echo '<div class="left side"> </div>'; 00096 echo '<div class="right side" > </div>'; 00097 echo '<div class="content">'; 00098 if (!is_null($thissection->name)) { 00099 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname'); 00100 } 00101 echo '<div class="summary">'; 00102 00103 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); 00104 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id); 00105 $summaryformatoptions = new stdClass(); 00106 $summaryformatoptions->noclean = true; 00107 $summaryformatoptions->overflowdiv = true; 00108 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); 00109 00110 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) { 00111 echo '<a title="'.$streditsummary.'" '. 00112 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '. 00113 ' class="iconsmall edit" alt="'.$streditsummary.'" /></a>'; 00114 } 00115 echo '</div>'; 00116 00117 print_section($course, $thissection, $mods, $modnamesused); 00118 00119 if ($PAGE->user_is_editing()) { 00120 print_section_add_menus($course, $section, $modnames); 00121 } 00122 00123 echo '</div>'; 00124 echo "</li>\n"; 00125 } 00126 00127 00130 00131 $section = 1; 00132 $sectionmenu = array(); 00133 00134 while ($section <= $course->numsections) { 00135 00136 if (!empty($sections[$section])) { 00137 $thissection = $sections[$section]; 00138 00139 } else { 00140 $thissection = new stdClass; 00141 $thissection->course = $course->id; // Create a new section structure 00142 $thissection->section = $section; 00143 $thissection->name = null; 00144 $thissection->summary = ''; 00145 $thissection->summaryformat = FORMAT_HTML; 00146 $thissection->visible = 1; 00147 $thissection->id = $DB->insert_record('course_sections', $thissection); 00148 } 00149 00150 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections); 00151 00152 if (!empty($displaysection) and $displaysection != $section) { // Check this topic is visible 00153 if ($showsection) { 00154 $sectionmenu[$section] = get_section_name($course, $thissection); 00155 } 00156 $section++; 00157 continue; 00158 } 00159 00160 if ($showsection) { 00161 00162 $currenttopic = ($course->marker == $section); 00163 00164 $currenttext = ''; 00165 if (!$thissection->visible) { 00166 $sectionstyle = ' hidden'; 00167 } else if ($currenttopic) { 00168 $sectionstyle = ' current'; 00169 $currenttext = get_accesshide(get_string('currenttopic','access')); 00170 } else { 00171 $sectionstyle = ''; 00172 } 00173 00174 echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >'; //'<div class="left side"> </div>'; 00175 00176 echo '<div class="left side">'.$currenttext.$section.'</div>'; 00177 // Note, 'right side' is BEFORE content. 00178 echo '<div class="right side">'; 00179 00180 if ($displaysection == $section) { // Show the zoom boxes 00181 echo '<a href="view.php?id='.$course->id.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'. 00182 '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon" alt="'.$strshowalltopics.'" /></a><br />'; 00183 } else { 00184 $strshowonlytopic = get_string("showonlytopic", "", $section); 00185 echo '<a href="view.php?id='.$course->id.'&topic='.$section.'" title="'.$strshowonlytopic.'">'. 00186 '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon" alt="'.$strshowonlytopic.'" /></a><br />'; 00187 } 00188 00189 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { 00190 00191 if ($course->marker == $section) { // Show the "light globe" on/off 00192 echo '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" class="icon"/></a><br />'; 00193 } else { 00194 echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" class="icon"/></a><br />'; 00195 } 00196 00197 if ($thissection->visible) { // Show the hide/show eye 00198 echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'">'. 00199 '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />'; 00200 } else { 00201 echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'">'. 00202 '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />'; 00203 } 00204 if ($section > 1) { // Add a arrow to move section up 00205 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.sesskey().'#section-'.($section-1).'" title="'.$strmoveup.'">'. 00206 '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />'; 00207 } 00208 00209 if ($section < $course->numsections) { // Add a arrow to move section down 00210 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.sesskey().'#section-'.($section+1).'" title="'.$strmovedown.'">'. 00211 '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />'; 00212 } 00213 } 00214 echo '</div>'; 00215 00216 echo '<div class="content">'; 00217 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students 00218 echo get_string('notavailable'); 00219 } else { 00220 if (!is_null($thissection->name)) { 00221 echo $OUTPUT->heading(format_string($thissection->name, true, array('context' => $context)), 3, 'sectionname'); 00222 } 00223 echo '<div class="summary">'; 00224 if ($thissection->summary) { 00225 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); 00226 $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id); 00227 $summaryformatoptions = new stdClass(); 00228 $summaryformatoptions->noclean = true; 00229 $summaryformatoptions->overflowdiv = true; 00230 echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions); 00231 } else { 00232 echo ' '; 00233 } 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 echo '<br />'; 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 } 00255 00256 if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { 00257 // print stealth sections if present 00258 $modinfo = get_fast_modinfo($course); 00259 foreach ($sections as $section=>$thissection) { 00260 if (empty($modinfo->sections[$section])) { 00261 continue; 00262 } 00263 00264 echo '<li id="section-'.$section.'" class="section main clearfix orphaned hidden">'; //'<div class="left side"> </div>'; 00265 00266 echo '<div class="left side">'; 00267 echo '</div>'; 00268 // Note, 'right side' is BEFORE content. 00269 echo '<div class="right side">'; 00270 echo '</div>'; 00271 echo '<div class="content">'; 00272 echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname'); 00273 print_section($course, $thissection, $mods, $modnamesused); 00274 echo '</div>'; 00275 echo "</li>\n"; 00276 } 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)), 'topic', $sectionmenu); 00284 $select->label = get_string('jumpto'); 00285 $select->class = 'jumpmenu'; 00286 $select->formid = 'sectionmenu'; 00287 echo $OUTPUT->render($select); 00288 }