I'm a student and my university uses Moodle as their learning management
system (LMS). They don't have Moodle Web Services enabled and won't be
enabling it anytime soon, at least for students. The university programs
have the following structure, for example:

1. Bachelor's Degree in Computer Science (duration: 8 semesters)

1.1. Unit 01: Mathematics Fundamental (duration: 1 semester)
1.1.1. Algebra I (first 3 months)
1.1.2. Algebra II (first 3 months)
1.1.3. Calculus I (last 3 months)
1.1.4. Calculus II (last 3 months)
1.1.5. Unit Project (throughout the semester)

1.2. Unit 02: Programming (duration: 1 semester)
1.2.1. Programming Logic (first 3 months)
1.2.2. Data Modelling with UML (first 3 months)
1.2.3. Python I (last 3 months)
1.2.4. Python II (last 3 months)
1.2.5. Unit Project (throughout the semester)

Each course/project have a bunch of assignments + one final assignment.
This goes on, totalizing 8 (eight) units, which will make up for a 4-year
program. I have to build my own Moodle API to be consumed by my program,
currently I'm using 'requests' + 'bs4' to do the job. I'm not here for
coding help, instead I have some python software design doubts. Some
information I have in mind:

- I was thinking about having the following classes: Program, Unit, Course,
Assignment, User.
- User would handle auth + session, the rest is pretty straightforward,
program would handle programs, unit would handles units, and so on.
- Inside Program init there would be attributes title, id and units; inside
Unit init there would be attributes title, id and courses; inside Course
init there would be attributes title, id, due_date, submitted, grade.

Should I call the site using requests and do all the parsing for everything
using bs4 as soon as I create a new instance of User? For example:

user = User('john.smith', 'password')  # will get all data needed
user.program  # <Program 'Computer Science' (10260)>

cs = user.program
cs.units  # <Unit 'Mathematics Fundamental' (1405)>, <Unit 'Programming'
(1413)>, etc.

prog = cs.units[1]
prog.assignments  # <Assignment 'Assignment 01' (200)>, <Assignment
'Assignment 02' (201)>, <Assignment 'Assignment 03' (202)>, <Assignment
'Assignment 04' (203)>, [...], <Assignment 'Final Assignment' (210)>

as03 = cs.assignments[2]
as03.title  # ''Assignment 03"
as03.id  # 202
as03.due_date  # 2016-11-30T21:21:00+00:00 (ISO 8601)

Is this a good Pythonic design? If not, how could it be better?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to