Select Git revision
-
Jan Philipp Timme authoredJan Philipp Timme authored
jmodule.js 6.94 KiB
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
define(['jquery'], function ($) {
function search(searchstring, reloadBool, displaymode, instanceid, sesskey, contextid, idsearching, orderbysemester, wwwroot) {
if (reloadBool) {
$("#hshcourseprogress").show();
$.ajax({
type: 'GET',
url: wwwroot + '/blocks/hshcourselist/hshcourselist.php',
data: 'course=' + searchstring + '&instanceid=' + instanceid
+ '&sesskey=' + sesskey + '&contextid=' + contextid
+ '&idsearching=' + idsearching + '&orderbysemester=' + orderbysemester,
dataType: "json",
success: function (response) {
var plainJSON = JSON.stringify(response);
var courses = JSON.parse(plainJSON);
var list = $("<ul class='list-group' id='hshcourselistul'></ul>");
if (courses.length > 0) {
$.each(courses, function (index, course) {
switch (displaymode) {
case '0':
displaystr = course.shortname;
break;
case '1':
displaystr = course.fullname;
break;
case '2':
displaystr = course.shortname + ': ' + course.fullname;
break;
default:
displaystr = course.fullname;
break;
}
$('<li class="list-group-item hshcoursesearchlistitem " value="' + course.id + '">'
+ '<a href="' + wwwroot + '/course/view.php?id=' + course.id + '">' + displaystr + '</a> </li>')
.appendTo(list);
});
}
$("#hshcourselistul").replaceWith(list);
$("#hshcourseprogress").hide();
},
error: function (a) {
console.error("error " + JSON.stringify(a));
}
});
} else {
}
}
return {
init: function (jsdataobject, wwwroot) {
var jsdataobject = jsdataobject;
var instanceid = jsdataobject.instanceid;