From df85371ecb573de7279b51787971c37c8bfb7342 Mon Sep 17 00:00:00 2001 From: Nick Freear Date: Fri, 13 Apr 2018 15:59:06 +0100 Subject: [PATCH] Bug #8, add `admin_add_course_category_link()` Javascript [iet:10328314] * Also, fix for `conditional_embedded_survey::grade_items_id` PHP variable * [ci skip] --- .gitignore | 3 +++ classes/local/conditional_embedded_survey.php | 12 ++++++------ js/src/local-fixes.js | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 86957fc..1f75983 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,7 @@ phantomjs rasterize.js /*.png +.DS_Store +*.docx + # End. diff --git a/classes/local/conditional_embedded_survey.php b/classes/local/conditional_embedded_survey.php index fa957b8..1ede259 100644 --- a/classes/local/conditional_embedded_survey.php +++ b/classes/local/conditional_embedded_survey.php @@ -22,11 +22,11 @@ class conditional_embedded_survey extends base { // const EMBED_LIKE = '%%'; // MySQL 'LIKE' const EMBED_REGEXP = '(<\/iframe>|[?#!]-pre-survey-embed)'; // MySQL 'REGEXP' - protected $course_id; // 4, - protected $course_code; // 'FR', - protected $cmid; // 72, - protected $activity_id; // 'assign.id' = 13, - protected $grade_items_id; // 47, + protected $course_id; // 4, + protected $course_code; // 'FR', + protected $cmid; // `mdl_course_modules`.`id`; 72, + protected $activity_id; // `mdl_course_modules`.`instance`; 'assign.id' = 13; + protected $grade_items_id; // NOT used. 47, protected $userid; protected $config; @@ -53,7 +53,7 @@ protected function set_config( $course_code, $userid = null ) { $this->course_code = $course_code; $this->cmid = $config->cmid; $this->activity_id = $config->activity_id; - $this->grade_items_id = $config->grade_items_id; + $this->grade_items_id = isset( $config->grade_items_id ) ? $config->grade_items_id : null; // NOT used. $this->userid = $userid ? $userid : $USER->id; diff --git a/js/src/local-fixes.js b/js/src/local-fixes.js index e1a8e37..5e39cf9 100644 --- a/js/src/local-fixes.js +++ b/js/src/local-fixes.js @@ -15,6 +15,8 @@ module.exports = function ($, resp) { course_add_tesla_result_links($, resp); + admin_add_course_category_link($); + $(window.document).ajaxSuccess(function (ev, xhr, settings) { if (settings.url.match(/enrollment_ajax.php/)) { console.warn('> enrollment_ajax:', xhr.responseText, xhr.status, ev.namespace); @@ -185,15 +187,22 @@ function fix_pilot_fallback_link($, resp) { function course_add_tesla_result_links($, resp) { var $cm_edit_menus = $('.path-course-view .section-cm-edit-actions[ data-owner ]'); - var use_lti = resp.config.lti_results; + var lti_res = resp.config.lti_results; $cm_edit_menus.each(function (idx, el) { var cmid = $(this).data('owner').replace(/#module-/, ''); var $link = $(this).find('a.editing_update.cm-edit-action'); - var url = '/local/tesla/views/tesla_results.php?cmid=' + cmid + (use_lti ? '' : '&noredirect=1'); + var url = '/local/tesla/views/tesla_results.php?cmid=' + cmid + (lti_res ? '' : '&noredirect=1'); $link.after('TeSLA results'.replace(/%s/, url)); - console.warn('course-add-tesla-result-links, cmid:', cmid, url, resp.config.lti_results); + console.warn('course-add-tesla-result-links, cmid:', cmid, url, lti_res); }); } + +function admin_add_course_category_link($) { + var $admin_menu = $('#nav-drawer nav a[ data-key = sitesettings ]').closest('nav'); + var url = '/course/'; + + $admin_menu.append('All courses'.replace(/%s/, url)); +}