Skip to content
Permalink
Browse files
Merge branch 'MDL-10965-master' of git://github.com/marinaglancy/moodle
  • Loading branch information
David Monllaó committed Apr 10, 2019
2 parents e9cbc45 + 76f2d89 commit 11bfc07a939aef93300c65dd00384fdedbfb52ca
Showing with 670 additions and 418 deletions.
  1. +0 −4 admin/tool/dataprivacy/classes/output/data_registry_page.php
  2. +1 −2 admin/tool/generator/classes/make_testplan_form.php
  3. +0 −19 admin/tool/generator/classes/testplan_backend.php
  4. +6 −0 admin/tool/generator/upgrade.txt
  5. +5 −16 badges/criteria/award_criteria_courseset.php
  6. +14 −8 blocks/course_list/block_course_list.php
  7. +2 −3 blocks/html/lib.php
  8. +4 −1 calendar/lib.php
  9. +1 −0 calendar/view.php
  10. +201 −85 course/classes/category.php
  11. +0 −8 course/classes/list_element.php
  12. +7 −8 course/classes/management/helper.php
  13. +6 −6 course/classes/management_renderer.php
  14. +1 −3 course/classes/search/course.php
  15. +1 −2 course/classes/search/customfield.php
  16. +19 −47 course/completion_form.php
  17. +17 −4 course/externallib.php
  18. +21 −20 course/index.php
  19. +2 −2 course/info.php
  20. +1 −1 course/lib.php
  21. +5 −4 course/management.php
  22. +60 −47 course/renderer.php
  23. +2 −1 course/search.php
  24. +106 −0 course/tests/behat/course_browsing.feature
  25. +25 −2 course/tests/category_test.php
  26. +1 −2 enrol/externallib.php
  27. +1 −2 enrol/guest/classes/external.php
  28. +5 −0 enrol/index.php
  29. +2 −3 enrol/self/externallib.php
  30. +1 −0 lang/en/error.php
  31. +1 −0 lang/en/moodle.php
  32. +1 −0 lang/en/role.php
  33. +5 −0 lib/accesslib.php
  34. +1 −1 lib/amd/build/form-course-selector.min.js
  35. +3 −1 lib/amd/src/form-course-selector.js
  36. +10 −86 lib/datalib.php
  37. +10 −0 lib/db/access.php
  38. +67 −0 lib/deprecatedlib.php
  39. +3 −4 lib/filebrowser/file_info_context_coursecat.php
  40. +2 −5 lib/filelib.php
  41. +6 −1 lib/form/course.php
  42. +11 −1 lib/moodlelib.php
  43. +27 −17 lib/navigationlib.php
  44. +4 −0 lib/upgrade.txt
  45. +1 −1 search/classes/manager.php
  46. +1 −1 version.php
@@ -234,10 +234,6 @@ public static function get_courses_branch(\context $catcontext) {

$coursecontext = \context_course::instance($course->id);

if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
continue;
}

