Example #1
0
def course(session_id, course_id):
    try:
        session = smussdsparser.Session(session_id)
        course = smussdsparser.Course(session, course_id)
        return jsonify({'course': course.get_course_information()})
    except smussdsparser.NotLoggedInException:
        return abort(
            make_response(
                jsonify(message="The session id provided is not logged in."),
                401))
Example #2
0
def assignments(session_id, course_id):
    try:
        session = smussdsparser.Session(session_id)
        course = smussdsparser.Course(session, course_id)
        return jsonify(
            {'assignments': [x.__dict__ for x in course.get_assignments()]})
    except smussdsparser.NotLoggedInException:
        return abort(
            make_response(
                jsonify(message="The session id provided is not logged in."),
                401))
Example #3
0
def student(session_id):
    try:
        session = smussdsparser.Session(session_id)
        student = smussdsparser.Student(session)
        student_dict = student.__dict__
        student_dict.pop('courses')
        student_dict.pop('session')
        return jsonify({'student': student.__dict__})
    except smussdsparser.NotLoggedInException:
        return abort(
            make_response(
                jsonify(message="The session id provided is not logged in."),
                401))
Example #4
0
def courses(session_id):
    try:
        session = smussdsparser.Session(session_id)
        student = smussdsparser.Student(session)
        return jsonify({
            'courses': [{
                'id': x.course_id,
                'name': x.course_name,
                'teacher_name': x.teacher_name
            } for x in student.get_student_courses()]
        })
    except smussdsparser.NotLoggedInException:
        return abort(
            make_response(
                jsonify(message="The session id provided is not logged in."),
                401))
Example #5
0
import smussdsparser

# The session_id can be obtained by logging into SMUS SDS and using a chrome extension like EditThisCookie to find
# the PHPSESSID cookie value.
session_id = 'aaaaaaaaaaaaaaaaaaaaaaaa'

# The first step is creating our session
my_session = smussdsparser.Session(session_id)

# We create a student object by passing our session to the Student class
try:
    my_account = smussdsparser.Student(my_session)
except smussdsparser.NotLoggedInException:
    print('The session is not logged in.')
    exit()

# Student objects have many attributes including name and courses
print('Welcome ' + my_account.name + '.')
print('You are currently enrolled in ' + str(len(my_account.courses)) +
      ' courses.')
print('')

for course in my_account.courses:
    print(course.course_name + ' by ' + course.teacher_name)
    if course.has_assignments:
        print('Assignments:')
        for assignment in course.get_assignments():
            print(assignment.title + ' due on ' +
                  assignment.due_date.strftime('%d %b %Y'))
    else:
        print('Your teacher has not enabled assignments.')