Make things as simple as possible, but not simpler.
This is the documentation for NUS IVLE APIs JavaScript SDK, Version 0.0.0.
It is derivied from my Firefox Add-on NUS IVLE Helper, developed for my UNFINISHED IVLE client-side website.
Please remember to put your IVLE API key (get it at IVLE page) in the top right input box, and get your user token using your NUS account first.
Important For all results, if the result is Array
, only the first item will be displayed in Run
. You can use Run in Console
to access the complete result.
NOTE If you Run in Console
, you can always access the last data outputted in Console using $$
.
Found a issue, or any feedbacks, please file an issue here.
Copyright (c) 2012 Wang ZhuochunLicensed under the MIT license.
ivle.login(key, redirectUrl); // return the login url
ivle.getToken([url]); // return the token if it is found in location.href/url
var user = ivle.User(key, token); // return a User instance // you must init user, it will validate the user and query his/her profile user.init().done(function() { // start doing things // e.g. get user's profile user.profile(); // e.g. or get a profile item user.profile("Faculty"); // "Multi Disciplinary Programme" })
user.validate(function(result) { // result = true/false });
var profile = user.profile();
var id = user.profile("UserID");
var email = user.profile("Email");
user.modulesTaken(function(mods) { // mods = [...] });
user.unreadAnnouncements(function(anns) { // anns = [...] });
var params = {ModuleCode: "ACC1002"}; user.search("Modules", params, function(result) { // result = [...] });
Allowed Query Params:
// must have at least one query param in search q = { ModuleCode: "ACC1002" // String , ModuleTitle: "Financial" // String , LecturerName: "XXX" // String , Department: "Arts" // String , Semester: "1" // String , AcadYear: "2012/2013" // String , ModNameExact: false // Boolean , LecNameExact: false // Boolean };
var modules = []; user.modules(function(mods) { modules = mods; // mods = Module[...] });
var modId = modules[0].get("CourseName"); // course name of the 1st module in list
modules[0].update(); // update the data of the 1st module
// prefer this one anns = modules[0].announcements(); // or fetch from server modules[0].announcementsAsync(function(anns) { // anns = [...] });
bins = modules[0].workbins(); // or fetch from server modules[0].workbinsAsync(function(bins) { // bins = [...] });
forums = modules[0].forums(); // or fetch from server modules[0].forumsAsync(function(forums) { // forums = [...] });
webcasts = modules[0].webcasts(); // or fetch from server modules[0].webcastsAsync(function(webcasts) { // webcasts = [...] });
grades = modules[0].gradebooks(); // or fetch from server modules[0].gradebooksAsync(function(grades) { // grades = [...] });
Instead of passing in callbacks
into functions, all functions return a $.Deferred
object that you can also call with done
, success
, error
. So you can more controls.
However, the result will be raw data. You can filter the data using ivle.filterResult
.
// instead of passing in a callback modules[0].gradebooksAsync(function(grades) { // grades = [...] }); // you can also do this modules[0].gradebooksAync().success(function(data) { var grades = ivle.filterResult(data); // grades = [...] });
For APIs not provided, you can always call user.get(api, params)
. If params
are not required for a API, you need to pass in an empty object {}
.
// for example, get all unread announcements user.get("Announcements_Unread", {TitleOnly: false}) .success(function(data) { var anns = ivle.filterResult(data); // anns = [...] });