Skip to content

Commit

Permalink
Bug #8, add admin_add_course_category_link() Javascript [iet:10328314]
Browse files Browse the repository at this point in the history
* Also, fix for `conditional_embedded_survey::grade_items_id` PHP variable
* [ci skip]
  • Loading branch information
nfreear committed Apr 13, 2018
1 parent 963cb3f commit df85371
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ phantomjs
rasterize.js
/*.png

.DS_Store
*.docx

# End.
12 changes: 6 additions & 6 deletions classes/local/conditional_embedded_survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class conditional_embedded_survey extends base {
// const EMBED_LIKE = '%</iframe>%'; // 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;
Expand All @@ -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;

Expand Down
15 changes: 12 additions & 3 deletions js/src/local-fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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('<a href="%s" class="dropdown-item tesla-r">TeSLA results</a>'.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('<a href="%s" class="list-group-item">All courses</a>'.replace(/%s/, url));
}

0 comments on commit df85371

Please sign in to comment.