forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-63058 block_myoverview: starring and storing preferences
- Loading branch information
Bas Brands
committed
Oct 20, 2018
1 parent
b81722e
commit 3cfff88
Showing
39 changed files
with
1,402 additions
and
100 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
* @copyright 2018 Bas Brands <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
define(['core/ajax'], function(Ajax) { | ||
define(['core/ajax', 'core/notification'], function(Ajax, Notification) { | ||
|
||
/** | ||
* Retrieve a list of enrolled courses. | ||
|
@@ -47,7 +47,55 @@ define(['core/ajax'], function(Ajax) { | |
return promise; | ||
}; | ||
|
||
/** | ||
* Set the favourite state on a list of courses. | ||
* | ||
* Valid args are: | ||
* Array courses list of course id numbers. | ||
* | ||
* @param {Object} args Arguments send to the webservice. | ||
* @return {Promise} Resolve with warnings. | ||
*/ | ||
var setFavouriteCourses = function(args) { | ||
|
||
var request = { | ||
methodname: 'core_course_set_favourite_courses', | ||
args: args | ||
}; | ||
|
||
var promise = Ajax.call([request])[0]; | ||
|
||
return promise; | ||
}; | ||
|
||
/** | ||
* Update the user preferences. | ||
* | ||
* @param {Object} args Arguments send to the webservice. | ||
* | ||
* Sample args: | ||
* { | ||
* preferences: [ | ||
* { | ||
* type: 'block_example_user_sort_preference' | ||
* value: 'title' | ||
* } | ||
* ] | ||
* } | ||
*/ | ||
var updateUserPreferences = function(args) { | ||
var request = { | ||
methodname: 'core_user_update_user_preferences', | ||
args: args | ||
}; | ||
|
||
Ajax.call([request])[0] | ||
.fail(Notification.exception); | ||
}; | ||
|
||
return { | ||
getEnrolledCoursesByTimeline: getEnrolledCoursesByTimeline | ||
getEnrolledCoursesByTimeline: getEnrolledCoursesByTimeline, | ||
setFavouriteCourses: setFavouriteCourses, | ||
updateUserPreferences: updateUserPreferences | ||
}; | ||
}); |
Oops, something went wrong.