courses.management.commands.import_moodle¶
Django management commands for courses app.
Module Contents¶
-
class
courses.management.commands.import_moodle.Command¶ Bases:
django.core.management.BaseCommandRemove all data from Mofa and imports all courses and teachers from Moodle.
-
handle(self, *args, **options)¶ Define main method.
-
-
courses.management.commands.import_moodle.import_courses()¶ Import courses from Moodle and add to Django database.
-
courses.management.commands.import_moodle.import_course_content()¶ Import course content from Moodle and add to Django database.
-
courses.management.commands.import_moodle.get_course_contents_for_all_courses(course_list)¶ Get all course contents from Moodle for all courses.
- Parameters
course_list (dict(str, int)) – List of dictionary. Key: external course id. Value: mofa course id.
- Returns
List of dictionaries of course contents for all the courses in course_list.
- Return type
list(dict(str, int)
-
courses.management.commands.import_moodle.group_course_contents(courses_contents)¶ Group all the course contents by content type.
- Parameters
courses_contents (list(dict(str, int)) – List of dictionaries of course contents for all the courses in course_list.
- Returns
A dictionary with a list of each of the assessments and resources.
- Return type
dict(str, list(dict(str, int)))
-
courses.management.commands.import_moodle.get_quiz_questions(grouped_dict)¶ Get the quiz questions for all quizzes individually and combine them.
- Parameters
grouped_dict (dict(str,list(dict(str, int)))) – A dictionary with a list of each of the assessments and resources.
- Returns
A dictionary with questions.
- Return type
dict(int, list(dict(str, str)))
-
courses.management.commands.import_moodle.fill_database(grouped_dict, question_list)¶ Fill the database with all specified course contents.
- Parameters
grouped_dict (dict(str,list(dict(str, int)))) – A dictionary with a list of each of the assessments and resources.
question_list (dict(int, list(dict(str, str)))) – A dictionary with questions.
-
courses.management.commands.import_moodle.import_teachers()¶ Import the teachers from Moodle.
- Returns
Amount of imported users.
- Return type
int
-
courses.management.commands.import_moodle.create_auth_group()¶ Create teacher group, add permissions add to Django database.
- Returns
Teacher auth group.
:rtype Auth Group
-
courses.management.commands.import_moodle.create_teachers(teachers_list)¶ Create teachers and add them to Django database.
- Parameters
teachers_list (dict(int, dict(str, str))) – Dictionary of teachers.
- Returns
A QuerySet of teachers.
- Return type
QuerySet
-
courses.management.commands.import_moodle.add_courses_and_group_to_users(course_list, teacher_group, teachers_list, users)¶ Add courses the teacher teaches to that teacher. Add teacher to teachers group.
- Parameters
course_list (dict(int, int)) – List of courses.
teacher_group (Auth Group) – Teachers group.
teachers_list (dict(int, dict(str, str))) – Dictionary of teachers.
users (QuerySet) – QuerySet of all the teachers.