Permalink
Browse files

Merge branch 'wip-MDL-59411-master' of git://github.com/marinaglancy/…

…moodle
  • Loading branch information...
dmonllao committed Jul 17, 2017
2 parents efc1d2b + 592f3ae commit bf442807f5c6e6effb43e1dfb0106535648689f3
Showing with 33 additions and 8 deletions.
  1. +28 −1 course/renderer.php
  2. +5 −7 lib/moodlelib.php
@@ -945,6 +945,34 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect
return $output;
}
/**
* Message displayed to the user when they try to access unavailable activity following URL
*
* This method is a very simplified version of {@link course_section_cm()} to be part of the error
* notification only. It also does not check if module is visible on course page or not.
*
* The message will be displayed inside notification!
*
* @param cm_info $cm
* @return string
*/
public function course_section_cm_unavilable_error_message(cm_info $cm) {
if ($cm->uservisible) {
return null;
}
if (!$cm->availableinfo) {
return get_string('activityiscurrentlyhidden');
}
$altname = get_accesshide(' ' . $cm->modfullname);
$name = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(),
'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) .
html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
$formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
return html_writer::div($name, 'activityinstance-error') .
html_writer::div($formattedinfo, 'availabilityinfo-error');
}
/**
* Renders HTML to display a list of course modules in a course section
* Also displays "move here" controls in Javascript-disabled mode
@@ -2072,7 +2100,6 @@ public function frontpage_categories_list() {
set_attributes(array('class' => 'frontpage-category-names'));
return $this->coursecat_tree($chelper, coursecat::get(0));
}
}
/**
@@ -2898,13 +2898,11 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
if ($preventredirect) {
throw new require_login_exception('Activity is hidden');
}
if ($course->id != SITEID) {
$url = new moodle_url('/course/view.php', array('id' => $course->id));
} else {
$url = new moodle_url('/');
}
redirect($url, get_string('activityiscurrentlyhidden'), null,
\core\output\notification::NOTIFY_ERROR);
// Get the error message that activity is not available and why (if explanation can be shown to the user).
$PAGE->set_course($course);
$renderer = $PAGE->get_renderer('course');
$message = $renderer->course_section_cm_unavilable_error_message($cm);
redirect(course_get_url($course), $message, null, \core\output\notification::NOTIFY_ERROR);
}
// Set the global $COURSE.

0 comments on commit bf44280

Please sign in to comment.