Skip to content

Commit

Permalink
MDL-70817 core_course: Convert core_course/repository to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Apr 2, 2021
1 parent 6fc9b23 commit 3a960c1
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion course/amd/build/repository.min.js

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

2 changes: 1 addition & 1 deletion course/amd/build/repository.min.js.map

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

184 changes: 92 additions & 92 deletions course/amd/src/repository.js
Expand Up @@ -20,102 +20,102 @@
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/ajax'], function($, Ajax) {

/**
* Get the list of courses that the logged in user is enrolled in for a given
* timeline classification.
*
* @param {string} classification past, inprogress, or future
* @param {int} limit Only return this many results
* @param {int} offset Skip this many results from the start of the result set
* @param {string} sort Column to sort by and direction, e.g. 'shortname asc'
* @return {object} jQuery promise resolved with courses.
*/
var getEnrolledCoursesByTimelineClassification = function(classification, limit, offset, sort) {
var args = {
classification: classification
};

if (typeof limit !== 'undefined') {
args.limit = limit;
}

if (typeof offset !== 'undefined') {
args.offset = offset;
}

if (typeof sort !== 'undefined') {
args.sort = sort;
}

var request = {
methodname: 'core_course_get_enrolled_courses_by_timeline_classification',
args: args
};

return Ajax.call([request])[0];

import Ajax from 'core/ajax';

/**
* Get the list of courses that the logged in user is enrolled in for a given
* timeline classification.
*
* @param {string} classification past, inprogress, or future
* @param {int} limit Only return this many results
* @param {int} offset Skip this many results from the start of the result set
* @param {string} sort Column to sort by and direction, e.g. 'shortname asc'
* @return {object} jQuery promise resolved with courses.
*/
const getEnrolledCoursesByTimelineClassification = (classification, limit, offset, sort) => {
const args = {
classification: classification
};

/**
* Get the list of courses that the user has most recently accessed.
*
* @method getLastAccessedCourses
* @param {int} userid User from which the courses will be obtained
* @param {int} limit Only return this many results
* @param {int} offset Skip this many results from the start of the result set
* @param {string} sort Column to sort by and direction, e.g. 'shortname asc'
* @return {promise} Resolved with an array of courses
*/
var getLastAccessedCourses = function(userid, limit, offset, sort) {
var args = {};

if (typeof userid !== 'undefined') {
args.userid = userid;
}

if (typeof limit !== 'undefined') {
args.limit = limit;
}

if (typeof offset !== 'undefined') {
args.offset = offset;
}

if (typeof sort !== 'undefined') {
args.sort = sort;
}

var request = {
methodname: 'core_course_get_recent_courses',
args: args
};

return Ajax.call([request])[0];
if (typeof limit !== 'undefined') {
args.limit = limit;
}

if (typeof offset !== 'undefined') {
args.offset = offset;
}

if (typeof sort !== 'undefined') {
args.sort = sort;
}

const request = {
methodname: 'core_course_get_enrolled_courses_by_timeline_classification',
args: args
};

/**
* Get the list of users enrolled in this cmid.
*
* @param {Number} cmid Course Module from which the users will be obtained
* @param {Number} groupID Group ID from which the users will be obtained
* @returns {Promise} Promise containing a list of users
*/
var getEnrolledUsersFromCourseModuleID = function(cmid, groupID) {
var request = {
methodname: 'core_course_get_enrolled_users_by_cmid',
args: {
cmid: cmid,
groupid: groupID,
},
};

return Ajax.call([request])[0];
return Ajax.call([request])[0];
};

/**
* Get the list of courses that the user has most recently accessed.
*
* @method getLastAccessedCourses
* @param {int} userid User from which the courses will be obtained
* @param {int} limit Only return this many results
* @param {int} offset Skip this many results from the start of the result set
* @param {string} sort Column to sort by and direction, e.g. 'shortname asc'
* @return {promise} Resolved with an array of courses
*/
const getLastAccessedCourses = (userid, limit, offset, sort) => {
const args = {};

if (typeof userid !== 'undefined') {
args.userid = userid;
}

if (typeof limit !== 'undefined') {
args.limit = limit;
}

if (typeof offset !== 'undefined') {
args.offset = offset;
}

if (typeof sort !== 'undefined') {
args.sort = sort;
}

const request = {
methodname: 'core_course_get_recent_courses',
args: args
};

return {
getEnrolledCoursesByTimelineClassification: getEnrolledCoursesByTimelineClassification,
getLastAccessedCourses: getLastAccessedCourses,
getUsersFromCourseModuleID: getEnrolledUsersFromCourseModuleID,
return Ajax.call([request])[0];
};

/**
* Get the list of users enrolled in this cmid.
*
* @param {Number} cmid Course Module from which the users will be obtained
* @param {Number} groupID Group ID from which the users will be obtained
* @returns {Promise} Promise containing a list of users
*/
const getEnrolledUsersFromCourseModuleID = (cmid, groupID) => {
var request = {
methodname: 'core_course_get_enrolled_users_by_cmid',
args: {
cmid: cmid,
groupid: groupID,
},
};
});

return Ajax.call([request])[0];
};

export default {
getEnrolledCoursesByTimelineClassification,
getLastAccessedCourses,
getUsersFromCourseModuleID: getEnrolledUsersFromCourseModuleID,
};

0 comments on commit 3a960c1

Please sign in to comment.