eLearning is an API dedicated to managing the backend infrastructure of an e-learning system.
Project description
eLearning API Documentation
eLearning is an API dedicated to managing the backend infrastructure of an e-learning system. eLearning is totally developed with Python 3.6+ and the data storing is a MongoDB implementation through the third-party API pymongo 3.9.0.
Installation
Assuming, Python 3 (>=3.6) is already installed and a MongoDB Cluster connection is working, eLearning API needs the next requirements:
-
pymongo 3.9.0. Or, it can be easily installed with:
$ python -m pip install pymongo
-
dnspython. Or, it can be easily installed with:
$ python -m pip install pymongo[srv]
-
pip. Or, it can be easily installed with:
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py $ python get-pip.py
-
Install with:
$ pip install eLearning
-
Import and hello-world:
import eLearning as el elc = el.eLearning_connector() print(elc.client) print(elc.db) print(elc.db.list_collection_names()) elc._tabula_rasa() elc.insert_professor( 'Paul Erdős', 'erdos@princeton.edu' ) elc.insert_student( 'Terence Tao', 'tao@princeton.edu' )
Testing
To test the API, please try the next lines at your Python command-line interface:
import eLearning as el
el.eLearning_test.run()
eLearning API documentation
Connector level operations
class eLearning_connector ( )
An eLearning_connector is the object used to communicate with MongoDB cluster and databases. eLearning_connector object has the next attributes:
- eLearning_connector.client : informative dictionary about the connector.
- eLearning_connector.db : informative dictionary about the database.
- eLearning_connector.course_collection : MongoDB collection object with the courses information.
- eLearning_connector.lesson_collection : MongoDB collection object with the lessons information.
- eLearning_connector.question_collection : MongoDB collection object with the questions information.
- eLearning_connector.binnacle_collection : MongoDB collection object with the binnacles information.
- eLearning_connector.record_collection : MongoDB collection object with the records information.
- eLearning_connector.user_collection : MongoDB collection object with the users information.
eLearning_connector.insert_professor ( fullname, email )
Return the tuple
('200 - OK',"")
if the professor-user with given fullname and email was inserted successfully in the database. Otherwise, return('409 - Conflict',"Insertion error.")
.
eLearning_connector.insert_student ( fullname, email )
Return the tuple
('200 - OK',"")
if the student-user with given fullname and email was inserted successfully in the database. Otherwise, return('409 - Conflict',"Insertion error.")
.
eLearning_connector.delete_user_by_email ( email )
Return the tuple
('200 - OK',"")
if the user with given email was deleted successfully from the database. Otherwise, return('409 - Conflict',"Deletion error.")
.
eLearning_connector.get_user_by_email ( email )
Return a class eLearning_professor instance if the given email results of a professor-user. Return a class eLearning_student instance if the given email results of a student-user. Otherwise, return
None
.
eLearning_connector.list_professors ()
Return a Python list object with all existing professor-user documents, each document is arranged into a Python dict object. If there are not professor-users in database, an empty list is returned.
eLearning_connector.list_students ()
Return a Python list object with all existing student-user documents, each document is arranged into a Python dict object. If there are not student-users in database, an empty list is returned.
eLearning_connector.list_courses ()
Return a Python list object with all existing course documents, each document is arranged into a Python dict object. If there are not courses in database, an empty list is returned.
eLearning_connector.list_lessons ( parent_course_code )
Return a Python list object with all associated lesson documents to a given parent_course_code, each document is arranged into a Python dict object. If there are not such lessons in database, an empty list is returned.
eLearning_connector.list_questions ( parent_lesson_code )
Return a Python list object with all associated question documents to a given parent_lesson_code, each document is arranged into a Python dict object. If there are not such questions in database, an empty list is returned.
User level operations
class eLearning_professor ( )
An eLearning_professor instance corresponds to the valid professor-users' attributes and methods:
- eLearning_professor.fullname :
<str>
Fullname of the user. - eLearning_professor.email :
<str>
e-mail address of the user. - eLearning_professor.role :
<str>
it always set as "professor".
eLearning_professor.create_course ( title, code, description=None
, required_course_code=None
)
Parameters :
- title:
<str>
Customized title for the course.- code:
<str>
Customized code for the course.- description:
<str>
Description of the course.- required_course_code:
<str>
Code of required approved-course.
Return the tuple
('200 - OK',"")
if the course with given parameters was created successfully in the database. Otherwise, return('400 - Bad Request',"Course's code already exists.")
,('404 - Not Found',"Required-course's code not found.")
or('409 - Conflict',"Insertion error.")
.
eLearning_professor.create_lesson ( title, code, content, parent_course_code, approval_score=1.0
, required_lesson_code=None
)
Parameters :
- title:
<str>
Customized title for the lesson.- code:
<str>
Customized code for the lesson.- content:
<str>
Description of the lesson.- correct_answers:
<list>
List of the correct answer labels (<str>
).- parent_course_code:
<str>
Code of the parent-course.- approval_score:
<float>
Floating number between0.0
(minimal score) and1.0
(maximal score).- required_lesson_code:
<str>
Code of required approved-lesson.
Return the tuple
('200 - OK',"")
if the lesson with given parameters was created successfully in the database. Otherwise, return('400 - Bad Request',"Lesson's code already exists.")
,('404 - Not Found',"Required-lesson's code not found.")
,('404 - Not Found',"Parent-course's code not found.")
or('409 - Conflict',"Insertion error.")
.
eLearning_professor.create_question ( code, mode, content, correct_answers, parent_lesson_code )
Parameters :
- code:
<str>
Customized code for the question.- mode:
<str>
"Bool","MC1A","MCMA+","MCMA*" only.- content:
<str>
Description of the question.- correct_answers:
<list>
List of option labels.- parent_lesson_code:
<str>
Code of the parent-course.
Return the tuple
('200 - OK',"")
if the question with given parameters was created successfully in the database. Otherwise, return('400 - Bad Request',"Invalid question mode.")
,('400 - Bad Request',"Answers have to be a list of strings.")
,('404 - Not Found',"Parent-lesson's code not found.")
or('409 - Conflict',"Insertion error.")
.
eLearning_professor.list_courses ( )
Return the Python object list with all current courses.
eLearning_professor.read_course ( code, full=False
)
Parameters :
- code:
<str>
Code of the course.- full:
<bool>
False
orTrue
.
Return the Python object dict with the given course attributes at creation time. Moreover, if full is set to
True
, the information of all subscribed lessons and questions will be included.
eLearning_professor.read_lesson ( code, full=False
)
Parameters :
- code:
<str>
Code of the lesson.- full:
<bool>
False
orTrue
.
Return the Python object dict with the given lesson attributes at creation time. Moreover, if full is set to
True
, the information of all subscribed questions will be included.
eLearning_professor.read_question ( code )
Parameters :
- code:
<str>
Code of the question.
Return the Python object dict with the given question attributes at creation time.
eLearning_professor.update_course ( code, **kwards )
Parameters :
- code:
<str>
Code of the course.- **kwards:
<dict>
Dictionary with the attributes to update for the given course.
Return an integer with the count of modified attributes.
eLearning_professor.update_lesson ( code, **kwards )
Parameters :
- code:
<str>
Code of the lesson.- **kwards:
<dict>
Dictionary with the attributes to update for the given lesson.
Return an integer with the count of modified attributes.
eLearning_professor.update_question ( code, **kwards )
Parameters :
- code:
<str>
Code of the question.- **kwards:
<dict>
Dictionary with the attributes to update for the given question.
Return an integer with the count of modified attributes.
eLearning_professor.delete_course ( code, **kwards )
Parameters :
- code:
<str>
Code of the course.
Return an integer with the count of deleted objects.
eLearning_professor.delete_lesson ( code, **kwards )
Parameters :
- code:
<str>
Code of the lesson.
Return an integer with the count of deleted objects.
eLearning_professor.delete_question ( code, **kwards )
Parameters :
- code:
<str>
Code of the question.
Return an integer with the count of deleted objects.
class eLearning_student ( )
An eLearning_student instance corresponds to the valid student-users' attributes and methods:
- eLearning_student.fullname :
<str>
Fullname of the user. - eLearning_student.email :
<str>
e-mail address of the user. - eLearning_student.role :
<str>
it always set as "student". - eLearning_student.score :
<float>
Main score.
eLearning_student.get_record_summary ( )
Return a Python object list with informative dict about the type, code, status, score and datetime of all courses and lessons taken by the student.
eLearning_student.list_courses_and_availability ( )
Return a Python object list with all current courses. Every course is represented by an informative dict, where the key
'available'
indicate withTrue
, whether the course is available for the student or withFalse
otherwise.
eLearning_student.list_lessons_and_availability ( parent_course_code )
Parameters :
- parent_course_code:
<str>
Code of the parent-course.
Return a Python object list with all current lessons. Every lesson is represented by an informative dict, where the key
'available'
indicate withTrue
, whether the lesson is available for the student or withFalse
otherwise.
eLearning_student.get_full_lesson ( code )
Parameters :
- code:
<str>
Code of the claimed lesson.
Return a Python object dict with the claimed lesson information and its subscrited questions.
eLearning_student.take_lesson ( code, answers_list )
Parameters :
- code:
<str>
Code of the taken lesson.- answer_list:
<list>
List with lists of the correct answers labels; e.g.[['A','C'],['A'],[True]]
.
Return a Python object dict resuming the score, status of the taken lesson and the parent-course status whether was approved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for eLearning-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b302c02c5c4a4f0cdcfd0b9d778609492cd284c89d10c69313a3c250b6c08e76 |
|
MD5 | badaac82e34df2e8a2f17aedb496a5b0 |
|
BLAKE2b-256 | 404a0e3361dc3111f67996293f6037a145411931858c53b907aa924b064115fb |