Course Activity linked to Student ID

This commit is contained in:
scmmishra 2018-10-15 11:45:17 +05:30 committed by Aditya Hase
parent 38c1baf719
commit 17294e703e
3 changed files with 41 additions and 8 deletions

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -235,12 +236,12 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"set_only_once": 1,
"translatable": 0,
"unique": 0
},
@ -267,7 +268,7 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@ -287,7 +288,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-10-12 13:06:17.568571",
"modified": "2018-10-12 16:14:21.510581",
"modified_by": "Administrator",
"module": "Education",
"name": "LMS Activity",

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
@ -1187,7 +1188,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-08-21 14:44:35.278833",
"modified": "2018-10-12 16:46:31.504987",
"modified_by": "Administrator",
"module": "Education",
"name": "Student",
@ -1231,6 +1232,25 @@
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Student",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 0
}
],
"quick_entry": 0,

View File

@ -92,7 +92,7 @@ def add_activity(content_type, **kwargs):
if activity_does_not_exists:
current_activity = frappe.get_doc({
"doctype": "Student Course Activity",
"student_id": frappe.session.user,
"student_id": get_student_id(frappe.session.user),
"program_name": kwargs.get('program'),
"lms_activity": [{
"course_name": kwargs.get('course'),
@ -131,8 +131,20 @@ def add_activity(content_type, **kwargs):
def check_entry_exists(program):
try:
activity_name = frappe.get_all("Student Course Activity", filters={"student_id": frappe.session.user, "program_name": program})[0]
activity_name = frappe.get_all("Student Course Activity", filters={"student_id": get_student_id(frappe.session.user), "program_name": program})[0]
except IndexError:
print("------ Got No Doc ------")
return True, None
else:
print("------ Got A Doc ------")
return None, frappe.get_doc("Student Course Activity", activity_name)
def get_student_id(email):
"""Returns Student ID, example EDU-STU-2018-00001 from email address
:params email: email address of the student"""
try:
student = frappe.get_list('Student', filters={'student_email_id': email})[0].name
return student
except IndexError:
frappe.throw("Student Account with email:{0} does not exist".format(email))