IVLE 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/IVLE.gemspec +29 -0
  4. data/LICENSE +7 -0
  5. data/README.md +61 -0
  6. data/Rakefile +1 -0
  7. data/config/settings.yml +2 -0
  8. data/doc/Fixtures.html +167 -0
  9. data/doc/Fixtures/IVLE.html +213 -0
  10. data/doc/Gemfile.html +133 -0
  11. data/doc/IVLE.html +278 -0
  12. data/doc/IVLE/API.html +424 -0
  13. data/doc/IVLE/Announcement.html +309 -0
  14. data/doc/IVLE/Community.html +1305 -0
  15. data/doc/IVLE/Consultation.html +342 -0
  16. data/doc/IVLE/DeltaDatasets.html +213 -0
  17. data/doc/IVLE/Forum.html +533 -0
  18. data/doc/IVLE/Gradebook.html +213 -0
  19. data/doc/IVLE/IVLEModule.html +567 -0
  20. data/doc/IVLE/IVLENews.html +213 -0
  21. data/doc/IVLE/LibraryEReserves.html +245 -0
  22. data/doc/IVLE/Login.html +309 -0
  23. data/doc/IVLE/MyOrganizer.html +520 -0
  24. data/doc/IVLE/OpenWebcastLectures.html +247 -0
  25. data/doc/IVLE/Poll.html +309 -0
  26. data/doc/IVLE/Profile.html +213 -0
  27. data/doc/IVLE/RostersAndGroups.html +676 -0
  28. data/doc/IVLE/StudentEvents.html +378 -0
  29. data/doc/IVLE/Timetable.html +309 -0
  30. data/doc/IVLE/Webcast.html +247 -0
  31. data/doc/IVLE/Workbin.html +245 -0
  32. data/doc/Object.html +185 -0
  33. data/doc/Rakefile.html +131 -0
  34. data/doc/created.rid +26 -0
  35. data/doc/images/add.png +0 -0
  36. data/doc/images/brick.png +0 -0
  37. data/doc/images/brick_link.png +0 -0
  38. data/doc/images/bug.png +0 -0
  39. data/doc/images/bullet_black.png +0 -0
  40. data/doc/images/bullet_toggle_minus.png +0 -0
  41. data/doc/images/bullet_toggle_plus.png +0 -0
  42. data/doc/images/date.png +0 -0
  43. data/doc/images/delete.png +0 -0
  44. data/doc/images/find.png +0 -0
  45. data/doc/images/loadingAnimation.gif +0 -0
  46. data/doc/images/macFFBgHack.png +0 -0
  47. data/doc/images/package.png +0 -0
  48. data/doc/images/page_green.png +0 -0
  49. data/doc/images/page_white_text.png +0 -0
  50. data/doc/images/page_white_width.png +0 -0
  51. data/doc/images/plugin.png +0 -0
  52. data/doc/images/ruby.png +0 -0
  53. data/doc/images/tag_blue.png +0 -0
  54. data/doc/images/tag_green.png +0 -0
  55. data/doc/images/transparent.png +0 -0
  56. data/doc/images/wrench.png +0 -0
  57. data/doc/images/wrench_orange.png +0 -0
  58. data/doc/images/zoom.png +0 -0
  59. data/doc/index.html +126 -0
  60. data/doc/js/darkfish.js +155 -0
  61. data/doc/js/jquery.js +18 -0
  62. data/doc/js/navigation.js +142 -0
  63. data/doc/js/search.js +94 -0
  64. data/doc/js/search_index.js +1 -0
  65. data/doc/js/searcher.js +228 -0
  66. data/doc/rdoc.css +543 -0
  67. data/doc/table_of_contents.html +379 -0
  68. data/lib/IVLE.rb +133 -0
  69. data/lib/IVLE/api/announcement.rb +19 -0
  70. data/lib/IVLE/api/community.rb +174 -0
  71. data/lib/IVLE/api/consultation.rb +24 -0
  72. data/lib/IVLE/api/delta_datasets.rb +7 -0
  73. data/lib/IVLE/api/forum.rb +47 -0
  74. data/lib/IVLE/api/gradebook.rb +7 -0
  75. data/lib/IVLE/api/ivle_news.rb +7 -0
  76. data/lib/IVLE/api/library_ereserves.rb +11 -0
  77. data/lib/IVLE/api/login.rb +19 -0
  78. data/lib/IVLE/api/module.rb +53 -0
  79. data/lib/IVLE/api/my_organizer.rb +62 -0
  80. data/lib/IVLE/api/open_webcast_lectures.rb +13 -0
  81. data/lib/IVLE/api/poll.rb +19 -0
  82. data/lib/IVLE/api/profile.rb +7 -0
  83. data/lib/IVLE/api/rosters_and_groups.rb +78 -0
  84. data/lib/IVLE/api/student_events.rb +32 -0
  85. data/lib/IVLE/api/timetable.rb +19 -0
  86. data/lib/IVLE/api/webcast.rb +13 -0
  87. data/lib/IVLE/api/workbin.rb +11 -0
  88. data/lib/IVLE/version.rb +3 -0
  89. data/spec/api/api_spec.rb +34 -0
  90. data/spec/fixtures/api/login.html +11 -0
  91. data/spec/fixtures/api/modules.json +201 -0
  92. data/spec/fixtures/ivle.rb +7 -0
  93. data/spec/fixtures/modules.json +201 -0
  94. metadata +216 -0
