@@ -36,7 +36,7 @@ class Exercise(Document):
|
||||
return old_submission
|
||||
|
||||
course = frappe.get_doc("LMS Course", self.course)
|
||||
batch = course.get_student_batch(user)
|
||||
member = course.get_membership(frappe.session.user)
|
||||
|
||||
doc = frappe.get_doc(
|
||||
doctype="Exercise Submission",
|
||||
@@ -44,8 +44,9 @@ class Exercise(Document):
|
||||
exercise_title=self.title,
|
||||
course=self.course,
|
||||
lesson=self.lesson,
|
||||
batch=batch and batch.name,
|
||||
solution=code)
|
||||
batch=member.batch,
|
||||
solution=code,
|
||||
member=member.name)
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
return doc
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Exercise Latest Submission', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -0,0 +1,166 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-12-08 17:56:26.049675",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"exercise",
|
||||
"status",
|
||||
"batch",
|
||||
"column_break_4",
|
||||
"exercise_title",
|
||||
"course",
|
||||
"lesson",
|
||||
"section_break_8",
|
||||
"solution",
|
||||
"image",
|
||||
"test_results",
|
||||
"comments",
|
||||
"latest_submission",
|
||||
"member",
|
||||
"member_email",
|
||||
"member_cohort",
|
||||
"member_subgroup"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "exercise",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Exercise",
|
||||
"options": "Exercise",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"label": "Status",
|
||||
"options": "Correct\nIncorrect"
|
||||
},
|
||||
{
|
||||
"fieldname": "batch",
|
||||
"fieldtype": "Link",
|
||||
"label": "Batch",
|
||||
"options": "LMS Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fetch_from": "exercise.title",
|
||||
"fieldname": "exercise_title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Exercise Title",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "exercise.course",
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Course",
|
||||
"options": "LMS Course",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "exercise.lesson",
|
||||
"fieldname": "lesson",
|
||||
"fieldtype": "Link",
|
||||
"label": "Lesson",
|
||||
"options": "Course Lesson"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_8",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fetch_from": "latest_submission.solution",
|
||||
"fieldname": "solution",
|
||||
"fieldtype": "Code",
|
||||
"label": "Solution"
|
||||
},
|
||||
{
|
||||
"fetch_from": "latest_submission.image",
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Code",
|
||||
"label": "Image",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "latest_submission.test_results",
|
||||
"fieldname": "test_results",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Test Results"
|
||||
},
|
||||
{
|
||||
"fieldname": "comments",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Comments"
|
||||
},
|
||||
{
|
||||
"fieldname": "latest_submission",
|
||||
"fieldtype": "Link",
|
||||
"label": "Latest Submission",
|
||||
"options": "Exercise Submission"
|
||||
},
|
||||
{
|
||||
"fieldname": "member",
|
||||
"fieldtype": "Link",
|
||||
"label": "Member",
|
||||
"options": "LMS Batch Membership"
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.member",
|
||||
"fieldname": "member_email",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Member Email",
|
||||
"options": "User",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.cohort",
|
||||
"fieldname": "member_cohort",
|
||||
"fieldtype": "Link",
|
||||
"label": "Member Cohort",
|
||||
"options": "Cohort",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.subgroup",
|
||||
"fieldname": "member_subgroup",
|
||||
"fieldtype": "Link",
|
||||
"label": "Member Subgroup",
|
||||
"options": "Cohort Subgroup",
|
||||
"search_index": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-08 22:58:46.312861",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Exercise Latest Submission",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, Frappe and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class ExerciseLatestSubmission(Document):
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestExerciseLatestSubmission(unittest.TestCase):
|
||||
pass
|
||||
@@ -16,7 +16,8 @@
|
||||
"solution",
|
||||
"image",
|
||||
"test_results",
|
||||
"comments"
|
||||
"comments",
|
||||
"member"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -90,11 +91,17 @@
|
||||
{
|
||||
"fieldname": "section_break_8",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "member",
|
||||
"fieldtype": "Link",
|
||||
"label": "Member",
|
||||
"options": "LMS Batch Membership"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-09-29 15:27:57.273879",
|
||||
"modified": "2021-12-08 22:25:05.809376",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Exercise Submission",
|
||||
|
||||
@@ -5,4 +5,20 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class ExerciseSubmission(Document):
|
||||
pass
|
||||
def on_update(self):
|
||||
self.update_latest_submission()
|
||||
|
||||
def update_latest_submission(self):
|
||||
names = frappe.get_all("Exercise Latest Submission", {"exercise": self.exercise, "member": self.member})
|
||||
if names:
|
||||
doc = frappe.get_doc("Exercise Latest Submission", names[0])
|
||||
doc.latest_submission = self.name
|
||||
doc.save(ignore_permissions=True)
|
||||
else:
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Exercise Latest Submission",
|
||||
"exercise": self.exercise,
|
||||
"member": self.member,
|
||||
"latest_submission": self.name
|
||||
})
|
||||
doc.save(ignore_permissions=True)
|
||||
|
||||
Reference in New Issue
Block a user