$coursenode = [
'text' => shorten_text(format_string($course->shortname, true, ['context' => $coursecontext])),
'contextid' => $coursecontext->id,
@@ -47,8 +47,7 @@ public function definition() {
tool_generator_testplan_backend::get_size_choices());
$mform->setDefault('size', tool_generator_testplan_backend::DEFAULT_SIZE);

$mform->addElement('select', 'courseid', get_string('targetcourse', 'tool_generator'),
tool_generator_testplan_backend::get_course_options());
$mform->addElement('course', 'courseid', get_string('targetcourse', 'tool_generator'));

$mform->addElement('advcheckbox', 'updateuserspassword', get_string('updateuserspassword', 'tool_generator'));
$mform->addHelpButton('updateuserspassword', 'updateuserspassword', 'tool_generator');
@@ -71,25 +71,6 @@ public static function get_size_choices() {
return $options;
}

/**
* Gets the list of courses that can be used used to generate a test.
*
* @return array The list of options as courseid => name
*/
public static function get_course_options() {
$courses = get_courses('all', 'c.sortorder ASC', 'c.id, c.shortname, c.fullname');
if (!$courses) {
print_error('error_nocourses', 'tool_generator');
}

$options = array();
unset($courses[1]);
foreach ($courses as $course) {
$options[$course->id] = $course->fullname . '(' . $course->shortname . ')';
}
return $options;
}

/**
* Getter for moodle-performance-comparison project URL.
*
@@ -0,0 +1,6 @@
This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.

=== 3.7 ===

* Function tool_generator_testplan_backend::get_course_options() is removed, the 'course' form element is used instead.
@@ -78,22 +78,10 @@ public function get_courses(&$mform) {
require_once($CFG->dirroot . '/course/lib.php');
$buttonarray = array();

// Get courses with enabled completion.
$courses = $DB->get_records('course', array('enablecompletion' => COMPLETION_ENABLED));
if (!empty($courses)) {
$list = core_course_category::make_categories_list();

$select = array();
$selected = array();
foreach ($courses as $c) {
$select[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => context_course::instance($c->id)));
}

if ($this->id !== 0) {
$selected = array_keys($this->params);
}
$settings = array('multiple' => 'multiple', 'size' => 20, 'style' => 'width:300px');
$mform->addElement('select', 'courses', get_string('addcourse', 'badges'), $select, $settings);
$hasselectablecourses = core_course_category::search_courses(['onlywithcompletion' => true], ['limit' => 1]);
if ($hasselectablecourses) {
$settings = array('multiple' => 'multiple', 'onlywithcompletion' => 1);
$mform->addElement('course', 'courses', get_string('addcourse', 'badges'), $settings);
$mform->addRule('courses', get_string('requiredcourse', 'badges'), 'required');
$mform->addHelpButton('courses', 'addcourse', 'badges');

@@ -104,6 +92,7 @@ public function get_courses(&$mform) {
$mform->addElement('hidden', 'addcourse', 'addcourse');
$mform->setType('addcourse', PARAM_TEXT);
if ($this->id !== 0) {
$selected = array_keys($this->params);
$mform->setDefault('courses', $selected);
}
$mform->setType('agg', PARAM_INT);
@@ -54,6 +54,11 @@ function get_content() {
}
}

$allcourselink =
(has_capability('moodle/course:update', context_system::instance())
|| empty($CFG->block_course_list_hideallcourseslink)) &&
core_course_category::user_top();

if (empty($CFG->disablemycourses) and isloggedin() and !isguestuser() and
!(has_capability('moodle/course:update', context_system::instance()) and $adminseesall)) { // Just print My Courses
if ($courses = enrol_get_my_courses()) {
@@ -65,7 +70,7 @@ function get_content() {
}
$this->title = get_string('mycourses');
/// If we can update any course of the view all isn't hidden, show the view all courses link
if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
if ($allcourselink) {
$this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a> ...";
}
}
@@ -75,35 +80,36 @@ function get_content() {
}
}

$categories = core_course_category::get(0)->get_children(); // Parent = 0 ie top-level categories only
if ($categories) { //Check we have categories
// User is not enrolled in any courses, show list of available categories or courses (if there is only one category).
$topcategory = core_course_category::top();
if ($topcategory->is_uservisible() && ($categories = $topcategory->get_children())) { // Check we have categories.
if (count($categories) > 1 || (count($categories) == 1 && $DB->count_records('course') > 200)) { // Just print top level category links
foreach ($categories as $category) {
$categoryname = $category->get_formatted_name();
$linkcss = $category->visible ? "" : " class=\"dimmed\" ";
$this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/index.php?categoryid=$category->id\">".$icon . $categoryname . "</a>";
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
if ($allcourselink) {
$this->content->footer .= "<a href=\"$CFG->wwwroot/course/index.php\">".get_string('fulllistofcourses').'</a> ...';
}
$this->title = get_string('categories');
} else { // Just print course names of single category
$category = array_shift($categories);
$courses = get_courses($category->id);
$courses = $category->get_courses();

if ($courses) {
foreach ($courses as $course) {
$coursecontext = context_course::instance($course->id);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";

$this->content->items[]="<a $linkcss title=\""
. format_string($course->shortname, true, array('context' => $coursecontext))."\" ".
. s($course->get_formatted_shortname())."\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">"
.$icon. format_string(get_course_display_name_for_list($course), true, array('context' => context_course::instance($course->id))) . "</a>";
.$icon. $course->get_formatted_name() . "</a>";
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if (has_capability('moodle/course:update', context_system::instance()) || empty($CFG->block_course_list_hideallcourseslink)) {
if ($allcourselink) {
$this->content->footer .= "<a href=\"$CFG->wwwroot/course/index.php\">".get_string('fulllistofcourses').'</a> ...';
}
$this->get_remote_courses();
@@ -48,9 +48,8 @@ function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $a
$parentcontext = $context->get_parent_context();
if ($parentcontext->contextlevel === CONTEXT_COURSECAT) {
// Check if category is visible and user can view this category.
$category = $DB->get_record('course_categories', array('id' => $parentcontext->instanceid), '*', MUST_EXIST);
if (!$category->visible) {
require_capability('moodle/category:viewhiddencategories', $parentcontext);
if (!core_course_category::get($parentcontext->instanceid, IGNORE_MISSING)) {
send_file_not_found();
}
} else if ($parentcontext->contextlevel === CONTEXT_USER && $parentcontext->instanceid != $USER->id) {
// The block is in the context of a user, it is only visible to the user who it belongs to.
@@ -2352,8 +2352,11 @@ function calendar_get_default_courses($courseid = null, $fields = '*', $canmanag
$fieldlist = explode(',', $fields);

$prefixedfields = array_map(function($value) {
return 'c.' . trim($value);
return 'c.' . trim(strtolower($value));
}, $fieldlist);
if (!in_array('c.visible', $prefixedfields) && !in_array('c.*', $prefixedfields)) {
$prefixedfields[] = 'c.visible';
}
$courses = get_courses('all', 'c.shortname', implode(',', $prefixedfields));
} else {
$courses = enrol_get_users_courses($userid, true, $fields);
@@ -83,6 +83,7 @@
if ($courseid != SITEID && !empty($courseid)) {
navigation_node::override_active_url(new moodle_url('/course/view.php', array('id' => $course->id)));
} else if (!empty($categoryid)) {
core_course_category::get($categoryid); // Check that category exists and can be accessed.
$PAGE->set_category_by_id($categoryid);
navigation_node::override_active_url(new moodle_url('/course/index.php', array('categoryid' => $categoryid)));
} else {

0 comments on commit 11bfc07

Please sign in to comment.