feat: added course, batch and lesson to exercise submission
Useful to find all the submissions for a batch/lesson.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user