Skip to content

Commit 1fd55a4

Browse files
committed
Course lists now available
1 parent 18faa3a commit 1fd55a4

File tree

12 files changed

+487
-120
lines changed

12 files changed

+487
-120
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"import"
3939
],
4040
"rules": {
41-
"indent": [ 2, 4 ]
41+
"indent": [ 2, 4 ],
42+
"padded-blocks": ["error", "always"]
4243
}
4344
}

config/default.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

config/default.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
url:
3+
root: 'https://lms.iiitb.ac.in/moodle'
4+
login: "/login/index.php"
5+
home: "/my"
6+
7+
flags:
8+
allowInsecure: true
9+
10+
status:
11+
loggedOut: 'You are not logged in.'
12+
loggedIn: 'You are logged in as '
13+
14+
params:
15+
onlineTimeout: 3000
16+
17+
eventFlags:
18+
user:
19+
getCourses:
20+
success: { status: 'success', code: 0 }
21+
unknownError: { status: 'error', code: 1 }
22+
auth:
23+
login:
24+
success: { status: 'authenticated', code: 0 }
25+
invalidCreds: {status: 'invalidCredentials', code: 1}
26+
headerMismatch: { status: 'headerMismatch', code: 2 }
27+
cannotConnect: { status: 'cannotConnect', code: 3 }
28+
unknownError: { status: 'Error', error: null, code: 4 }
29+
30+
isLoggedin:
31+
success: { status: 'success', code: 0}
32+
cannotConnect: { status: 'cannotConnect', code: 1 }
33+
nullValue: { status: 'nullValue', error: 2 }
34+
unknownError: { status: 'Error', code: 3 }
35+
36+
course:
37+
forum:
38+
success: { status: 'success', code: 0 }
39+
noForum: { status: 'noForum', code: 1 }
40+
cannotConnect: { status: 'cannotConnect', code: 2 }
41+
unknownError: { status: 'Error', code: 3 }
42+
43+
activity:
44+
success: { status: 'success', code: 0 }
45+
noActivity: { status: 'noActivity', code: 1 }
46+
cannotConnect: { status: 'cannotConnect', code: 2 }
47+
unknownError: { status: 'Error', code: 3 }
48+
49+
material:
50+
success: { status: 'success', code: 0 }
51+
noMaterial: { status: 'noMaterial', code: 1 }
52+
cannotConnect: { status: 'cannotConnect', code: 2 }
53+
unknownError: { status: 'Error', code: 3 }
54+
55+
selector:
56+
site:
57+
pageTitle: ".headermenu"
58+
userStatus: ".logininfo"
59+
loggedOut: 'You are not logged in.'
60+
loggedIn: 'You are logged in as '
61+
62+
user:
63+
privateFiles:
64+
selector: div[id^="private_files_tree_"]
65+
link: a @href
66+
name: a
67+
68+
courseList:
69+
selector: "#page-content"
70+
link: ".corner-box .content .course_list h2 @href"
71+
name: ".corner-box .content .course_list h2"
72+
73+
course:
74+
activity:
75+
activity: "#section-2"
76+
summary: "div.content > div > div > p"
77+
link: ".modtype_assign > div > div > div:nth-child(2) > div.activityinstance > a @href"
78+
name: ".modtype_assign > div > div > div:nth-child(2) > div.activityinstance > a"
79+
desc: ".modtype_assign > div > div > div:nth-child(2) > div.contentafterlink > div > div > p"
80+
81+
forum:
82+
forum: "#section-0"
83+
link: ".modtype_forum > div > div > div:nth-child(2) > div > a @href"
84+
name: ".modtype_forum > div > div > div:nth-child(2) > div > a"
85+
86+
87+
material:
88+
material: "#section-1"
89+
summary: ".summary"
90+
link: ".modtype_folder a @href"
91+
name: ".modtype_folder a"
92+
desc: ".contentafterlink p"
93+

index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const password = process.env.LMS_PASSWORD;
33

44
const osmosis = require('osmosis');
55
const User = require('./src/User/User');
6+
const Auth = require('./src/Auth/Auth');
67

78
const user = new User(username, password);
89
// const net = require('./src/Helpers/Network');
@@ -13,20 +14,33 @@ const Course = require('./src/Course/Course');
1314
const course = new Course('https://lms.iiitb.ac.in/moodle/course/view.php?id=816');
1415

1516
function onLogin(osmosis) {
16-
course.getMaterial(osmosis)
17+
18+
course.getForums(osmosis)
1719
.then((res) => {
20+
1821
console.log(res);
22+
1923
}, (err) => {
24+
25+
console.log(err);
26+
27+
})
28+
.catch((err) => {
2029
console.log(err);
2130
});
31+
2232
}
2333

2434
user.login(osmosis)
2535
.then((res) => {
26-
// console.log(res);
36+
37+
console.log(res);
2738
onLogin(osmosis);
39+
2840
}, (err) => {
41+
2942
console.log(err);
43+
3044
});
3145

3246

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"config": "^1.26.1",
1212
"cookie": "^0.3.1",
1313
"debug": "^2.6.8",
14+
"js-yaml": "^3.8.4",
1415
"jswget": "^0.4.1",
1516
"osmosis": "^1.1.4"
1617
},

0 commit comments

Comments
 (0)