Skip to content

Commit

Permalink
MDL-52747 tool_lp: Show courses linked to competency in plan
Browse files Browse the repository at this point in the history
Show courses that are linked to the given competency for a  given
 learning plan on a modal dialogue.
  • Loading branch information
junpataleta authored and Frederic Massart committed Apr 18, 2016
1 parent c5e89aa commit 55ac216
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion admin/tool/lp/amd/build/planactions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions admin/tool/lp/amd/src/planactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ define(['jquery',
'core/ajax',
'core/notification',
'core/str',
'tool_lp/menubar'],
function($, templates, ajax, notification, str, Menubar) {
'tool_lp/menubar',
'tool_lp/dialogue'],
function($, templates, ajax, notification, str, Menubar, Dialogue) {

/**
* PlanActions class.
Expand Down Expand Up @@ -487,6 +488,34 @@ define(['jquery',
this._doUnapprove(planData);
};

/**
* Display list of linked courses on a modal dialogue.
*
* @param {Event} e The event.
*/
PlanActions.prototype._showLinkedCoursesHandler = function(e) {
e.preventDefault();

var competencyid = $(e.target).data('id');
var requests = ajax.call([{
methodname: 'tool_lp_list_courses_using_competency',
args: { id: competencyid }
}]);

requests[0].done(function(courses) {
var context = {
courses: courses
};
templates.render('tool_lp/linked_courses_summary', context).done(function(html) {
str.get_string('linkedcourses', 'tool_lp').done(function (linkedcourses) {
new Dialogue(
linkedcourses, // Title.
html // The linked courses.
);
}).fail(notification.exception);
}).fail(notification.exception);
}).fail(notification.exception);
};

/**
* Plan event handler.
Expand Down Expand Up @@ -563,6 +592,8 @@ define(['jquery',
wrapper.find('[data-action="plan-stop-review"]').click(this._eventHandler.bind(this, 'stopReview'));
wrapper.find('[data-action="plan-approve"]').click(this._eventHandler.bind(this, 'approve'));
wrapper.find('[data-action="plan-unapprove"]').click(this._eventHandler.bind(this, 'unapprove'));

wrapper.find('[data-action="find-courses-link"]').click(this._showLinkedCoursesHandler.bind(this));
};

return PlanActions;
Expand Down
1 change: 1 addition & 0 deletions admin/tool/lp/lang/en/tool_lp.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
$string['errorplanstatus'] = 'Learning plans \'{$a}\' status unknown';
$string['errorscalealreadyused'] = 'The scale cannot be changed, it is already being used.';
$string['errorscaleconfiguration'] = 'You must configure the scale by selecting default and proficient values.';
$string['findcourses'] = 'Find courses';
$string['frameworkcannotbedeleted'] = 'The competency framework \'{$a}\' can not be deleted';
$string['hidden'] = 'Hidden';
$string['hiddenhint'] = '(hidden)';
Expand Down
3 changes: 3 additions & 0 deletions admin/tool/lp/templates/plan_page.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
<a href="#" data-action="delete-competency-link" data-id="{{competency.id}}">{{#pix}}t/delete, core{{/pix}} {{#str}}delete{{/str}}</a>
</li>
{{/plan.canbeedited}}
<li>
<a href="#" data-action="find-courses-link" data-id="{{competency.id}}">{{#pix}}t/preview, core{{/pix}} {{#str}}findcourses, tool_lp{{/str}}</a>
</li>
</ul>
</li>
</ul>
Expand Down

0 comments on commit 55ac216

Please sign in to comment.