mirror of
https://github.com/moodle/moodle.git
synced 2025-07-23 15:22:05 +02:00
MDL-35339 Use get_fast_modinfo() in course sections display functions
- Avoid using field course_sections.sequence for retrieving the modules list, use functionality from get_fast_modinfo() instead; - In the following functions/methods mark arguments $mod, $modnames, $modnamesused and $sections as not used because they can be taken any time from get_fast_modinfo(): - function print_section() - protected function format_section_renderer_base::section_summary() - private function format_section_renderer_base::section_activity_summary - public function format_section_renderer_base::print_single_section_page - public function format_section_renderer_base::print_multiple_section_page
This commit is contained in:
@@ -271,7 +271,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
*
|
*
|
||||||
* @param stdClass $section The course_section entry from DB
|
* @param stdClass $section The course_section entry from DB
|
||||||
* @param stdClass $course The course entry from DB
|
* @param stdClass $course The course entry from DB
|
||||||
* @param array $mods course modules indexed by id (from get_fast_modinfo()->get_cms())
|
* @param array $mods (argument not used)
|
||||||
* @return string HTML to output.
|
* @return string HTML to output.
|
||||||
*/
|
*/
|
||||||
protected function section_summary($section, $course, $mods) {
|
protected function section_summary($section, $course, $mods) {
|
||||||
@@ -303,7 +303,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
|
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
|
||||||
$o.= $this->format_summary_text($section);
|
$o.= $this->format_summary_text($section);
|
||||||
$o.= html_writer::end_tag('div');
|
$o.= html_writer::end_tag('div');
|
||||||
$o.= $this->section_activity_summary($section, $course, $mods);
|
$o.= $this->section_activity_summary($section, $course, null);
|
||||||
|
|
||||||
$o.= $this->section_availability_message($section);
|
$o.= $this->section_availability_message($section);
|
||||||
|
|
||||||
@@ -318,11 +318,12 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
*
|
*
|
||||||
* @param stdClass $section The course_section entry from DB
|
* @param stdClass $section The course_section entry from DB
|
||||||
* @param stdClass $course the course record from DB
|
* @param stdClass $course the course record from DB
|
||||||
* @param array $mods course modules indexed by id (from get_fast_modinfo()->get_cms())
|
* @param array $mods (argument not used)
|
||||||
* @return string HTML to output.
|
* @return string HTML to output.
|
||||||
*/
|
*/
|
||||||
private function section_activity_summary($section, $course, $mods) {
|
private function section_activity_summary($section, $course, $mods) {
|
||||||
if (empty($section->sequence)) {
|
$modinfo = get_fast_modinfo($course);
|
||||||
|
if (empty($modinfo->sections[$section->section])) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,9 +333,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
$complete = 0;
|
$complete = 0;
|
||||||
$cancomplete = isloggedin() && !isguestuser();
|
$cancomplete = isloggedin() && !isguestuser();
|
||||||
$completioninfo = new completion_info($course);
|
$completioninfo = new completion_info($course);
|
||||||
$modsequence = explode(',', $section->sequence);
|
foreach ($modinfo->sections[$section->section] as $cmid) {
|
||||||
foreach ($modsequence as $cmid) {
|
$thismod = $modinfo->cms[$cmid];
|
||||||
$thismod = $mods[$cmid];
|
|
||||||
|
|
||||||
if ($thismod->modname == 'label') {
|
if ($thismod->modname == 'label') {
|
||||||
// Labels are special (not interesting for students)!
|
// Labels are special (not interesting for students)!
|
||||||
@@ -343,9 +343,10 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
|
|
||||||
if ($thismod->uservisible) {
|
if ($thismod->uservisible) {
|
||||||
if (isset($sectionmods[$thismod->modname])) {
|
if (isset($sectionmods[$thismod->modname])) {
|
||||||
|
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
|
||||||
$sectionmods[$thismod->modname]['count']++;
|
$sectionmods[$thismod->modname]['count']++;
|
||||||
} else {
|
} else {
|
||||||
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
|
$sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
|
||||||
$sectionmods[$thismod->modname]['count'] = 1;
|
$sectionmods[$thismod->modname]['count'] = 1;
|
||||||
}
|
}
|
||||||
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
|
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
|
||||||
@@ -531,26 +532,25 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
* Output the html for a single section page .
|
* Output the html for a single section page .
|
||||||
*
|
*
|
||||||
* @param stdClass $course The course entry from DB
|
* @param stdClass $course The course entry from DB
|
||||||
* @param array $sections The course_sections entries from the DB
|
* @param array $sections (argument not used)
|
||||||
* @param array $mods used for print_section()
|
* @param array $mods (argument not used)
|
||||||
* @param array $modnames used for print_section()
|
* @param array $modnames (argument not used)
|
||||||
* @param array $modnamesused used for print_section()
|
* @param array $modnamesused (argument not used)
|
||||||
* @param int $displaysection The section number in the course which is being displayed
|
* @param int $displaysection The section number in the course which is being displayed
|
||||||
*/
|
*/
|
||||||
public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) {
|
public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
// Can we view the section in question?
|
$modinfo = get_fast_modinfo($course);
|
||||||
$context = context_course::instance($course->id);
|
|
||||||
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
|
|
||||||
|
|
||||||
if (!isset($sections[$displaysection])) {
|
// Can we view the section in question?
|
||||||
|
if (!($sectioninfo = $modinfo->get_section_info($displaysection))) {
|
||||||
// This section doesn't exist
|
// This section doesn't exist
|
||||||
print_error('unknowncoursesection', 'error', null, $course->fullname);
|
print_error('unknowncoursesection', 'error', null, $course->fullname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sections[$displaysection]->visible && !$canviewhidden) {
|
if (!$sectioninfo->uservisible) {
|
||||||
if (!$course->hiddensections) {
|
if (!$course->hiddensections) {
|
||||||
echo $this->start_section_list();
|
echo $this->start_section_list();
|
||||||
echo $this->section_hidden($displaysection);
|
echo $this->section_hidden($displaysection);
|
||||||
@@ -562,15 +562,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
|
|
||||||
// Copy activity clipboard..
|
// Copy activity clipboard..
|
||||||
echo $this->course_activity_clipboard($course, $displaysection);
|
echo $this->course_activity_clipboard($course, $displaysection);
|
||||||
|
$thissection = $modinfo->get_section_info(0);
|
||||||
// General section if non-empty.
|
if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
|
||||||
$thissection = $sections[0];
|
|
||||||
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
|
|
||||||
echo $this->start_section_list();
|
echo $this->start_section_list();
|
||||||
echo $this->section_header($thissection, $course, true, $displaysection);
|
echo $this->section_header($thissection, $course, true, $displaysection);
|
||||||
print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, $displaysection);
|
print_section($course, $thissection, null, null, true, "100%", false, $displaysection);
|
||||||
if ($PAGE->user_is_editing()) {
|
if ($PAGE->user_is_editing()) {
|
||||||
print_section_add_menus($course, 0, $modnames, false, false, $displaysection);
|
print_section_add_menus($course, 0, null, false, false, $displaysection);
|
||||||
}
|
}
|
||||||
echo $this->section_footer();
|
echo $this->section_footer();
|
||||||
echo $this->end_section_list();
|
echo $this->end_section_list();
|
||||||
@@ -579,34 +577,35 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
// Start single-section div
|
// Start single-section div
|
||||||
echo html_writer::start_tag('div', array('class' => 'single-section'));
|
echo html_writer::start_tag('div', array('class' => 'single-section'));
|
||||||
|
|
||||||
|
// The requested section page.
|
||||||
|
$thissection = $modinfo->get_section_info($displaysection);
|
||||||
|
|
||||||
// Title with section navigation links.
|
// Title with section navigation links.
|
||||||
$sectionnavlinks = $this->get_nav_links($course, $sections, $displaysection);
|
$sectionnavlinks = $this->get_nav_links($course, $modinfo->get_section_info_all(), $displaysection);
|
||||||
$sectiontitle = '';
|
$sectiontitle = '';
|
||||||
$sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation header headingblock'));
|
$sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation header headingblock'));
|
||||||
$sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
|
$sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
|
||||||
$sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
|
$sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
|
||||||
// Title attributes
|
// Title attributes
|
||||||
$titleattr = 'mdl-align title';
|
$titleattr = 'mdl-align title';
|
||||||
if (!$sections[$displaysection]->visible) {
|
if (!$thissection->visible) {
|
||||||
$titleattr .= ' dimmed_text';
|
$titleattr .= ' dimmed_text';
|
||||||
}
|
}
|
||||||
$sectiontitle .= html_writer::tag('div', get_section_name($course, $sections[$displaysection]), array('class' => $titleattr));
|
$sectiontitle .= html_writer::tag('div', get_section_name($course, $displaysection), array('class' => $titleattr));
|
||||||
$sectiontitle .= html_writer::end_tag('div');
|
$sectiontitle .= html_writer::end_tag('div');
|
||||||
echo $sectiontitle;
|
echo $sectiontitle;
|
||||||
|
|
||||||
// Now the list of sections..
|
// Now the list of sections..
|
||||||
echo $this->start_section_list();
|
echo $this->start_section_list();
|
||||||
|
|
||||||
// The requested section page.
|
|
||||||
$thissection = $sections[$displaysection];
|
|
||||||
echo $this->section_header($thissection, $course, true, $displaysection);
|
echo $this->section_header($thissection, $course, true, $displaysection);
|
||||||
// Show completion help icon.
|
// Show completion help icon.
|
||||||
$completioninfo = new completion_info($course);
|
$completioninfo = new completion_info($course);
|
||||||
echo $completioninfo->display_help_icon();
|
echo $completioninfo->display_help_icon();
|
||||||
|
|
||||||
print_section($course, $thissection, $mods, $modnamesused, true, '100%', false, $displaysection);
|
print_section($course, $thissection, null, null, true, '100%', false, $displaysection);
|
||||||
if ($PAGE->user_is_editing()) {
|
if ($PAGE->user_is_editing()) {
|
||||||
print_section_add_menus($course, $displaysection, $modnames, false, false, $displaysection);
|
print_section_add_menus($course, $displaysection, null, false, false, $displaysection);
|
||||||
}
|
}
|
||||||
echo $this->section_footer();
|
echo $this->section_footer();
|
||||||
echo $this->end_section_list();
|
echo $this->end_section_list();
|
||||||
@@ -629,14 +628,16 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
* Output the html for a multiple section page
|
* Output the html for a multiple section page
|
||||||
*
|
*
|
||||||
* @param stdClass $course The course entry from DB
|
* @param stdClass $course The course entry from DB
|
||||||
* @param array $sections The course_sections entries from the DB
|
* @param array $sections (argument not used)
|
||||||
* @param array $mods used for print_section()
|
* @param array $mods (argument not used)
|
||||||
* @param array $modnames used for print_section()
|
* @param array $modnames (argument not used)
|
||||||
* @param array $modnamesused used for print_section()
|
* @param array $modnamesused (argument not used)
|
||||||
*/
|
*/
|
||||||
public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) {
|
public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
|
$modinfo = get_fast_modinfo($course);
|
||||||
|
|
||||||
$context = context_course::instance($course->id);
|
$context = context_course::instance($course->id);
|
||||||
// Title with completion help icon.
|
// Title with completion help icon.
|
||||||
$completioninfo = new completion_info($course);
|
$completioninfo = new completion_info($course);
|
||||||
@@ -649,32 +650,22 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
// Now the list of sections..
|
// Now the list of sections..
|
||||||
echo $this->start_section_list();
|
echo $this->start_section_list();
|
||||||
|
|
||||||
// General section if non-empty.
|
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
|
||||||
$thissection = $sections[0];
|
if ($section == 0) {
|
||||||
unset($sections[0]);
|
// 0-section is displayed a little different then the others
|
||||||
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
|
if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
|
||||||
echo $this->section_header($thissection, $course, false, 0);
|
echo $this->section_header($thissection, $course, false, 0);
|
||||||
print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, 0);
|
print_section($course, $thissection, null, null, true, "100%", false, 0);
|
||||||
if ($PAGE->user_is_editing()) {
|
if ($PAGE->user_is_editing()) {
|
||||||
print_section_add_menus($course, 0, $modnames, false, false, 0);
|
print_section_add_menus($course, 0, null, false, false, 0);
|
||||||
|
}
|
||||||
|
echo $this->section_footer();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
echo $this->section_footer();
|
if ($section > $course->numsections) {
|
||||||
}
|
// activities inside this section are 'orphaned', this section will be printed as 'stealth' below
|
||||||
|
continue;
|
||||||
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
|
|
||||||
for ($section = 1; $section <= $course->numsections; $section++) {
|
|
||||||
if (!empty($sections[$section])) {
|
|
||||||
$thissection = $sections[$section];
|
|
||||||
} else {
|
|
||||||
// This will create a course section if it doesn't exist..
|
|
||||||
$thissection = get_course_section($section, $course->id);
|
|
||||||
|
|
||||||
// The returned section is only a bare database object rather than
|
|
||||||
// a section_info object - we will need at least the uservisible
|
|
||||||
// field in it.
|
|
||||||
$thissection->uservisible = true;
|
|
||||||
$thissection->availableinfo = null;
|
|
||||||
$thissection->showavailability = 0;
|
|
||||||
}
|
}
|
||||||
// Show the section if the user is permitted to access it, OR if it's not available
|
// Show the section if the user is permitted to access it, OR if it's not available
|
||||||
// but showavailability is turned on
|
// but showavailability is turned on
|
||||||
@@ -687,36 +678,33 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
|||||||
echo $this->section_hidden($section);
|
echo $this->section_hidden($section);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($sections[$section]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
|
if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
|
||||||
// Display section summary only.
|
// Display section summary only.
|
||||||
echo $this->section_summary($thissection, $course, $mods);
|
echo $this->section_summary($thissection, $course, null);
|
||||||
} else {
|
} else {
|
||||||
echo $this->section_header($thissection, $course, false, 0);
|
echo $this->section_header($thissection, $course, false, 0);
|
||||||
if ($thissection->uservisible) {
|
if ($thissection->uservisible) {
|
||||||
print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, 0);
|
print_section($course, $thissection, null, null, true, "100%", false, 0);
|
||||||
if ($PAGE->user_is_editing()) {
|
if ($PAGE->user_is_editing()) {
|
||||||
print_section_add_menus($course, $section, $modnames, false, false, 0);
|
print_section_add_menus($course, $section, null, false, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo $this->section_footer();
|
echo $this->section_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($sections[$section]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
|
if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
|
||||||
// Print stealth sections if present.
|
// Print stealth sections if present.
|
||||||
$modinfo = get_fast_modinfo($course);
|
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
|
||||||
foreach ($sections as $section => $thissection) {
|
if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
|
||||||
if (empty($modinfo->sections[$section])) {
|
// this is not stealth section or it is empty
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo $this->stealth_section_header($section);
|
echo $this->stealth_section_header($section);
|
||||||
print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, $displaysection);
|
print_section($course, $thissection, null, null, true, "100%", false, 0);
|
||||||
echo $this->stealth_section_footer();
|
echo $this->stealth_section_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,12 +44,20 @@ if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context)
|
|||||||
course_set_marker($course->id, $marker);
|
course_set_marker($course->id, $marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure all sections are created
|
||||||
|
$modinfo = get_fast_modinfo($course);
|
||||||
|
for ($sectionnum = 0; $sectionnum <= $course->numsections; $sectionnum++) {
|
||||||
|
if (!$modinfo->get_section_info($sectionnum)) {
|
||||||
|
get_course_section($sectionnum, $course->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$renderer = $PAGE->get_renderer('format_topics');
|
$renderer = $PAGE->get_renderer('format_topics');
|
||||||
|
|
||||||
if (!empty($displaysection)) {
|
if (!empty($displaysection)) {
|
||||||
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
|
$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
|
||||||
} else {
|
} else {
|
||||||
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
|
$renderer->print_multiple_section_page($course, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include course format js module
|
// Include course format js module
|
||||||
|
@@ -37,12 +37,20 @@ if ($week = optional_param('week', 0, PARAM_INT)) {
|
|||||||
}
|
}
|
||||||
// End backwards-compatible aliasing..
|
// End backwards-compatible aliasing..
|
||||||
|
|
||||||
|
// make sure all sections are created
|
||||||
|
$modinfo = get_fast_modinfo($course);
|
||||||
|
for ($sectionnum = 0; $sectionnum <= $course->numsections; $sectionnum++) {
|
||||||
|
if (!$modinfo->get_section_info($sectionnum)) {
|
||||||
|
get_course_section($sectionnum, $course->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$renderer = $PAGE->get_renderer('format_weeks');
|
$renderer = $PAGE->get_renderer('format_weeks');
|
||||||
|
|
||||||
if (!empty($displaysection)) {
|
if (!empty($displaysection)) {
|
||||||
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
|
$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
|
||||||
} else {
|
} else {
|
||||||
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
|
$renderer->print_multiple_section_page($course, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$PAGE->requires->js('/course/format/weeks/format.js');
|
$PAGE->requires->js('/course/format/weeks/format.js');
|
||||||
|
@@ -1332,9 +1332,9 @@ function get_print_section_cm_text(cm_info $cm, $course) {
|
|||||||
* Prints a section full of activity modules
|
* Prints a section full of activity modules
|
||||||
*
|
*
|
||||||
* @param stdClass $course The course
|
* @param stdClass $course The course
|
||||||
* @param stdClass $section The section
|
* @param stdClass|section_info $section The section object containing properties id and section
|
||||||
* @param array $mods The modules in the section
|
* @param array $mods (argument not used)
|
||||||
* @param array $modnamesused An array containing the list of modules and their names
|
* @param array $modnamesused (argument not used)
|
||||||
* @param bool $absolute All links are absolute
|
* @param bool $absolute All links are absolute
|
||||||
* @param string $width Width of the container
|
* @param string $width Width of the container
|
||||||
* @param bool $hidecompletion Hide completion status
|
* @param bool $hidecompletion Hide completion status
|
||||||
@@ -1353,7 +1353,6 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
|||||||
static $strmovehere;
|
static $strmovehere;
|
||||||
static $strmovefull;
|
static $strmovefull;
|
||||||
static $strunreadpostsone;
|
static $strunreadpostsone;
|
||||||
static $modulenames;
|
|
||||||
|
|
||||||
if (!isset($initialised)) {
|
if (!isset($initialised)) {
|
||||||
$groupbuttons = ($course->groupmode or (!$course->groupmodeforce));
|
$groupbuttons = ($course->groupmode or (!$course->groupmodeforce));
|
||||||
@@ -1364,7 +1363,6 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
|||||||
$strmovehere = get_string("movehere");
|
$strmovehere = get_string("movehere");
|
||||||
$strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
|
$strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
|
||||||
}
|
}
|
||||||
$modulenames = array();
|
|
||||||
$initialised = true;
|
$initialised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1372,62 +1370,37 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
|||||||
$completioninfo = new completion_info($course);
|
$completioninfo = new completion_info($course);
|
||||||
|
|
||||||
//Accessibility: replace table with list <ul>, but don't output empty list.
|
//Accessibility: replace table with list <ul>, but don't output empty list.
|
||||||
if (!empty($section->sequence)) {
|
if (!empty($modinfo->sections[$section->section])) {
|
||||||
|
|
||||||
// Fix bug #5027, don't want style=\"width:$width\".
|
// Fix bug #5027, don't want style=\"width:$width\".
|
||||||
echo "<ul class=\"section img-text\">\n";
|
echo "<ul class=\"section img-text\">\n";
|
||||||
$sectionmods = explode(",", $section->sequence);
|
|
||||||
|
|
||||||
foreach ($sectionmods as $modnumber) {
|
foreach ($modinfo->sections[$section->section] as $modnumber) {
|
||||||
if (empty($mods[$modnumber])) {
|
$mod = $modinfo->cms[$modnumber];
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var cm_info
|
|
||||||
*/
|
|
||||||
$mod = $mods[$modnumber];
|
|
||||||
|
|
||||||
if ($ismoving and $mod->id == $USER->activitycopy) {
|
if ($ismoving and $mod->id == $USER->activitycopy) {
|
||||||
// do not display moving mod
|
// do not display moving mod
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($modinfo->cms[$modnumber])) {
|
// We can continue (because it will not be displayed at all)
|
||||||
// We can continue (because it will not be displayed at all)
|
// if:
|
||||||
// if:
|
// 1) The activity is not visible to users
|
||||||
// 1) The activity is not visible to users
|
// and
|
||||||
// and
|
// 2a) The 'showavailability' option is not set (if that is set,
|
||||||
// 2a) The 'showavailability' option is not set (if that is set,
|
// we need to display the activity so we can show
|
||||||
// we need to display the activity so we can show
|
// availability info)
|
||||||
// availability info)
|
// or
|
||||||
// or
|
// 2b) The 'availableinfo' is empty, i.e. the activity was
|
||||||
// 2b) The 'availableinfo' is empty, i.e. the activity was
|
// hidden in a way that leaves no info, such as using the
|
||||||
// hidden in a way that leaves no info, such as using the
|
// eye icon.
|
||||||
// eye icon.
|
if (!$mod->uservisible &&
|
||||||
if (!$modinfo->cms[$modnumber]->uservisible &&
|
(empty($mod->showavailability) ||
|
||||||
(empty($modinfo->cms[$modnumber]->showavailability) ||
|
empty($mod->availableinfo))) {
|
||||||
empty($modinfo->cms[$modnumber]->availableinfo))) {
|
// visibility shortcut
|
||||||
// visibility shortcut
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!file_exists("$CFG->dirroot/mod/$mod->modname/lib.php")) {
|
|
||||||
// module not installed
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!coursemodule_visible_for_user($mod) &&
|
|
||||||
empty($mod->showavailability)) {
|
|
||||||
// full visibility check
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($modulenames[$mod->modname])) {
|
|
||||||
$modulenames[$mod->modname] = get_string('modulename', $mod->modname);
|
|
||||||
}
|
|
||||||
$modulename = $modulenames[$mod->modname];
|
|
||||||
|
|
||||||
// In some cases the activity is visible to user, but it is
|
// In some cases the activity is visible to user, but it is
|
||||||
// dimmed. This is done if viewhiddenactivities is true and if:
|
// dimmed. This is done if viewhiddenactivities is true and if:
|
||||||
// 1. the activity is not visible, or
|
// 1. the activity is not visible, or
|
||||||
@@ -1710,7 +1683,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
|||||||
' alt="'.$strmovehere.'" /></a></li>
|
' alt="'.$strmovehere.'" /></a></li>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
if (!empty($section->sequence) || $ismoving) {
|
if (!empty($modinfo->sections[$section->section]) || $ismoving) {
|
||||||
echo "</ul><!--class='section'-->\n\n";
|
echo "</ul><!--class='section'-->\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user