Modified add-activity, no duplicates will be saved now
This commit is contained in:
parent
a3afe2a998
commit
76222f7acc
@ -106,8 +106,8 @@ def evaluate_quiz(quiz_response, quiz_name):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_completed_courses(email=frappe.session.user):
|
def get_completed_courses(email=frappe.session.user):
|
||||||
|
print("Get completed course ", email)
|
||||||
try:
|
try:
|
||||||
print(email)
|
|
||||||
student = frappe.get_doc("Student", get_student_id(email))
|
student = frappe.get_doc("Student", get_student_id(email))
|
||||||
return student.get_completed_courses()
|
return student.get_completed_courses()
|
||||||
except:
|
except:
|
||||||
@ -174,12 +174,26 @@ def get_course_enrollments(email=frappe.session.user):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_activity(enrollment, content_type, content):
|
def add_activity(enrollment, content_type, content):
|
||||||
activity = frappe.get_doc({
|
if(check_activity_exists(enrollment, content_type, content)):
|
||||||
"doctype": "Course Activity",
|
pass
|
||||||
"enrollment": enrollment,
|
else:
|
||||||
"content_type": content_type,
|
activity = frappe.get_doc({
|
||||||
"content": content,
|
"doctype": "Course Activity",
|
||||||
"activity_date": frappe.utils.datetime.datetime.now()
|
"enrollment": enrollment,
|
||||||
})
|
"content_type": content_type,
|
||||||
activity.save()
|
"content": content,
|
||||||
frappe.db.commit()
|
"activity_date": frappe.utils.datetime.datetime.now()
|
||||||
|
})
|
||||||
|
activity.save()
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
|
def check_activity_exists(enrollment, content_type, content):
|
||||||
|
activity = frappe.get_all("Course Activity", filters={'enrollment': enrollment, 'content_type': content_type, 'content': content})
|
||||||
|
if activity:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def add_quiz_activity(enrollment, quiz, score, answers):
|
||||||
|
pass
|
||||||
Loading…
x
Reference in New Issue
Block a user