@@ -0,0 +1,19 @@
1
+ module IVLE
2
+ module Poll
3
+ def polls(course_id, poll_id, title_only=false)
4
+ api 'Polls', courseid: course_id, pollid: poll_id, titleonly: title_only
5
+ end
6
+
7
+ def poll_submit_vote(poll_id, poll_question_id, poll_question_option_id, other_text)
8
+ api_post 'Poll_SubmitVote_JSON', pollid: poll_id, pollquestionid: poll_question_id, pollquestionoptionid: poll_question_option_id, othertext: other_text
9
+ end
10
+
11
+ def poll_get_voted_user(poll_id, poll_question_id, poll_question_option_id)
12
+ api 'Poll_GetVotedUser', pollid: poll_id, pollquestionid: poll_question_id, pollquestionoptionid: poll_question_option_id
13
+ end
14
+
15
+ def poll_get_voted_user_other(poll_id, poll_question_id, poll_question_option_id)
16
+ api 'Poll_GetVotedUser_Other', pollid: poll_id, pollquestionid: poll_question_id, pollquestionoptionid: poll_question_option_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module IVLE
2
+ module Profile
3
+ def profile_view
4
+ api 'Profile_View'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,78 @@
1
+ module IVLE
2
+ module RostersAndGroups
3
+ def class_roster(course_id)
4
+ api 'Class_Roster', courseid: course_id
5
+ end
6
+
7
+ def guest_roster(course_id)
8
+ api 'Guest_Roster', courseid: course_id
9
+ end
10
+
11
+ def groups_by_user_and_module(course_id=nil, acad_year=nil, semester=nil)
12
+ if course_id == nil && (acad_year == nil || semester == nil)
13
+ raise 'Missing arguments: acad_year and semester must not be nil if course_id is nil'
14
+ elsif course_id.nil?
15
+ params = {}
16
+ else
17
+ params = { courseid: course_id, acadyear: acad_year, semester: semester }
18
+ end
19
+
20
+ api 'GroupsByUserAndModule', params
21
+ end
22
+
23
+ def groups_by_user
24
+ api 'GroupsByUser'
25
+ end
26
+
27
+ def module_class_groups(course_id, flag)
28
+ api 'Module_ClassGroups', courseid: course_id, flag: flag
29
+ end
30
+
31
+ def module_class_group_users(class_group_id)
32
+ api 'Module_ClassGroups', classgroupid: class_group_id
33
+ end
34
+
35
+ def module_official_group_users(course_id, module_code, group_name, acad_year, semester, group_type)
36
+ api 'Module_OfficialGroupUsers', {
37
+ courseid: course_id,
38
+ modulecode: module_code,
39
+ groupname: group_name,
40
+ acadyear: acad_year,
41
+ semester: semester,
42
+ grouptype: group_type
43
+ }
44
+ end
45
+
46
+ def class_group_sign_up(course_id, group_id)
47
+ api_post 'ClassGroupSignUp_JSON', courseid: course_id, groupid: group_id
48
+ end
49
+
50
+ def class_group_sign_up_remove(course_id, group_id)
51
+ api_post 'ClassGroupSignUpRemove_JSON', courseid: course_id, groupid: group_id
52
+ end
53
+
54
+ def group_projects_by_user(course_id, include_groups, group_type)
55
+ api 'GroupProjectsByUser', courseid: course_id, includegroups: include_groups, grouptype: group_type
56
+ end
57
+
58
+ def project_self_enrol_groups(project_id)
59
+ api 'Project_SelfEnrolGroups', projectid: project_id
60
+ end
61
+
62
+ def project_group_users(project_group_id)
63
+ api 'ProjectGroupUsers', projectgroupid: project_group_id
64
+ end
65
+
66
+ def project_enrolled_groups
67
+ api 'Project_EnrolledGroups'
68
+ end
69
+
70
+ def project_group_sign_up(project_group_id)
71
+ api_post 'ProjectGroup_SignUp_JSON', projectgroupid: project_group_id
72
+ end
73
+
74
+ def project_group_remove_sign_up(project_group_id)
75
+ api_post 'ProjectGroup_RemoveSignUp_JSON', projectgroupid: project_group_id
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,32 @@
1
+ module IVLE
2
+ module StudentEvents
3
+ def student_events(title_only=false)
4
+ api 'StudentEvents', titleonly: title_only
5
+ end
6
+
7
+ def student_events_categories(include_events=true, title_only=false)
8
+ api 'StudentEvents_Categories', includeevents: include_events, titleonly: title_only
9
+ end
10
+
11
+ def student_events_committees(include_events=true, title_only=false)
12
+ api 'StudentEvents_Committees', includeevents: include_events, titleonly: title_only
13
+ end
14
+
15
+ def student_events_category(category_id, title_only=false)
16
+ api 'StudentEvents_Category', categoryid: category_id, titleonly: title_only
17
+ end
18
+
19
+ def student_events_committee(committee_id, title_only=false)
20
+ api 'StudentEvents_Committee', committeeid: committee_id, titleonly: title_only
21
+ end
22
+
23
+ def student_event_post_new_event(category_id, committee_id, evt_start_date, evt_end_date)
24
+ api_post 'StudentEvent_PostNewEvent_JSON', {
25
+ categoryid: category_id,
26
+ committeeid: committee_id,
27
+ evtstartdate: evt_start_date,
28
+ evtenddate: evt_end_date
29
+ }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ module IVLE
2
+ module Timetable
3
+ def timetable_student(acad_year, semester)
4
+ api 'Timetable_Student', acadyear: acad_year, semester: semester
5
+ end
6
+
7
+ def timetable_module(course_id)
8
+ api 'Timetable_Module', courseid: course_id
9
+ end
10
+
11
+ def timetable_student_module(course_id)
12
+ api 'Timetable_Student_Module', courseid: course_id
13
+ end
14
+
15
+ def timetable_module_exam(course_id)
16
+ api 'Timetable_ModuleExam', courseid: course_id
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module IVLE
2
+ module Webcast
3
+ def webcasts(course_id, duration=0, media_channel_id=nil)
4
+ optionals = media_channel_id.nil? ? {} : { mediachannelid: media_channel_id }
5
+ api 'Webcasts', { courseid: course_id, duration: duration }.merge(optionals)
6
+ end
7
+
8
+ def webcast_add_log(media_channel_id, media_channel_item_id)
9
+ # Docs are bad
10
+ api_post 'Webcast_AddLog_JSON', mediachannelid: media_channel_id, mediachannelitemid: media_channel_item_id
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module IVLE
2
+ module Workbin
3
+ def workbins(course_id, duration=0, workbin_id=nil, title_only=false)
4
+ api 'Workbins', courseid: course_id, duration: duration, workbinid: workbin_id, titleonly: title_only
5
+ end
6
+
7
+ def download_file(id)
8
+ api 'downloadfile', id: id
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module IVLE
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,34 @@
1
+ require 'fakeweb'
2
+ require 'IVLE'
3
+ require 'fixtures/ivle'
4
+
5
+ describe IVLE::API do
6
+ include Fixtures::IVLE
7
+
8
+ context 'API calls' do
9
+ before do
10
+ FakeWeb.register_uri(:get,
11
+ "https://ivle.nus.edu.sg/api/login?apikey=api_key&url=",
12
+ body: read_fixture('login.html'),
13
+ content_type: "text/html")
14
+
15
+ FakeWeb.register_uri(:post,
16
+ "https://ivle.nus.edu.sg/api/login?apikey",
17
+ body: "1111",
18
+ content_type: "text/html")
19
+
20
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
21
+ stub.get('api/Lapi.svc/Modules') {[ 200, {}, read_fixture('modules.json') ]}
22
+ end
23
+
24
+ mock_client = Faraday.new(url: 'https://ivle.nus.edu.sg/') { |f| f.adapter :test, stubs }
25
+ IVLE::API.any_instance.stub(:client).and_return(mock_client)
26
+ @ivle = IVLE::API.new('api_key', 'login', 'pass')
27
+ end
28
+
29
+ it 'calls an API method' do
30
+ # This tests the entire API flow.
31
+ expect(@ivle.modules[:Results]).to have(4).items
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ </head>
5
+ <body>
6
+ <form name="frm" onsubmit="javascript:return WebForm_OnSubmit();" action="?apikey" method="post">
7
+ <input name="userid" type="password" maxlength="100" name="password">
8
+ <input name="password" type="password" maxlength="100" name="password">
9
+ </form>
10
+ </body>
11
+ </html>
@@ -0,0 +1,201 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "Announcements": [],
5
+ "Forums": [],
6
+ "Workbins": [],
7
+ "Webcasts": [],
8
+ "Gradebooks": [],
9
+ "Polls": [],
10
+ "ID": "3333333-0106-46c6-b488-5e6bf643df67",
11
+ "CourseLevel": "1",
12
+ "CourseCode": "NM3209",
13
+ "CourseName": "Creating Interactive Media",
14
+ "CourseDepartment": "",
15
+ "CourseSemester": "Semester 1",
16
+ "CourseAcadYear": "2013/2014",
17
+ "CourseOpenDate": "/Date(1369929600000+0800)/",
18
+ "CourseOpenDate_js": "2013-05-31T00:00:00",
19
+ "CourseCloseDate": "/Date(1386345540000+0800)/",
20
+ "CourseCloseDate_js": "2013-12-06T23:59:00",
21
+ "CourseMC": "4",
22
+ "isActive": "Y",
23
+ "Permission": "S",
24
+ "Creator": {
25
+ "UserID": "cnmmk",
26
+ "Name": "Kevin McGee",
27
+ "Email": null,
28
+ "Title": null,
29
+ "UserGuid": "333333-0795-4b24-8d31-ed00398f4180",
30
+ "AccountType": null
31
+ },
32
+ "hasGradebookItems": false,
33
+ "hasTimetableItems": true,
34
+ "hasGroupsItems": true,
35
+ "hasClassGroupsForSignUp": false,
36
+ "hasGuestRosterItems": false,
37
+ "hasClassRosterItems": true,
38
+ "hasWeblinkItems": true,
39
+ "hasLecturerItems": true,
40
+ "hasDescriptionItems": true,
41
+ "hasReadingItems": false,
42
+ "hasAnnouncementItems": false,
43
+ "hasProjectGroupItems": false,
44
+ "hasProjectGroupsForSignUp": false,
45
+ "hasConsultationItems": false,
46
+ "hasConsultationSlotsForSignUp": false,
47
+ "Badge": 0,
48
+ "BadgeAnnouncement": 0,
49
+ "WebLinks": [],
50
+ "Lecturers": [],
51
+ "Descriptions": [],
52
+ "ReadingFormatted": [],
53
+ "ReadingUnformatted": []
54
+ },
55
+ {
56
+ "Announcements": [],
57
+ "Forums": [],
58
+ "Workbins": [],
59
+ "Webcasts": [],
60
+ "Gradebooks": [],
61
+ "Polls": [],
62
+ "ID": "3333333-3456-4cf1-a6ee-bdc8afed01cb",
63
+ "CourseLevel": "1",
64
+ "CourseCode": "NM4227",
65
+ "CourseName": "PLAYABLE ART",
66
+ "CourseDepartment": "",
67
+ "CourseSemester": "Semester 1",
68
+ "CourseAcadYear": "2013/2014",
69
+ "CourseOpenDate": "/Date(1369152000000+0800)/",
70
+ "CourseOpenDate_js": "2013-05-22T00:00:00",
71
+ "CourseCloseDate": "/Date(1386345540000+0800)/",
72
+ "CourseCloseDate_js": "2013-12-06T23:59:00",
73
+ "CourseMC": "0",
74
+ "isActive": "Y",
75
+ "Permission": "S",
76
+ "Creator": {
77
+ "UserID": "cnmams",
78
+ "Name": "Anne Marie Schleiner",
79
+ "Email": null,
80
+ "Title": null,
81
+ "UserGuid": "3333333-2a80-4ed6-b44566-a221111a8e3",
82
+ "AccountType": null
83
+ },
84
+ "hasGradebookItems": false,
85
+ "hasTimetableItems": true,
86
+ "hasGroupsItems": true,
87
+ "hasClassGroupsForSignUp": false,
88
+ "hasGuestRosterItems": false,
89
+ "hasClassRosterItems": true,
90
+ "hasWeblinkItems": false,
91
+ "hasLecturerItems": true,
92
+ "hasDescriptionItems": true,
93
+ "hasReadingItems": false,
94
+ "hasAnnouncementItems": false,
95
+ "hasProjectGroupItems": false,
96
+ "hasProjectGroupsForSignUp": false,
97
+ "hasConsultationItems": false,
98
+ "hasConsultationSlotsForSignUp": false,
99
+ "Badge": 0,
100
+ "BadgeAnnouncement": 0,
101
+ "WebLinks": [],
102
+ "Lecturers": [],
103
+ "Descriptions": [],
104
+ "ReadingFormatted": [],
105
+ "ReadingUnformatted": []
106
+ },
107
+ {
108
+ "Announcements": [],
109
+ "Forums": [],
110
+ "Workbins": [],
111
+ "Webcasts": [],
112
+ "Gradebooks": [],
113
+ "Polls": [],
114
+ "ID": "00000000-0000-0000-0000-000000000000",
115
+ "CourseLevel": null,
116
+ "CourseCode": "CS4249",
117
+ "CourseName": "PHENOMENA AND THEORIES OF HUMAN-COMPUTER INTERACTION",
118
+ "CourseDepartment": null,
119
+ "CourseSemester": "1",
120
+ "CourseAcadYear": "2013/2014",
121
+ "CourseOpenDate": "/Date(1375452583402+0800)/",
122
+ "CourseOpenDate_js": "2013-08-02T22:09:43.4027946+08:00",
123
+ "CourseCloseDate": "/Date(1375452583402+0800)/",
124
+ "CourseCloseDate_js": "2013-08-02T22:09:43.4027946+08:00",
125
+ "CourseMC": null,
126
+ "isActive": "Y",
127
+ "Permission": "S",
128
+ "Creator": null,
129
+ "hasGradebookItems": false,
130
+ "hasTimetableItems": false,
131
+ "hasGroupsItems": false,
132
+ "hasClassGroupsForSignUp": false,
133
+ "hasGuestRosterItems": false,
134
+ "hasClassRosterItems": false,
135
+ "hasWeblinkItems": false,
136
+ "hasLecturerItems": false,
137
+ "hasDescriptionItems": false,
138
+ "hasReadingItems": false,
139
+ "hasAnnouncementItems": false,
140
+ "hasProjectGroupItems": false,
141
+ "hasProjectGroupsForSignUp": false,
142
+ "hasConsultationItems": false,
143
+ "hasConsultationSlotsForSignUp": false,
144
+ "Badge": 0,
145
+ "BadgeAnnouncement": 0,
146
+ "WebLinks": [],
147
+ "Lecturers": [],
148
+ "Descriptions": [],
149
+ "ReadingFormatted": [],
150
+ "ReadingUnformatted": []
151
+ },
152
+ {
153
+ "Announcements": [],
154
+ "Forums": [],
155
+ "Workbins": [],
156
+ "Webcasts": [],
157
+ "Gradebooks": [],
158
+ "Polls": [],
159
+ "ID": "00000000-0000-0000-0000-000000000000",
160
+ "CourseLevel": null,
161
+ "CourseCode": "CS4345",
162
+ "CourseName": "GENERAL-PURPOSE COMPUTATION ON GPU",
163
+ "CourseDepartment": null,
164
+ "CourseSemester": "1",
165
+ "CourseAcadYear": "2013/2014",
166
+ "CourseOpenDate": "/Date(1375452583402+0800)/",
167
+ "CourseOpenDate_js": "2013-08-02T22:09:43.4027946+08:00",
168
+ "CourseCloseDate": "/Date(1375452583402+0800)/",
169
+ "CourseCloseDate_js": "2013-08-02T22:09:43.4027946+08:00",
170
+ "CourseMC": null,
171
+ "isActive": "Y",
172
+ "Permission": "S",
173
+ "Creator": null,
174
+ "hasGradebookItems": false,
175
+ "hasTimetableItems": false,
176
+ "hasGroupsItems": false,
177
+ "hasClassGroupsForSignUp": false,
178
+ "hasGuestRosterItems": false,
179
+ "hasClassRosterItems": false,
180
+ "hasWeblinkItems": false,
181
+ "hasLecturerItems": false,
182
+ "hasDescriptionItems": false,
183
+ "hasReadingItems": false,
184
+ "hasAnnouncementItems": false,
185
+ "hasProjectGroupItems": false,
186
+ "hasProjectGroupsForSignUp": false,
187
+ "hasConsultationItems": false,
188
+ "hasConsultationSlotsForSignUp": false,
189
+ "Badge": 0,
190
+ "BadgeAnnouncement": 0,
191
+ "WebLinks": [],
192
+ "Lecturers": [],
193
+ "Descriptions": [],
194
+ "ReadingFormatted": [],
195
+ "ReadingUnformatted": []
196
+ }
197
+ ],
198
+ "Comments": "Valid login!",
199
+ "LastUpdate": "/Date(1375452581593+0800)/",
200
+ "LastUpdate_js": "2013-08-02T22:09:41.5931636+08:00"
201
+ }
@@ -0,0 +1,7 @@
1
+ module Fixtures
2
+ module IVLE
3
+ def read_fixture(name)
4
+ File.read(File.dirname(__FILE__) + "/api/#{name}")
5
+ end
6
+ end
7
+ end