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()
|
@frappe.whitelist()
|
||||||
def submit_solution(exercise, code):
|
def submit_solution(exercise, code):
|
||||||
"""Submits a solution.
|
"""Submits a solution.
|
||||||
|
|
||||||
|
@exerecise: name of the exercise to submit
|
||||||
|
@code: solution to the exercise
|
||||||
"""
|
"""
|
||||||
ex = frappe.get_doc("Exercise", exercise)
|
ex = frappe.get_doc("Exercise", exercise)
|
||||||
if not ex:
|
if not ex:
|
||||||
|
|||||||
@@ -38,10 +38,16 @@ class Exercise(Document):
|
|||||||
if old_submission and old_submission.solution == code:
|
if old_submission and old_submission.solution == code:
|
||||||
return old_submission
|
return old_submission
|
||||||
|
|
||||||
|
course = frappe.get_doc("LMS Course", self.course)
|
||||||
|
batch = course.get_student_batch(user)
|
||||||
|
|
||||||
doc = frappe.get_doc(
|
doc = frappe.get_doc(
|
||||||
doctype="Exercise Submission",
|
doctype="Exercise Submission",
|
||||||
exercise=self.name,
|
exercise=self.name,
|
||||||
exercise_title=self.title,
|
exercise_title=self.title,
|
||||||
|
course=self.course,
|
||||||
|
lesson=self.lesson,
|
||||||
|
batch=batch and batch.name,
|
||||||
solution=code)
|
solution=code)
|
||||||
doc.insert()
|
doc.insert()
|
||||||
return doc
|
return doc
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
"field_order": [
|
"field_order": [
|
||||||
"exercise",
|
"exercise",
|
||||||
"solution",
|
"solution",
|
||||||
"exercise_title"
|
"exercise_title",
|
||||||
|
"course",
|
||||||
|
"batch",
|
||||||
|
"lesson"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -30,11 +33,32 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Exercise Title",
|
"label": "Exercise Title",
|
||||||
"read_only": 1
|
"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,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-19 19:41:55.852069",
|
"modified": "2021-05-20 13:30:16.349278",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Exercise Submission",
|
"name": "Exercise Submission",
|
||||||
|
|||||||
Reference in New Issue
Block a user