We need to have little improvements in "Courses pending approval" page (/course/pending.php):
- "Requested by" user name as link to user profile (otherwise admin needs to go to user search...)
- "Category" should be full category path – we have a lot of categories and the name without the path is not sufficient.
I also have code for these changes:
Moodle 2.4
/course/lib.php file changes |
diff --git a/course/lib.php b/course/lib.php
|
index 18576c8..8633443 100644
|
--- a/course/lib.php
|
+++ b/course/lib.php
|
@@ -2248,6 +2248,24 @@ function make_categories_options() {
|
}
|
|
/**
|
+ * This function will make category path with ID-s (like "/123/789") to readable path string (like "Main Category ► Sub Category").
|
+ *
|
+ * @param string $path Path containing category ID-s instead of names
|
+ * @param string $separator Separator to use between category names
|
+ * @return string full category path with cateory names
|
+ */
|
+function get_category_readable_path($path, $separator = ' ► ') {
|
+ global $DB;
|
+ $categories = explode('/', $path);
|
+ $readablepath = '';
|
+ foreach ($categories as $categoryid) {
|
+ $category = $DB->get_record('course_categories', array('id' => $categoryid));
|
+ $readablepath .= ($readablepath == '' ? '' : $separator) . $category->name;
|
+ }
|
+ return $readablepath;
|
+}
|
+
|
+/**
|
* Prints the category info in indented fashion
|
* This function is only used by print_whole_category_list() above
|
*/
|
/course/pending.php file changes |
diff --git a/course/pending.php b/course/pending.php
|
index 3d6cb18..50583ca 100644
|
--- a/course/pending.php
|
+++ b/course/pending.php
|
@@ -124,9 +124,13 @@ if (empty($pending)) {
|
$row = array();
|
$row[] = format_string($course->shortname);
|
$row[] = format_string($course->fullname);
|
- $row[] = fullname($course->get_requester());
|
+
|
+ $requester = $course->get_requester();
|
+ $userurl = new moodle_url('/user/profile.php', array('id' => $requester->id));
|
+ $row[] = html_writer::link($userurl, fullname($requester), array('target' => '_blank'));
|
+
|
$row[] = $course->summary;
|
- $row[] = format_string($category->name);
|
+ $row[] = format_string(get_category_readable_path($category->path));
|
$row[] = format_string($course->reason);
|
$row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') .
|
$OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get');
|
|
Moodle 2.5 (not tested)
/lib/coursecatlib.php file changes |
diff --git a/lib/coursecatlib.php b/lib/coursecatlib.php
|
index 6cf2ea1..7a8f5ab 100644
|
--- a/lib/coursecatlib.php
|
+++ b/lib/coursecatlib.php
|
@@ -1806,6 +1806,24 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
}
|
|
/**
|
+ * Returns nice readable cateogry path string wiht cetegory names (example: "Main Category ► Sub Category").
|
+ *
|
+ * @param string $separator separator to use between category names
|
+ * @return string full category path with cateory names
|
+ */
|
+ function get_path_with_names($separator = ' ► ') {
|
+ global $DB;
|
+ $categories = explode('/', $this->path);
|
+ $readablepath = '';
|
+ foreach ($categories as $categoryid) {
|
+ $category = $DB->get_record('course_categories', array('id' => $categoryid));
|
+ $coursecat = new coursecat($category);
|
+ $readablepath .= ($readablepath == '' ? '' : $separator) . $coursecat->get_formatted_name();
|
+ }
|
+ return $readablepath;
|
+ }
|
+
|
+ /**
|
* Returns ids of all parents of the category. Last element in the return array is the direct parent
|
*
|
* For example, if you have a tree of categories like:
|
/course/pending.php file changes |
diff --git a/course/pending.php b/course/pending.php
|
index eaf4c28..f8b8f62 100644
|
--- a/course/pending.php
|
+++ b/course/pending.php
|
@@ -115,9 +115,13 @@ if (empty($pending)) {
|
$row = array();
|
$row[] = format_string($course->shortname);
|
$row[] = format_string($course->fullname);
|
- $row[] = fullname($course->get_requester());
|
+
|
+ $requester = $course->get_requester();
|
+ $userurl = new moodle_url('/user/profile.php', array('id' => $requester->id));
|
+ $row[] = html_writer::link($userurl, fullname($requester), array('target' => '_blank'));
|
+
|
$row[] = $course->summary;
|
- $row[] = $category->get_formatted_name();
|
+ $row[] = $category->get_path_with_names();
|
$row[] = format_string($course->reason);
|
$row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') .
|
$OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get');
|
|
- has been marked as being related by
-
MDL-72699 Add link to the user profile in the field Requested by at Courses pending approval
-
- Closed
-