def mod_assign_unlock_submissions(assignment_id, user_ids): """ Unlocks submissions for a specific assignments for a specific user(s). """ call_moodle_api( "mod_assign_unlock_submissions", assignmentid=assignment_id, userids=user_ids, )
def core_enrol_get_enrolled_users(course_id): """ Get enrolled users by course id """ response = call_moodle_api("core_enrol_get_enrolled_users", courseid=course_id) return response
def mod_feedback_get_analysis(feedback_id): """ Retrieves the responses for the given feedback id """ response = call_moodle_api("mod_feedback_get_analysis", feedbackid=feedback_id) return response
def mod_feedback_get_feedbacks_by_courses(course_id): """ Retrieves all feedbacks for a given course """ response = call_moodle_api("mod_feedback_get_feedbacks_by_courses", courseids=[course_id]) return response["feedbacks"]
def mod_assign_get_submission_status(assignment_id, user_id=None): """ Returns the submissions for the given assignments in a dict mapping assignment id to submissions {id: [..]} """ response = call_moodle_api("mod_assign_get_submission_status", assignid=assignment_id, userid=user_id) return response
def mod_assign_get_grades(assignment_ids): """ Returns the grades for all the assignments """ response = call_moodle_api("mod_assign_get_grades", assignmentids=assignment_ids) grades = {} for grds in response["assignments"]: grades[grds["assignmentid"]] = grds["grades"] return grades
def mod_assign_get_submissions(assignment_ids): """ Returns the submissions for the given assignments in a dict mapping assignment id to submissions {id: [..]} """ response = call_moodle_api("mod_assign_get_submissions", assignmentids=assignment_ids) submissions = {} for assign in response["assignments"]: submissions[assign["assignmentid"]] = assign["submissions"] return submissions
def mod_assign_get_assignments(course_id): """ Returns a dictionary mapping assignment id to its name from a specified course """ response = call_moodle_api("mod_assign_get_assignments", courseids=[course_id]) if not response["courses"]: raise EmptyCourseError( "Received an empty course." + "It could be that the course does not have any assignments.\n" + response) return response["courses"][0]["assignments"]
def get_user_name(user_id): response = call_moodle_api("core_user_get_users_by_field", field="id", values=[user_id]) response_json = response[0] return response_json["firstname"] + " " + response_json["lastname"]
def core_course_get_contents(course_id): """ Returns the structure of the course with all resources and topics """ return call_moodle_api("core_course_get_contents", courseid=course_id)
def core_course_get_courses(): """ Returns a tuple of ids and course names """ return call_moodle_api("core_course_get_courses")