[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Base renderer for outputting course formats. 19 * 20 * @package core 21 * @copyright 2012 Dan Poltawski 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @since Moodle 2.3 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 29 /** 30 * This is a convenience renderer which can be used by section based formats 31 * to reduce code duplication. It is not necessary for all course formats to 32 * use this and its likely to change in future releases. 33 * 34 * @package core 35 * @copyright 2012 Dan Poltawski 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 * @since Moodle 2.3 38 */ 39 abstract class format_section_renderer_base extends plugin_renderer_base { 40 41 /** @var contains instance of core course renderer */ 42 protected $courserenderer; 43 44 /** 45 * Constructor method, calls the parent constructor 46 * 47 * @param moodle_page $page 48 * @param string $target one of rendering target constants 49 */ 50 public function __construct(moodle_page $page, $target) { 51 parent::__construct($page, $target); 52 $this->courserenderer = $this->page->get_renderer('core', 'course'); 53 } 54 55 /** 56 * Generate the starting container html for a list of sections 57 * @return string HTML to output. 58 */ 59 abstract protected function start_section_list(); 60 61 /** 62 * Generate the closing container html for a list of sections 63 * @return string HTML to output. 64 */ 65 abstract protected function end_section_list(); 66 67 /** 68 * Generate the title for this section page 69 * @return string the page title 70 */ 71 abstract protected function page_title(); 72 73 /** 74 * Generate the section title 75 * 76 * @param stdClass $section The course_section entry from DB 77 * @param stdClass $course The course entry from DB 78 * @return string HTML to output. 79 */ 80 public function section_title($section, $course) { 81 $title = get_section_name($course, $section); 82 $url = course_get_url($course, $section->section, array('navigation' => true)); 83 if ($url) { 84 $title = html_writer::link($url, $title); 85 } 86 return $title; 87 } 88 89 /** 90 * Generate the content to displayed on the right part of a section 91 * before course modules are included 92 * 93 * @param stdClass $section The course_section entry from DB 94 * @param stdClass $course The course entry from DB 95 * @param bool $onsectionpage true if being printed on a section page 96 * @return string HTML to output. 97 */ 98 protected function section_right_content($section, $course, $onsectionpage) { 99 $o = $this->output->spacer(); 100 101 if ($section->section != 0) { 102 $controls = $this->section_edit_controls($course, $section, $onsectionpage); 103 if (!empty($controls)) { 104 $o = implode('<br />', $controls); 105 } 106 } 107 108 return $o; 109 } 110 111 /** 112 * Generate the content to displayed on the left part of a section 113 * before course modules are included 114 * 115 * @param stdClass $section The course_section entry from DB 116 * @param stdClass $course The course entry from DB 117 * @param bool $onsectionpage true if being printed on a section page 118 * @return string HTML to output. 119 */ 120 protected function section_left_content($section, $course, $onsectionpage) { 121 $o = $this->output->spacer(); 122 123 if ($section->section != 0) { 124 // Only in the non-general sections. 125 if (course_get_format($course)->is_section_current($section)) { 126 $o = get_accesshide(get_string('currentsection', 'format_'.$course->format)); 127 } 128 } 129 130 return $o; 131 } 132 133 /** 134 * Generate the display of the header part of a section before 135 * course modules are included 136 * 137 * @param stdClass $section The course_section entry from DB 138 * @param stdClass $course The course entry from DB 139 * @param bool $onsectionpage true if being printed on a single-section page 140 * @param int $sectionreturn The section to return to after an action 141 * @return string HTML to output. 142 */ 143 protected function section_header($section, $course, $onsectionpage, $sectionreturn=null) { 144 global $PAGE; 145 146 $o = ''; 147 $currenttext = ''; 148 $sectionstyle = ''; 149 150 if ($section->section != 0) { 151 // Only in the non-general sections. 152 if (!$section->visible) { 153 $sectionstyle = ' hidden'; 154 } else if (course_get_format($course)->is_section_current($section)) { 155 $sectionstyle = ' current'; 156 } 157 } 158 159 $o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section, 160 'class' => 'section main clearfix'.$sectionstyle, 'role'=>'region', 161 'aria-label'=> get_section_name($course, $section))); 162 163 $leftcontent = $this->section_left_content($section, $course, $onsectionpage); 164 $o.= html_writer::tag('div', $leftcontent, array('class' => 'left side')); 165 166 $rightcontent = $this->section_right_content($section, $course, $onsectionpage); 167 $o.= html_writer::tag('div', $rightcontent, array('class' => 'right side')); 168 $o.= html_writer::start_tag('div', array('class' => 'content')); 169 170 // When not on a section page, we display the section titles except the general section if null 171 $hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name))); 172 173 // When on a section page, we only display the general section title, if title is not the default one 174 $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); 175 176 $classes = ' accesshide'; 177 if ($hasnamenotsecpg || $hasnamesecpg) { 178 $classes = ''; 179 } 180 $o.= $this->output->heading($this->section_title($section, $course), 3, 'sectionname' . $classes); 181 182 $o.= html_writer::start_tag('div', array('class' => 'summary')); 183 $o.= $this->format_summary_text($section); 184 185 $context = context_course::instance($course->id); 186 if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) { 187 $url = new moodle_url('/course/editsection.php', array('id'=>$section->id, 'sr'=>$sectionreturn)); 188 $o.= html_writer::link($url, 189 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/settings'), 190 'class' => 'iconsmall edit', 'alt' => get_string('edit'))), 191 array('title' => get_string('editsummary'))); 192 } 193 $o.= html_writer::end_tag('div'); 194 195 $o .= $this->section_availability_message($section, 196 has_capability('moodle/course:viewhiddensections', $context)); 197 198 return $o; 199 } 200 201 /** 202 * Generate the display of the footer part of a section 203 * 204 * @return string HTML to output. 205 */ 206 protected function section_footer() { 207 $o = html_writer::end_tag('div'); 208 $o.= html_writer::end_tag('li'); 209 210 return $o; 211 } 212 213 /** 214 * Generate the edit controls of a section 215 * 216 * @param stdClass $course The course entry from DB 217 * @param stdClass $section The course_section entry from DB 218 * @param bool $onsectionpage true if being printed on a section page 219 * @return array of links with edit controls 220 */ 221 protected function section_edit_controls($course, $section, $onsectionpage = false) { 222 global $PAGE; 223 224 if (!$PAGE->user_is_editing()) { 225 return array(); 226 } 227 228 $coursecontext = context_course::instance($course->id); 229 230 if ($onsectionpage) { 231 $baseurl = course_get_url($course, $section->section); 232 } else { 233 $baseurl = course_get_url($course); 234 } 235 $baseurl->param('sesskey', sesskey()); 236 237 $controls = array(); 238 239 $url = clone($baseurl); 240 if (has_capability('moodle/course:sectionvisibility', $coursecontext)) { 241 if ($section->visible) { // Show the hide/show eye. 242 $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format); 243 $url->param('hide', $section->section); 244 $controls[] = html_writer::link($url, 245 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'), 246 'class' => 'icon hide', 'alt' => $strhidefromothers)), 247 array('title' => $strhidefromothers, 'class' => 'editing_showhide')); 248 } else { 249 $strshowfromothers = get_string('showfromothers', 'format_'.$course->format); 250 $url->param('show', $section->section); 251 $controls[] = html_writer::link($url, 252 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'), 253 'class' => 'icon hide', 'alt' => $strshowfromothers)), 254 array('title' => $strshowfromothers, 'class' => 'editing_showhide')); 255 } 256 } 257 258 if (!$onsectionpage && has_capability('moodle/course:movesections', $coursecontext)) { 259 $url = clone($baseurl); 260 if ($section->section > 1) { // Add a arrow to move section up. 261 $url->param('section', $section->section); 262 $url->param('move', -1); 263 $strmoveup = get_string('moveup'); 264 265 $controls[] = html_writer::link($url, 266 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/up'), 267 'class' => 'icon up', 'alt' => $strmoveup)), 268 array('title' => $strmoveup, 'class' => 'moveup')); 269 } 270 271 $url = clone($baseurl); 272 if ($section->section < $course->numsections) { // Add a arrow to move section down. 273 $url->param('section', $section->section); 274 $url->param('move', 1); 275 $strmovedown = get_string('movedown'); 276 277 $controls[] = html_writer::link($url, 278 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/down'), 279 'class' => 'icon down', 'alt' => $strmovedown)), 280 array('title' => $strmovedown, 'class' => 'movedown')); 281 } 282 } 283 284 return $controls; 285 } 286 287 /** 288 * Generate a summary of a section for display on the 'coruse index page' 289 * 290 * @param stdClass $section The course_section entry from DB 291 * @param stdClass $course The course entry from DB 292 * @param array $mods (argument not used) 293 * @return string HTML to output. 294 */ 295 protected function section_summary($section, $course, $mods) { 296 $classattr = 'section main section-summary clearfix'; 297 $linkclasses = ''; 298 299 // If section is hidden then display grey section link 300 if (!$section->visible) { 301 $classattr .= ' hidden'; 302 $linkclasses .= ' dimmed_text'; 303 } else if (course_get_format($course)->is_section_current($section)) { 304 $classattr .= ' current'; 305 } 306 307 $title = get_section_name($course, $section); 308 $o = ''; 309 $o .= html_writer::start_tag('li', array('id' => 'section-'.$section->section, 310 'class' => $classattr, 'role'=>'region', 'aria-label'=> $title)); 311 312 $o .= html_writer::tag('div', '', array('class' => 'left side')); 313 $o .= html_writer::tag('div', '', array('class' => 'right side')); 314 $o .= html_writer::start_tag('div', array('class' => 'content')); 315 316 if ($section->uservisible) { 317 $title = html_writer::tag('a', $title, 318 array('href' => course_get_url($course, $section->section), 'class' => $linkclasses)); 319 } 320 $o .= $this->output->heading($title, 3, 'section-title'); 321 322 $o.= html_writer::start_tag('div', array('class' => 'summarytext')); 323 $o.= $this->format_summary_text($section); 324 $o.= html_writer::end_tag('div'); 325 $o.= $this->section_activity_summary($section, $course, null); 326 327 $context = context_course::instance($course->id); 328 $o .= $this->section_availability_message($section, 329 has_capability('moodle/course:viewhiddensections', $context)); 330 331 $o .= html_writer::end_tag('div'); 332 $o .= html_writer::end_tag('li'); 333 334 return $o; 335 } 336 337 /** 338 * Generate a summary of the activites in a section 339 * 340 * @param stdClass $section The course_section entry from DB 341 * @param stdClass $course the course record from DB 342 * @param array $mods (argument not used) 343 * @return string HTML to output. 344 */ 345 protected function section_activity_summary($section, $course, $mods) { 346 $modinfo = get_fast_modinfo($course); 347 if (empty($modinfo->sections[$section->section])) { 348 return ''; 349 } 350 351 // Generate array with count of activities in this section: 352 $sectionmods = array(); 353 $total = 0; 354 $complete = 0; 355 $cancomplete = isloggedin() && !isguestuser(); 356 $completioninfo = new completion_info($course); 357 foreach ($modinfo->sections[$section->section] as $cmid) { 358 $thismod = $modinfo->cms[$cmid]; 359 360 if ($thismod->modname == 'label') { 361 // Labels are special (not interesting for students)! 362 continue; 363 } 364 365 if ($thismod->uservisible) { 366 if (isset($sectionmods[$thismod->modname])) { 367 $sectionmods[$thismod->modname]['name'] = $thismod->modplural; 368 $sectionmods[$thismod->modname]['count']++; 369 } else { 370 $sectionmods[$thismod->modname]['name'] = $thismod->modfullname; 371 $sectionmods[$thismod->modname]['count'] = 1; 372 } 373 if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) { 374 $total++; 375 $completiondata = $completioninfo->get_data($thismod, true); 376 if ($completiondata->completionstate == COMPLETION_COMPLETE || 377 $completiondata->completionstate == COMPLETION_COMPLETE_PASS) { 378 $complete++; 379 } 380 } 381 } 382 } 383 384 if (empty($sectionmods)) { 385 // No sections 386 return ''; 387 } 388 389 // Output section activities summary: 390 $o = ''; 391 $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right')); 392 foreach ($sectionmods as $mod) { 393 $o.= html_writer::start_tag('span', array('class' => 'activity-count')); 394 $o.= $mod['name'].': '.$mod['count']; 395 $o.= html_writer::end_tag('span'); 396 } 397 $o.= html_writer::end_tag('div'); 398 399 // Output section completion data 400 if ($total > 0) { 401 $a = new stdClass; 402 $a->complete = $complete; 403 $a->total = $total; 404 405 $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right')); 406 $o.= html_writer::tag('span', get_string('progresstotal', 'completion', $a), array('class' => 'activity-count')); 407 $o.= html_writer::end_tag('div'); 408 } 409 410 return $o; 411 } 412 413 /** 414 * If section is not visible, display the message about that ('Not available 415 * until...', that sort of thing). Otherwise, returns blank. 416 * 417 * For users with the ability to view hidden sections, it shows the 418 * information even though you can view the section and also may include 419 * slightly fuller information (so that teachers can tell when sections 420 * are going to be unavailable etc). This logic is the same as for 421 * activities. 422 * 423 * @param stdClass $section The course_section entry from DB 424 * @param bool $canviewhidden True if user can view hidden sections 425 * @return string HTML to output 426 */ 427 protected function section_availability_message($section, $canviewhidden) { 428 global $CFG; 429 $o = ''; 430 if (!$section->uservisible) { 431 // Note: We only get to this function if availableinfo is non-empty, 432 // so there is definitely something to print. 433 $formattedinfo = \core_availability\info::format_info( 434 $section->availableinfo, $section->course); 435 $o .= html_writer::div($formattedinfo, 'availabilityinfo'); 436 } else if ($canviewhidden && !empty($CFG->enableavailability) && $section->visible) { 437 $ci = new \core_availability\info_section($section); 438 $fullinfo = $ci->get_full_information(); 439 if ($fullinfo) { 440 $formattedinfo = \core_availability\info::format_info( 441 $fullinfo, $section->course); 442 $o .= html_writer::div($formattedinfo, 'availabilityinfo'); 443 } 444 } 445 return $o; 446 } 447 448 /** 449 * Show if something is on on the course clipboard (moving around) 450 * 451 * @param stdClass $course The course entry from DB 452 * @param int $sectionno The section number in the coruse which is being dsiplayed 453 * @return string HTML to output. 454 */ 455 protected function course_activity_clipboard($course, $sectionno = null) { 456 global $USER; 457 458 $o = ''; 459 // If currently moving a file then show the current clipboard. 460 if (ismoving($course->id)) { 461 $url = new moodle_url('/course/mod.php', 462 array('sesskey' => sesskey(), 463 'cancelcopy' => true, 464 'sr' => $sectionno, 465 ) 466 ); 467 468 $o.= html_writer::start_tag('div', array('class' => 'clipboard')); 469 $o.= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname)); 470 $o.= ' ('.html_writer::link($url, get_string('cancel')).')'; 471 $o.= html_writer::end_tag('div'); 472 } 473 474 return $o; 475 } 476 477 /** 478 * Generate next/previous section links for naviation 479 * 480 * @param stdClass $course The course entry from DB 481 * @param array $sections The course_sections entries from the DB 482 * @param int $sectionno The section number in the coruse which is being dsiplayed 483 * @return array associative array with previous and next section link 484 */ 485 protected function get_nav_links($course, $sections, $sectionno) { 486 // FIXME: This is really evil and should by using the navigation API. 487 $course = course_get_format($course)->get_course(); 488 $canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($course->id)) 489 or !$course->hiddensections; 490 491 $links = array('previous' => '', 'next' => ''); 492 $back = $sectionno - 1; 493 while ($back > 0 and empty($links['previous'])) { 494 if ($canviewhidden || $sections[$back]->uservisible) { 495 $params = array(); 496 if (!$sections[$back]->visible) { 497 $params = array('class' => 'dimmed_text'); 498 } 499 $previouslink = html_writer::tag('span', $this->output->larrow(), array('class' => 'larrow')); 500 $previouslink .= get_section_name($course, $sections[$back]); 501 $links['previous'] = html_writer::link(course_get_url($course, $back), $previouslink, $params); 502 } 503 $back--; 504 } 505 506 $forward = $sectionno + 1; 507 while ($forward <= $course->numsections and empty($links['next'])) { 508 if ($canviewhidden || $sections[$forward]->uservisible) { 509 $params = array(); 510 if (!$sections[$forward]->visible) { 511 $params = array('class' => 'dimmed_text'); 512 } 513 $nextlink = get_section_name($course, $sections[$forward]); 514 $nextlink .= html_writer::tag('span', $this->output->rarrow(), array('class' => 'rarrow')); 515 $links['next'] = html_writer::link(course_get_url($course, $forward), $nextlink, $params); 516 } 517 $forward++; 518 } 519 520 return $links; 521 } 522 523 /** 524 * Generate the header html of a stealth section 525 * 526 * @param int $sectionno The section number in the coruse which is being dsiplayed 527 * @return string HTML to output. 528 */ 529 protected function stealth_section_header($sectionno) { 530 $o = ''; 531 $o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix orphaned hidden')); 532 $o.= html_writer::tag('div', '', array('class' => 'left side')); 533 $o.= html_writer::tag('div', '', array('class' => 'right side')); 534 $o.= html_writer::start_tag('div', array('class' => 'content')); 535 $o.= $this->output->heading(get_string('orphanedactivitiesinsectionno', '', $sectionno), 3, 'sectionname'); 536 return $o; 537 } 538 539 /** 540 * Generate footer html of a stealth section 541 * 542 * @return string HTML to output. 543 */ 544 protected function stealth_section_footer() { 545 $o = html_writer::end_tag('div'); 546 $o.= html_writer::end_tag('li'); 547 return $o; 548 } 549 550 /** 551 * Generate the html for a hidden section 552 * 553 * @param int $sectionno The section number in the coruse which is being dsiplayed 554 * @param int|stdClass $courseorid The course to get the section name for (object or just course id) 555 * @return string HTML to output. 556 */ 557 protected function section_hidden($sectionno, $courseorid = null) { 558 if ($courseorid) { 559 $sectionname = get_section_name($courseorid, $sectionno); 560 $strnotavailable = get_string('notavailablecourse', '', $sectionname); 561 } else { 562 $strnotavailable = get_string('notavailable'); 563 } 564 565 $o = ''; 566 $o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix hidden')); 567 $o.= html_writer::tag('div', '', array('class' => 'left side')); 568 $o.= html_writer::tag('div', '', array('class' => 'right side')); 569 $o.= html_writer::start_tag('div', array('class' => 'content')); 570 $o.= html_writer::tag('div', $strnotavailable); 571 $o.= html_writer::end_tag('div'); 572 $o.= html_writer::end_tag('li'); 573 return $o; 574 } 575 576 /** 577 * Generate the html for the 'Jump to' menu on a single section page. 578 * 579 * @param stdClass $course The course entry from DB 580 * @param array $sections The course_sections entries from the DB 581 * @param $displaysection the current displayed section number. 582 * 583 * @return string HTML to output. 584 */ 585 protected function section_nav_selection($course, $sections, $displaysection) { 586 global $CFG; 587 $o = ''; 588 $sectionmenu = array(); 589 $sectionmenu[course_get_url($course)->out(false)] = get_string('maincoursepage'); 590 $modinfo = get_fast_modinfo($course); 591 $section = 1; 592 while ($section <= $course->numsections) { 593 $thissection = $modinfo->get_section_info($section); 594 $showsection = $thissection->uservisible or !$course->hiddensections; 595 if (($showsection) && ($section != $displaysection) && ($url = course_get_url($course, $section))) { 596 $sectionmenu[$url->out(false)] = get_section_name($course, $section); 597 } 598 $section++; 599 } 600 601 $select = new url_select($sectionmenu, '', array('' => get_string('jumpto'))); 602 $select->class = 'jumpmenu'; 603 $select->formid = 'sectionmenu'; 604 $o .= $this->output->render($select); 605 606 return $o; 607 } 608 609 /** 610 * Output the html for a single section page . 611 * 612 * @param stdClass $course The course entry from DB 613 * @param array $sections (argument not used) 614 * @param array $mods (argument not used) 615 * @param array $modnames (argument not used) 616 * @param array $modnamesused (argument not used) 617 * @param int $displaysection The section number in the course which is being displayed 618 */ 619 public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) { 620 global $PAGE; 621 622 $modinfo = get_fast_modinfo($course); 623 $course = course_get_format($course)->get_course(); 624 625 // Can we view the section in question? 626 if (!($sectioninfo = $modinfo->get_section_info($displaysection))) { 627 // This section doesn't exist 628 print_error('unknowncoursesection', 'error', null, $course->fullname); 629 return; 630 } 631 632 if (!$sectioninfo->uservisible) { 633 if (!$course->hiddensections) { 634 echo $this->start_section_list(); 635 echo $this->section_hidden($displaysection, $course->id); 636 echo $this->end_section_list(); 637 } 638 // Can't view this section. 639 return; 640 } 641 642 // Copy activity clipboard.. 643 echo $this->course_activity_clipboard($course, $displaysection); 644 $thissection = $modinfo->get_section_info(0); 645 if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) { 646 echo $this->start_section_list(); 647 echo $this->section_header($thissection, $course, true, $displaysection); 648 echo $this->courserenderer->course_section_cm_list($course, $thissection, $displaysection); 649 echo $this->courserenderer->course_section_add_cm_control($course, 0, $displaysection); 650 echo $this->section_footer(); 651 echo $this->end_section_list(); 652 } 653 654 // Start single-section div 655 echo html_writer::start_tag('div', array('class' => 'single-section')); 656 657 // The requested section page. 658 $thissection = $modinfo->get_section_info($displaysection); 659 660 // Title with section navigation links. 661 $sectionnavlinks = $this->get_nav_links($course, $modinfo->get_section_info_all(), $displaysection); 662 $sectiontitle = ''; 663 $sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation navigationtitle')); 664 $sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left')); 665 $sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right')); 666 // Title attributes 667 $classes = 'sectionname'; 668 if (!$thissection->visible) { 669 $classes .= ' dimmed_text'; 670 } 671 $sectiontitle .= $this->output->heading(get_section_name($course, $displaysection), 3, $classes); 672 673 $sectiontitle .= html_writer::end_tag('div'); 674 echo $sectiontitle; 675 676 // Now the list of sections.. 677 echo $this->start_section_list(); 678 679 echo $this->section_header($thissection, $course, true, $displaysection); 680 // Show completion help icon. 681 $completioninfo = new completion_info($course); 682 echo $completioninfo->display_help_icon(); 683 684 echo $this->courserenderer->course_section_cm_list($course, $thissection, $displaysection); 685 echo $this->courserenderer->course_section_add_cm_control($course, $displaysection, $displaysection); 686 echo $this->section_footer(); 687 echo $this->end_section_list(); 688 689 // Display section bottom navigation. 690 $sectionbottomnav = ''; 691 $sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom')); 692 $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left')); 693 $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right')); 694 $sectionbottomnav .= html_writer::tag('div', $this->section_nav_selection($course, $sections, $displaysection), 695 array('class' => 'mdl-align')); 696 $sectionbottomnav .= html_writer::end_tag('div'); 697 echo $sectionbottomnav; 698 699 // Close single-section div. 700 echo html_writer::end_tag('div'); 701 } 702 703 /** 704 * Output the html for a multiple section page 705 * 706 * @param stdClass $course The course entry from DB 707 * @param array $sections (argument not used) 708 * @param array $mods (argument not used) 709 * @param array $modnames (argument not used) 710 * @param array $modnamesused (argument not used) 711 */ 712 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) { 713 global $PAGE; 714 715 $modinfo = get_fast_modinfo($course); 716 $course = course_get_format($course)->get_course(); 717 718 $context = context_course::instance($course->id); 719 // Title with completion help icon. 720 $completioninfo = new completion_info($course); 721 echo $completioninfo->display_help_icon(); 722 echo $this->output->heading($this->page_title(), 2, 'accesshide'); 723 724 // Copy activity clipboard.. 725 echo $this->course_activity_clipboard($course, 0); 726 727 // Now the list of sections.. 728 echo $this->start_section_list(); 729 730 foreach ($modinfo->get_section_info_all() as $section => $thissection) { 731 if ($section == 0) { 732 // 0-section is displayed a little different then the others 733 if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) { 734 echo $this->section_header($thissection, $course, false, 0); 735 echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); 736 echo $this->courserenderer->course_section_add_cm_control($course, 0, 0); 737 echo $this->section_footer(); 738 } 739 continue; 740 } 741 if ($section > $course->numsections) { 742 // activities inside this section are 'orphaned', this section will be printed as 'stealth' below 743 continue; 744 } 745 // Show the section if the user is permitted to access it, OR if it's not available 746 // but there is some available info text which explains the reason & should display. 747 $showsection = $thissection->uservisible || 748 ($thissection->visible && !$thissection->available && 749 !empty($thissection->availableinfo)); 750 if (!$showsection) { 751 // If the hiddensections option is set to 'show hidden sections in collapsed 752 // form', then display the hidden section message - UNLESS the section is 753 // hidden by the availability system, which is set to hide the reason. 754 if (!$course->hiddensections && $thissection->available) { 755 echo $this->section_hidden($section, $course->id); 756 } 757 758 continue; 759 } 760 761 if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) { 762 // Display section summary only. 763 echo $this->section_summary($thissection, $course, null); 764 } else { 765 echo $this->section_header($thissection, $course, false, 0); 766 if ($thissection->uservisible) { 767 echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); 768 echo $this->courserenderer->course_section_add_cm_control($course, $section, 0); 769 } 770 echo $this->section_footer(); 771 } 772 } 773 774 if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) { 775 // Print stealth sections if present. 776 foreach ($modinfo->get_section_info_all() as $section => $thissection) { 777 if ($section <= $course->numsections or empty($modinfo->sections[$section])) { 778 // this is not stealth section or it is empty 779 continue; 780 } 781 echo $this->stealth_section_header($section); 782 echo $this->courserenderer->course_section_cm_list($course, $thissection, 0); 783 echo $this->stealth_section_footer(); 784 } 785 786 echo $this->end_section_list(); 787 788 echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right')); 789 790 // Increase number of sections. 791 $straddsection = get_string('increasesections', 'moodle'); 792 $url = new moodle_url('/course/changenumsections.php', 793 array('courseid' => $course->id, 794 'increase' => true, 795 'sesskey' => sesskey())); 796 $icon = $this->output->pix_icon('t/switch_plus', $straddsection); 797 echo html_writer::link($url, $icon.get_accesshide($straddsection), array('class' => 'increase-sections')); 798 799 if ($course->numsections > 0) { 800 // Reduce number of sections sections. 801 $strremovesection = get_string('reducesections', 'moodle'); 802 $url = new moodle_url('/course/changenumsections.php', 803 array('courseid' => $course->id, 804 'increase' => false, 805 'sesskey' => sesskey())); 806 $icon = $this->output->pix_icon('t/switch_minus', $strremovesection); 807 echo html_writer::link($url, $icon.get_accesshide($strremovesection), array('class' => 'reduce-sections')); 808 } 809 810 echo html_writer::end_tag('div'); 811 } else { 812 echo $this->end_section_list(); 813 } 814 815 } 816 817 /** 818 * Generate html for a section summary text 819 * 820 * @param stdClass $section The course_section entry from DB 821 * @return string HTML to output. 822 */ 823 protected function format_summary_text($section) { 824 $context = context_course::instance($section->course); 825 $summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', 826 $context->id, 'course', 'section', $section->id); 827 828 $options = new stdClass(); 829 $options->noclean = true; 830 $options->overflowdiv = true; 831 return format_text($summarytext, $section->summaryformat, $options); 832 } 833 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |