diff --git a/community/lms/api.py b/community/lms/api.py index 879c2a05..3a7bd1b0 100644 --- a/community/lms/api.py +++ b/community/lms/api.py @@ -25,6 +25,9 @@ def get_section(name): @frappe.whitelist() def submit_solution(exercise, code): """Submits a solution. + + @exerecise: name of the exercise to submit + @code: solution to the exercise """ ex = frappe.get_doc("Exercise", exercise) if not ex: diff --git a/community/lms/doctype/exercise/exercise.py b/community/lms/doctype/exercise/exercise.py index b9e9246e..313165cf 100644 --- a/community/lms/doctype/exercise/exercise.py +++ b/community/lms/doctype/exercise/exercise.py @@ -38,10 +38,16 @@ class Exercise(Document): if old_submission and old_submission.solution == code: return old_submission + course = frappe.get_doc("LMS Course", self.course) + batch = course.get_student_batch(user) + doc = frappe.get_doc( doctype="Exercise Submission", exercise=self.name, exercise_title=self.title, + course=self.course, + lesson=self.lesson, + batch=batch and batch.name, solution=code) doc.insert() return doc diff --git a/community/lms/doctype/exercise_submission/exercise_submission.json b/community/lms/doctype/exercise_submission/exercise_submission.json index ab26ff8e..de7541ea 100644 --- a/community/lms/doctype/exercise_submission/exercise_submission.json +++ b/community/lms/doctype/exercise_submission/exercise_submission.json @@ -7,7 +7,10 @@ "field_order": [ "exercise", "solution", - "exercise_title" + "exercise_title", + "course", + "batch", + "lesson" ], "fields": [ { @@ -30,11 +33,32 @@ "in_list_view": 1, "label": "Exercise Title", "read_only": 1 + }, + { + "fetch_from": "exercise.course", + "fieldname": "course", + "fieldtype": "Link", + "label": "Course", + "options": "LMS Course", + "read_only": 1 + }, + { + "fieldname": "batch", + "fieldtype": "Link", + "label": "Batch", + "options": "LMS Batch" + }, + { + "fetch_from": "exercise.lesson", + "fieldname": "lesson", + "fieldtype": "Link", + "label": "Lesson", + "options": "Lesson" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-05-19 19:41:55.852069", + "modified": "2021-05-20 13:30:16.349278", "modified_by": "Administrator", "module": "LMS", "name": "Exercise Submission",