PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/course/format/topics/format.php

https://github.com/kpike/moodle
PHP | 288 lines | 202 code | 51 blank | 35 comment | 49 complexity | 8fb97935971daf00f41879771cf8a408 MD5 | raw file
  1. <?php
  2. // Display the whole course as "topics" made of of modules
  3. // Included from "view.php"
  4. /**
  5. * Evaluation topics format for course display - NO layout tables, for accessibility, etc.
  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.
  9. * Less risk for the Moodle 1.6 beta release.
  10. * 1. Straight copy of topics/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. *
  15. * Target: 3-column graphical view using relative widths for pixel screen sizes
  16. * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
  17. *
  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
  24. * @package
  25. */
  26. defined('MOODLE_INTERNAL') || die();
  27. require_once($CFG->libdir.'/filelib.php');
  28. require_once($CFG->libdir.'/completionlib.php');
  29. $topic = optional_param('topic', -1, PARAM_INT);
  30. if ($topic != -1) {
  31. $displaysection = course_set_display($course->id, $topic);
  32. } else {
  33. $displaysection = course_get_display($course->id);
  34. }
  35. $context = get_context_instance(CONTEXT_COURSE, $course->id);
  36. if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
  37. $course->marker = $marker;
  38. $DB->set_field("course", "marker", $marker, array("id"=>$course->id));
  39. }
  40. $streditsummary = get_string('editsummary');
  41. $stradd = get_string('add');
  42. $stractivities = get_string('activities');
  43. $strshowalltopics = get_string('showalltopics');
  44. $strtopic = get_string('topic');
  45. $strgroups = get_string('groups');
  46. $strgroupmy = get_string('groupmy');
  47. $editing = $PAGE->user_is_editing();
  48. if ($editing) {
  49. $strtopichide = get_string('hidetopicfromothers');
  50. $strtopicshow = get_string('showtopicfromothers');
  51. $strmarkthistopic = get_string('markthistopic');
  52. $strmarkedthistopic = get_string('markedthistopic');
  53. $strmoveup = get_string('moveup');
  54. $strmovedown = get_string('movedown');
  55. }
  56. // Print the Your progress icon if the track completion is enabled
  57. $completioninfo = new completion_info($course);
  58. echo $completioninfo->display_help_icon();
  59. echo $OUTPUT->heading(get_string('topicoutline'), 2, 'headingblock header outline');
  60. // Note, an ordered list would confuse - "1" could be the clipboard or summary.
  61. echo "<ul class='topics'>\n";
  62. /// If currently moving a file then show the current clipboard
  63. if (ismoving($course->id)) {
  64. $stractivityclipboard = strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
  65. $strcancel= get_string('cancel');
  66. echo '<li class="clipboard">';
  67. echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.sesskey().'">'.$strcancel.'</a>)';
  68. echo "</li>\n";
  69. }
  70. /// Print Section 0 with general activities
  71. $section = 0;
  72. $thissection = $sections[$section];
  73. unset($sections[0]);
  74. if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
  75. // Note, no need for a 'left side' cell or DIV.
  76. // Note, 'right side' is BEFORE content.
  77. echo '<li id="section-0" class="section main clearfix" >';
  78. echo '<div class="left side">&nbsp;</div>';
  79. echo '<div class="right side" >&nbsp;</div>';
  80. echo '<div class="content">';
  81. if (!is_null($thissection->name)) {
  82. echo $OUTPUT->heading($thissection->name, 3, 'sectionname');
  83. }
  84. echo '<div class="summary">';
  85. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
  86. $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
  87. $summaryformatoptions = new stdClass();
  88. $summaryformatoptions->noclean = true;
  89. $summaryformatoptions->overflowdiv = true;
  90. echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
  91. if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) {
  92. echo '<a title="'.$streditsummary.'" '.
  93. ' href="editsection.php?id='.$thissection->id.'"><img src="'.$OUTPUT->pix_url('t/edit') . '" '.
  94. ' class="icon edit" alt="'.$streditsummary.'" /></a>';
  95. }
  96. echo '</div>';
  97. print_section($course, $thissection, $mods, $modnamesused);
  98. if ($PAGE->user_is_editing()) {
  99. print_section_add_menus($course, $section, $modnames);
  100. }
  101. echo '</div>';
  102. echo "</li>\n";
  103. }
  104. /// Now all the normal modules by topic
  105. /// Everything below uses "section" terminology - each "section" is a topic.
  106. $section = 1;
  107. $sectionmenu = array();
  108. while ($section <= $course->numsections) {
  109. if (!empty($sections[$section])) {
  110. $thissection = $sections[$section];
  111. } else {
  112. $thissection = new stdClass;
  113. $thissection->course = $course->id; // Create a new section structure
  114. $thissection->section = $section;
  115. $thissection->name = null;
  116. $thissection->summary = '';
  117. $thissection->summaryformat = FORMAT_HTML;
  118. $thissection->visible = 1;
  119. $thissection->id = $DB->insert_record('course_sections', $thissection);
  120. }
  121. $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
  122. if (!empty($displaysection) and $displaysection != $section) { // Check this topic is visible
  123. if ($showsection) {
  124. $sectionmenu[$section] = get_section_name($course, $thissection);
  125. }
  126. $section++;
  127. continue;
  128. }
  129. if ($showsection) {
  130. $currenttopic = ($course->marker == $section);
  131. $currenttext = '';
  132. if (!$thissection->visible) {
  133. $sectionstyle = ' hidden';
  134. } else if ($currenttopic) {
  135. $sectionstyle = ' current';
  136. $currenttext = get_accesshide(get_string('currenttopic','access'));
  137. } else {
  138. $sectionstyle = '';
  139. }
  140. echo '<li id="section-'.$section.'" class="section main clearfix'.$sectionstyle.'" >'; //'<div class="left side">&nbsp;</div>';
  141. echo '<div class="left side">'.$currenttext.$section.'</div>';
  142. // Note, 'right side' is BEFORE content.
  143. echo '<div class="right side">';
  144. if ($displaysection == $section) { // Show the zoom boxes
  145. echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
  146. '<img src="'.$OUTPUT->pix_url('i/all') . '" class="icon" alt="'.$strshowalltopics.'" /></a><br />';
  147. } else {
  148. $strshowonlytopic = get_string("showonlytopic", "", $section);
  149. echo '<a href="view.php?id='.$course->id.'&amp;topic='.$section.'" title="'.$strshowonlytopic.'">'.
  150. '<img src="'.$OUTPUT->pix_url('i/one') . '" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
  151. }
  152. if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
  153. if ($course->marker == $section) { // Show the "light globe" on/off
  154. echo '<a href="view.php?id='.$course->id.'&amp;marker=0&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marked') . '" alt="'.$strmarkedthistopic.'" /></a><br />';
  155. } else {
  156. echo '<a href="view.php?id='.$course->id.'&amp;marker='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkthistopic.'">'.'<img src="'.$OUTPUT->pix_url('i/marker') . '" alt="'.$strmarkthistopic.'" /></a><br />';
  157. }
  158. if ($thissection->visible) { // Show the hide/show eye
  159. echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopichide.'">'.
  160. '<img src="'.$OUTPUT->pix_url('i/hide') . '" class="icon hide" alt="'.$strtopichide.'" /></a><br />';
  161. } else {
  162. echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strtopicshow.'">'.
  163. '<img src="'.$OUTPUT->pix_url('i/show') . '" class="icon hide" alt="'.$strtopicshow.'" /></a><br />';
  164. }
  165. if ($section > 1) { // Add a arrow to move section up
  166. 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.'">'.
  167. '<img src="'.$OUTPUT->pix_url('t/up') . '" class="icon up" alt="'.$strmoveup.'" /></a><br />';
  168. }
  169. if ($section < $course->numsections) { // Add a arrow to move section down
  170. 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.'">'.
  171. '<img src="'.$OUTPUT->pix_url('t/down') . '" class="icon down" alt="'.$strmovedown.'" /></a><br />';
  172. }
  173. }
  174. echo '</div>';
  175. echo '<div class="content">';
  176. if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students
  177. echo get_string('notavailable');
  178. } else {
  179. if (!is_null($thissection->name)) {
  180. echo $OUTPUT->heading($thissection->name, 3, 'sectionname');
  181. }
  182. echo '<div class="summary">';
  183. if ($thissection->summary) {
  184. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
  185. $summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
  186. $summaryformatoptions = new stdClass();
  187. $summaryformatoptions->noclean = true;
  188. $summaryformatoptions->overflowdiv = true;
  189. echo format_text($summarytext, $thissection->summaryformat, $summaryformatoptions);
  190. } else {
  191. echo '&nbsp;';
  192. }
  193. if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
  194. echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
  195. '<img src="'.$OUTPUT->pix_url('t/edit') . '" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
  196. }
  197. echo '</div>';
  198. print_section($course, $thissection, $mods, $modnamesused);
  199. echo '<br />';
  200. if ($PAGE->user_is_editing()) {
  201. print_section_add_menus($course, $section, $modnames);
  202. }
  203. }
  204. echo '</div>';
  205. echo "</li>\n";
  206. }
  207. unset($sections[$section]);
  208. $section++;
  209. }
  210. if (!$displaysection and $PAGE->user_is_editing() and has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
  211. // print stealth sections if present
  212. $modinfo = get_fast_modinfo($course);
  213. foreach ($sections as $section=>$thissection) {
  214. if (empty($modinfo->sections[$section])) {
  215. continue;
  216. }
  217. echo '<li id="section-'.$section.'" class="section main clearfix orphaned hidden">'; //'<div class="left side">&nbsp;</div>';
  218. echo '<div class="left side">';
  219. echo '</div>';
  220. // Note, 'right side' is BEFORE content.
  221. echo '<div class="right side">';
  222. echo '</div>';
  223. echo '<div class="content">';
  224. echo $OUTPUT->heading(get_string('orphanedactivities'), 3, 'sectionname');
  225. print_section($course, $thissection, $mods, $modnamesused);
  226. echo '</div>';
  227. echo "</li>\n";
  228. }
  229. }
  230. echo "</ul>\n";
  231. if (!empty($sectionmenu)) {
  232. $select = new single_select(new moodle_url('/course/view.php', array('id'=>$course->id)), 'topic', $sectionmenu);
  233. $select->label = get_string('jumpto');
  234. $select->class = 'jumpmenu';
  235. $select->formid = 'sectionmenu';
  236. echo $OUTPUT->render($select);
  237. }