Merge pull request #429 from pateljannat/classes
This commit is contained in:
@@ -46,8 +46,8 @@ repos:
|
|||||||
lms/public/js/lib/.*
|
lms/public/js/lib/.*
|
||||||
)$
|
)$
|
||||||
|
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.9.2
|
rev: 5.0.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
additional_dependencies: ['flake8-bugbear',]
|
additional_dependencies: ['flake8-bugbear',]
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ override_doctype_class = {
|
|||||||
# Hook on document methods and events
|
# Hook on document methods and events
|
||||||
|
|
||||||
doc_events = {
|
doc_events = {
|
||||||
"Discussion Reply": {"after_insert": "lms.lms.utils.create_notification_log"}
|
"Discussion Reply": {"after_insert": "lms.lms.utils.create_notification_log"},
|
||||||
|
"Course Lesson": {"on_update": "lms.lms.doctype.lms_quiz.lms_quiz.update_lesson_info"},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Scheduled Tasks
|
# Scheduled Tasks
|
||||||
@@ -143,6 +144,7 @@ website_route_rules = [
|
|||||||
},
|
},
|
||||||
{"from_route": "/quizzes", "to_route": "batch/quiz_list"},
|
{"from_route": "/quizzes", "to_route": "batch/quiz_list"},
|
||||||
{"from_route": "/quizzes/<quizname>", "to_route": "batch/quiz"},
|
{"from_route": "/quizzes/<quizname>", "to_route": "batch/quiz"},
|
||||||
|
{"from_route": "/classes/<classname>", "to_route": "classes/class"},
|
||||||
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
|
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
|
||||||
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
|
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
|
||||||
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},
|
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},
|
||||||
@@ -165,6 +167,11 @@ website_route_rules = [
|
|||||||
},
|
},
|
||||||
{"from_route": "/users", "to_route": "profiles/profile"},
|
{"from_route": "/users", "to_route": "profiles/profile"},
|
||||||
{"from_route": "/jobs/<job>", "to_route": "jobs/job"},
|
{"from_route": "/jobs/<job>", "to_route": "jobs/job"},
|
||||||
|
{
|
||||||
|
"from_route": "/classes/<classname>/students/<username>",
|
||||||
|
"to_route": "/classes/progress",
|
||||||
|
},
|
||||||
|
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"},
|
||||||
]
|
]
|
||||||
|
|
||||||
website_redirects = [
|
website_redirects = [
|
||||||
|
|||||||
0
lms/lms/doctype/class_course/__init__.py
Normal file
0
lms/lms/doctype/class_course/__init__.py
Normal file
43
lms/lms/doctype/class_course/class_course.json
Normal file
43
lms/lms/doctype/class_course/class_course.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"autoname": "autoincrement",
|
||||||
|
"creation": "2022-11-09 16:23:26.454527",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"course",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "course.title",
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title",
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-11-11 15:51:45.560864",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Class Course",
|
||||||
|
"naming_rule": "Autoincrement",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
9
lms/lms/doctype/class_course/class_course.py
Normal file
9
lms/lms/doctype/class_course/class_course.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2022, Frappe and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class ClassCourse(Document):
|
||||||
|
pass
|
||||||
0
lms/lms/doctype/class_student/__init__.py
Normal file
0
lms/lms/doctype/class_student/__init__.py
Normal file
7
lms/lms/doctype/class_student/class_student.js
Normal file
7
lms/lms/doctype/class_student/class_student.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Copyright (c) 2022, Frappe and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on("Class Student", {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
// }
|
||||||
|
});
|
||||||
51
lms/lms/doctype/class_student/class_student.json
Normal file
51
lms/lms/doctype/class_student/class_student.json
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2022-11-09 16:20:44.602545",
|
||||||
|
"default_view": "List",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"student",
|
||||||
|
"student_name",
|
||||||
|
"username"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "student",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Student",
|
||||||
|
"options": "User",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "student.full_name",
|
||||||
|
"fieldname": "student_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Student Name",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "student.username",
|
||||||
|
"fieldname": "username",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Username",
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-11-15 11:13:39.410578",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Class Student",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
9
lms/lms/doctype/class_student/class_student.py
Normal file
9
lms/lms/doctype/class_student/class_student.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2022, Frappe and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class ClassStudent(Document):
|
||||||
|
pass
|
||||||
9
lms/lms/doctype/class_student/test_class_student.py
Normal file
9
lms/lms/doctype/class_student/test_class_student.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2022, Frappe and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestClassStudent(FrappeTestCase):
|
||||||
|
pass
|
||||||
@@ -33,6 +33,7 @@ class CourseLesson(Document):
|
|||||||
e = frappe.get_doc(doctype_map[section], name)
|
e = frappe.get_doc(doctype_map[section], name)
|
||||||
e.lesson = self.name
|
e.lesson = self.name
|
||||||
e.index_ = index
|
e.index_ = index
|
||||||
|
e.course = self.course
|
||||||
e.save(ignore_permissions=True)
|
e.save(ignore_permissions=True)
|
||||||
index += 1
|
index += 1
|
||||||
self.update_orphan_documents(doctype_map[section], documents)
|
self.update_orphan_documents(doctype_map[section], documents)
|
||||||
@@ -49,6 +50,7 @@ class CourseLesson(Document):
|
|||||||
for name in orphan_documents:
|
for name in orphan_documents:
|
||||||
ex = frappe.get_doc(doctype, name)
|
ex = frappe.get_doc(doctype, name)
|
||||||
ex.lesson = None
|
ex.lesson = None
|
||||||
|
ex.course = None
|
||||||
ex.index_ = 0
|
ex.index_ = 0
|
||||||
ex.index_label = ""
|
ex.index_label = ""
|
||||||
ex.save()
|
ex.save()
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
"assignment",
|
"assignment",
|
||||||
"lesson",
|
"lesson",
|
||||||
"course",
|
"course",
|
||||||
|
"status",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"member",
|
"member",
|
||||||
"member_name"
|
"member_name",
|
||||||
|
"comments"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -59,12 +61,24 @@
|
|||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Not Graded",
|
||||||
|
"fieldname": "status",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Status",
|
||||||
|
"options": "Pass\nFail\nNot Graded"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "comments",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Comments"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"make_attachments_public": 1,
|
"make_attachments_public": 1,
|
||||||
"modified": "2022-10-31 13:18:09.609729",
|
"modified": "2022-11-16 12:11:59.472025",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Lesson Assignment",
|
"name": "Lesson Assignment",
|
||||||
@@ -85,6 +99,19 @@
|
|||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [
|
||||||
|
{
|
||||||
|
"color": "Green",
|
||||||
|
"title": "Pass"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "Orange",
|
||||||
|
"title": "Not Graded"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "Red",
|
||||||
|
"title": "Fail"
|
||||||
|
}
|
||||||
|
],
|
||||||
"title_field": "lesson"
|
"title_field": "lesson"
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,8 @@ class LessonAssignment(Document):
|
|||||||
|
|
||||||
def validate_duplicates(self):
|
def validate_duplicates(self):
|
||||||
if frappe.db.exists(
|
if frappe.db.exists(
|
||||||
"Lesson Assignment", {"lesson": self.lesson, "member": self.member}
|
"Lesson Assignment",
|
||||||
|
{"lesson": self.lesson, "member": self.member, "name": ["!=", self.name]},
|
||||||
):
|
):
|
||||||
lesson_title = frappe.db.get_value("Course Lesson", self.lesson, "title")
|
lesson_title = frappe.db.get_value("Course Lesson", self.lesson, "title")
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
@@ -43,10 +44,18 @@ def get_assignment(lesson):
|
|||||||
assignment = frappe.db.get_value(
|
assignment = frappe.db.get_value(
|
||||||
"Lesson Assignment",
|
"Lesson Assignment",
|
||||||
{"lesson": lesson, "member": frappe.session.user},
|
{"lesson": lesson, "member": frappe.session.user},
|
||||||
["lesson", "member", "assignment"],
|
["lesson", "member", "assignment", "comments", "status"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
assignment.file_name = frappe.db.get_value(
|
assignment.file_name = frappe.db.get_value(
|
||||||
"File", {"file_url": assignment.assignment}, "file_name"
|
"File", {"file_url": assignment.assignment}, "file_name"
|
||||||
)
|
)
|
||||||
return assignment
|
return assignment
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def grade_assignment(name, result, comments):
|
||||||
|
doc = frappe.get_doc("Lesson Assignment", name)
|
||||||
|
doc.status = result
|
||||||
|
doc.comments = comments
|
||||||
|
doc.save()
|
||||||
|
|||||||
0
lms/lms/doctype/lms_class/__init__.py
Normal file
0
lms/lms/doctype/lms_class/__init__.py
Normal file
7
lms/lms/doctype/lms_class/lms_class.js
Normal file
7
lms/lms/doctype/lms_class/lms_class.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Copyright (c) 2022, Frappe and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on("LMS Class", {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
// }
|
||||||
|
});
|
||||||
103
lms/lms/doctype/lms_class/lms_class.json
Normal file
103
lms/lms/doctype/lms_class/lms_class.json
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "format: CLS-{#####}",
|
||||||
|
"creation": "2022-11-09 16:14:05.876933",
|
||||||
|
"default_view": "List",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"title",
|
||||||
|
"start_date",
|
||||||
|
"end_date",
|
||||||
|
"column_break_4",
|
||||||
|
"description",
|
||||||
|
"section_break_6",
|
||||||
|
"students",
|
||||||
|
"courses"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "end_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "End Date",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_4",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_6",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "students",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Students",
|
||||||
|
"options": "Class Student"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "courses",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Courses",
|
||||||
|
"options": "Class Course"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "start_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Start Date",
|
||||||
|
"reqd": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-11-21 10:55:50.067225",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "LMS Class",
|
||||||
|
"naming_rule": "Expression (old style)",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Moderator",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
66
lms/lms/doctype/lms_class/lms_class.py
Normal file
66
lms/lms/doctype/lms_class/lms_class.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
# Copyright (c) 2022, Frappe and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from frappe import _
|
||||||
|
from frappe.utils import cint
|
||||||
|
|
||||||
|
|
||||||
|
class LMSClass(Document):
|
||||||
|
def validate(self):
|
||||||
|
validate_membership(self)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_membership(self):
|
||||||
|
for course in self.courses:
|
||||||
|
for student in self.students:
|
||||||
|
filters = {
|
||||||
|
"doctype": "LMS Batch Membership",
|
||||||
|
"member": student.student,
|
||||||
|
"course": course.course,
|
||||||
|
}
|
||||||
|
if not frappe.db.exists(filters):
|
||||||
|
frappe.get_doc(filters).save()
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def add_student(email, class_name):
|
||||||
|
if not frappe.db.exists("User", email):
|
||||||
|
frappe.throw(_("There is no such user. Please create a user with this Email ID."))
|
||||||
|
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Class Student",
|
||||||
|
"student": email,
|
||||||
|
"student_name": frappe.db.get_value("User", email, "full_name"),
|
||||||
|
"parent": class_name,
|
||||||
|
"parenttype": "LMS Class",
|
||||||
|
"parentfield": "students",
|
||||||
|
}
|
||||||
|
).save()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def remove_student(student, class_name):
|
||||||
|
frappe.db.delete("Class Student", {"student": student, "parent": class_name})
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def update_course(class_name, course, value):
|
||||||
|
if cint(value):
|
||||||
|
doc = frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Class Course",
|
||||||
|
"parent": class_name,
|
||||||
|
"course": course,
|
||||||
|
"parenttype": "LMS Class",
|
||||||
|
"parentfield": "courses",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
doc.save()
|
||||||
|
else:
|
||||||
|
frappe.db.delete("Class Course", {"parent": class_name, "course": course})
|
||||||
|
return True
|
||||||
9
lms/lms/doctype/lms_class/test_lms_class.py
Normal file
9
lms/lms/doctype/lms_class/test_lms_class.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2022, Frappe and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestLMSClass(FrappeTestCase):
|
||||||
|
pass
|
||||||
@@ -9,9 +9,12 @@
|
|||||||
"field_order": [
|
"field_order": [
|
||||||
"title",
|
"title",
|
||||||
"questions",
|
"questions",
|
||||||
"lesson",
|
"section_break_3",
|
||||||
"max_attempts",
|
"max_attempts",
|
||||||
"time"
|
"time",
|
||||||
|
"column_break_5",
|
||||||
|
"lesson",
|
||||||
|
"course"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -46,11 +49,27 @@
|
|||||||
"fieldname": "time",
|
"fieldname": "time",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Time Per Question (in Seconds)"
|
"label": "Time Per Question (in Seconds)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lesson.course",
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_5",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_3",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-08-19 17:54:41.685182",
|
"modified": "2022-11-15 15:36:39.585488",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Quiz",
|
"name": "LMS Quiz",
|
||||||
@@ -69,8 +88,10 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"show_title_field_in_link": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
|
"title_field": "title",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,13 @@ class LMSQuiz(Document):
|
|||||||
return result[0]
|
return result[0]
|
||||||
|
|
||||||
|
|
||||||
|
def update_lesson_info(doc, method):
|
||||||
|
if doc.quiz_id:
|
||||||
|
frappe.db.set_value(
|
||||||
|
"LMS Quiz", doc.quiz_id, {"lesson": doc.name, "course": doc.course}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def quiz_summary(quiz, results):
|
def quiz_summary(quiz, results):
|
||||||
score = 0
|
score = 0
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"member",
|
|
||||||
"member_name",
|
|
||||||
"column_break_3",
|
|
||||||
"quiz",
|
"quiz",
|
||||||
"score",
|
"score",
|
||||||
|
"course",
|
||||||
|
"column_break_3",
|
||||||
|
"member",
|
||||||
|
"member_name",
|
||||||
"section_break_6",
|
"section_break_6",
|
||||||
"result"
|
"result"
|
||||||
],
|
],
|
||||||
@@ -46,7 +47,8 @@
|
|||||||
"fetch_from": "member.full_name",
|
"fetch_from": "member.full_name",
|
||||||
"fieldname": "member_name",
|
"fieldname": "member_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Member Name"
|
"label": "Member Name",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
@@ -55,12 +57,20 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "section_break_6",
|
"fieldname": "section_break_6",
|
||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "quiz.course",
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-10-10 18:57:42.813738",
|
"modified": "2022-11-15 15:27:07.770945",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Quiz Submission",
|
"name": "LMS Quiz Submission",
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ def redirect_to_courses_list():
|
|||||||
def has_course_instructor_role(member=None):
|
def has_course_instructor_role(member=None):
|
||||||
return frappe.db.get_value(
|
return frappe.db.get_value(
|
||||||
"Has Role",
|
"Has Role",
|
||||||
{"parent": member or frappe.session.user, "role": "Course Instructor"},
|
{"parent": member or frappe.session.user, "role": "Instructor"},
|
||||||
"name",
|
"name",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ def can_create_courses(member=None):
|
|||||||
def has_course_moderator_role(member=None):
|
def has_course_moderator_role(member=None):
|
||||||
return frappe.db.get_value(
|
return frappe.db.get_value(
|
||||||
"Has Role",
|
"Has Role",
|
||||||
{"parent": member or frappe.session.user, "role": "Course Moderator"},
|
{"parent": member or frappe.session.user, "role": "Moderator"},
|
||||||
"name",
|
"name",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
0
lms/lms/web_form/class/__init__.py
Normal file
0
lms/lms/web_form/class/__init__.py
Normal file
3
lms/lms/web_form/class/class.js
Normal file
3
lms/lms/web_form/class/class.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
frappe.ready(function () {
|
||||||
|
// bind events here
|
||||||
|
});
|
||||||
87
lms/lms/web_form/class/class.json
Normal file
87
lms/lms/web_form/class/class.json
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"accept_payment": 0,
|
||||||
|
"allow_comments": 0,
|
||||||
|
"allow_delete": 0,
|
||||||
|
"allow_edit": 0,
|
||||||
|
"allow_incomplete": 0,
|
||||||
|
"allow_multiple": 0,
|
||||||
|
"allow_print": 0,
|
||||||
|
"amount": 0.0,
|
||||||
|
"amount_based_on_field": 0,
|
||||||
|
"apply_document_permissions": 0,
|
||||||
|
"button_label": "Save",
|
||||||
|
"creation": "2022-11-11 12:10:29.640675",
|
||||||
|
"custom_css": "",
|
||||||
|
"doc_type": "LMS Class",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Web Form",
|
||||||
|
"idx": 0,
|
||||||
|
"is_standard": 1,
|
||||||
|
"list_columns": [],
|
||||||
|
"login_required": 0,
|
||||||
|
"max_attachment_size": 0,
|
||||||
|
"modified": "2022-11-21 10:56:01.627821",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "class",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"payment_button_label": "Buy Now",
|
||||||
|
"published": 1,
|
||||||
|
"route": "class",
|
||||||
|
"show_attachments": 0,
|
||||||
|
"show_list": 0,
|
||||||
|
"show_sidebar": 0,
|
||||||
|
"success_title": "",
|
||||||
|
"success_url": "/classes",
|
||||||
|
"title": "Class",
|
||||||
|
"web_form_fields": [
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Title",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "start_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Start Date",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "end_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "End Date",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Description",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
lms/lms/web_form/class/class.py
Normal file
6
lms/lms/web_form/class/class.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
# do your magic here
|
||||||
|
pass
|
||||||
@@ -37,3 +37,4 @@ lms.patches.v0_0.set_courses_page_as_home
|
|||||||
lms.patches.v0_0.set_member_in_progress #09-11-2022
|
lms.patches.v0_0.set_member_in_progress #09-11-2022
|
||||||
lms.patches.v0_0.convert_progress_to_float
|
lms.patches.v0_0.convert_progress_to_float
|
||||||
lms.patches.v0_0.add_pages_to_nav #11-11-2022
|
lms.patches.v0_0.add_pages_to_nav #11-11-2022
|
||||||
|
lms.patches.v0_0.change_role_names
|
||||||
|
|||||||
6
lms/patches/v0_0/change_role_names.py
Normal file
6
lms/patches/v0_0/change_role_names.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.rename_doc("Role", "Course Instructor", "Instructor")
|
||||||
|
frappe.rename_doc("Role", "Course Moderator", "Moderator")
|
||||||
@@ -152,7 +152,8 @@ def assignment_renderer(detail):
|
|||||||
file_type = detail.split("-")[1]
|
file_type = detail.split("-")[1]
|
||||||
accept = supported_types[file_type] if file_type else ""
|
accept = supported_types[file_type] if file_type else ""
|
||||||
return frappe.render_template(
|
return frappe.render_template(
|
||||||
"templates/assignment.html", {"question": question, "accept": accept}
|
"templates/assignment.html",
|
||||||
|
{"question": question, "accept": accept, "file_type": file_type},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,14 @@ frappe.ready(() => {
|
|||||||
save_chapter(e);
|
save_chapter(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".nav-link").click((e) => {
|
||||||
|
change_hash(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.location.hash) {
|
||||||
|
open_tab();
|
||||||
|
}
|
||||||
|
|
||||||
if (window.location.pathname == "/statistics") {
|
if (window.location.pathname == "/statistics") {
|
||||||
generate_graph("New Signups", "#new-signups");
|
generate_graph("New Signups", "#new-signups");
|
||||||
generate_graph("Course Enrollments", "#course-enrollments");
|
generate_graph("Course Enrollments", "#course-enrollments");
|
||||||
@@ -210,3 +218,11 @@ const generate_course_completion_graph = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const change_hash = (e) => {
|
||||||
|
window.location.hash = $(e.currentTarget).attr("href");
|
||||||
|
};
|
||||||
|
|
||||||
|
const open_tab = () => {
|
||||||
|
$(`a[href="${window.location.hash}"]`).click();
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="">
|
<div class="">
|
||||||
<h3> {{ _("Assignment") }} </h3>
|
<h2 class="mt-5 mb-8"> {{ _("Assignment") }} </h2>
|
||||||
<div class="my-3"> {{ _(question) }} </div>
|
<div class="my-3"> {{ _(question) }} </div>
|
||||||
<input class="btn btn-default btn-sm border attach-file" type="file" accept="{{ accept }}" />
|
<div class="alert alert-info small">
|
||||||
<div class="btn btn-secondary ml-2 submit-work">{{ _("Submit") }}</div>
|
{{ _("Only files of type {0} will be accepted.").format(file_type) }}
|
||||||
<div class="preview-work hide">
|
</div>
|
||||||
<a target="_blank"></a>
|
<input class="btn btn-default btn-sm border attach-file" type="file" accept="{{ accept }}" />
|
||||||
<div class="btn btn-secondary btn-sm ml-2 clear-work">{{ _("Change") }}</div>
|
<div class="btn btn-secondary ml-2 submit-work">{{ _("Submit") }}</div>
|
||||||
</div>
|
<div class="preview-work hide">
|
||||||
</div>
|
<a target="_blank"></a>
|
||||||
|
<div class="assignment-status indicator-pill ml-3"></div>
|
||||||
|
<div class="btn btn-secondary btn-sm ml-2 clear-work">{{ _("Change") }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="comments mt-3 hide">
|
||||||
|
<span class="subheading">
|
||||||
|
{{ _("Instructors Comments") }}:
|
||||||
|
</span>
|
||||||
|
<span class="comment"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,114 +1,117 @@
|
|||||||
{% if attempts_exceeded %}
|
{% if attempts_exceeded %}
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="font-weight-bold mb-4" style="font-size: var(--text-lg);">{{ quiz.title }}</div>
|
<h2 class="mt-3">
|
||||||
<div class="alert alert-info medium mb-0">
|
{{ quiz.title }}
|
||||||
{{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }}
|
</h2>
|
||||||
{{ _("Your latest score is {0}.").format(last_attempt_score) }}
|
<div class="alert alert-info medium mb-0">
|
||||||
</div>
|
{{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }}
|
||||||
|
{{ _("Your latest score is {0}.").format(last_attempt_score) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div id="quiz-title" class="hide" data-name="{{ quiz.name }}" data-max-attempts="{{ quiz.max_attempts }}">
|
|
||||||
{{ quiz.title }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<div id="start-banner">
|
<div id="start-banner">
|
||||||
<button class="btn btn-secondary btn-sm btn-start-quiz pull-right"> {{ _("Start the Quiz") }} </button>
|
<button class="btn btn-secondary btn-sm btn-start-quiz pull-right">
|
||||||
|
{{ _("Start the Quiz") }}
|
||||||
|
</button>
|
||||||
|
|
||||||
<div class="font-weight-bold mb-5" style="font-size: var(--text-lg);"> {{ quiz.title }} </div>
|
<h2 class="mt-3" id="quiz-title" data-name="{{ quiz.name }}" data-max-attempts="{{ quiz.max_attempts }}">
|
||||||
|
{{ quiz.title }}
|
||||||
|
</h2>
|
||||||
|
|
||||||
<div class="alert alert-info medium">
|
<div class="alert alert-info medium">
|
||||||
{{ _("This quiz consists of {0} questions.").format(quiz.questions | length) }}
|
{{ _("This quiz consists of {0} questions.").format(quiz.questions | length) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if quiz.max_attempts %}
|
{% if quiz.max_attempts %}
|
||||||
{% set suffix = "times" if quiz.max_attempts > 1 else "time" %}
|
{% set suffix = "times" if quiz.max_attempts > 1 else "time" %}
|
||||||
<div class="alert alert-info medium">
|
<div class="alert alert-info medium">
|
||||||
{{ _("This quiz can only be taken {0} {1}. If you attempt the quiz but leave the page before submitting,
|
{{ _("This quiz can only be taken {0} {1}. If you attempt the quiz but leave the page before submitting,
|
||||||
the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }}
|
the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if quiz.time %}
|
{% if quiz.time %}
|
||||||
<div class="alert alert-info medium">
|
<div class="alert alert-info medium">
|
||||||
{{ _("The quiz has a time limit. For each question you will be given {0} seconds.").format(quiz.time) }}
|
{{ _("The quiz has a time limit. For each question you will be given {0} seconds.").format(quiz.time) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="quiz-form" class="hide">
|
<form id="quiz-form" class="hide">
|
||||||
<div class="questions">
|
<div class="questions">
|
||||||
{% for question in quiz.questions %}
|
{% for question in quiz.questions %}
|
||||||
{% set instruction = _("Choose all answers that apply") if question.multiple else _("Choose 1 answer") %}
|
{% set instruction = _("Choose all answers that apply") if question.multiple else _("Choose 1 answer") %}
|
||||||
|
|
||||||
<div class="question hide"
|
<div class="question hide"
|
||||||
data-question="{{ question.question }}" data-multi="{{ question.multiple }}" data-qt-index="{{ loop.index }}">
|
data-question="{{ question.question }}" data-multi="{{ question.multiple }}" data-qt-index="{{ loop.index }}">
|
||||||
<div class="question-header">
|
<div class="question-header">
|
||||||
<div class="question-number">{{ loop.index }}. </div>
|
<div class="question-number">{{ loop.index }}. </div>
|
||||||
<div class="question-text">
|
<div class="question-text">
|
||||||
{{ frappe.utils.md_to_html(question.question) }}
|
{{ frappe.utils.md_to_html(question.question) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="small"> {{ instruction }} </div>
|
<div class="small"> {{ instruction }} </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
|
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
|
||||||
{% for option in options %}
|
{% for option in options %}
|
||||||
{% if option %}
|
{% if option %}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<div class="custom-checkbox">
|
<div class="custom-checkbox">
|
||||||
<label class="quiz-label">
|
<label class="quiz-label">
|
||||||
<div class="course-meta font-weight-bold"> {{ convert_number_to_character(loop.index - 1) }}</div>
|
<div class="course-meta font-weight-bold"> {{ convert_number_to_character(loop.index - 1) }}</div>
|
||||||
<input class="option" value="{{ option | urlencode }}"
|
<input class="option" value="{{ option | urlencode }}"
|
||||||
data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
|
data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
|
||||||
type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
|
type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
|
||||||
<div class="option-text">{{ frappe.utils.md_to_html(option) }}</div>
|
<div class="option-text">{{ frappe.utils.md_to_html(option) }}</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% set explanation = question['explanation_' + loop.index | string] %}
|
{% set explanation = question['explanation_' + loop.index | string] %}
|
||||||
{% if explanation %}
|
{% if explanation %}
|
||||||
<small class="explanation ml-10 hide">{{ explanation }}</small>
|
<small class="explanation ml-10 hide">{{ explanation }}</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="quiz-footer">
|
<div class="quiz-footer">
|
||||||
<span class="font-weight-bold"> <span class="current-question">1</span> of {{ quiz.questions | length }}</span>
|
<span class="font-weight-bold"> <span class="current-question">1</span> of {{ quiz.questions | length }}</span>
|
||||||
|
|
||||||
{% if quiz.time %}
|
{% if quiz.time %}
|
||||||
<div class="progress timer w-75" data-time="{{ quiz.time }}">
|
<div class="progress timer w-75" data-time="{{ quiz.time }}">
|
||||||
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0"
|
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0"
|
||||||
aria-valuemax="100"style="width:100%">
|
aria-valuemax="100"style="width:100%">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<button class="button pull-right is-default" id="check" disabled>
|
<button class="button pull-right is-default" id="check" disabled>
|
||||||
{{ _("Check") }}
|
{{ _("Check") }}
|
||||||
</button>
|
</button>
|
||||||
<div class="button is-secondary hide" id="next">
|
<div class="button is-secondary hide" id="next">
|
||||||
{{ _("Next Question") }}
|
{{ _("Next Question") }}
|
||||||
</div>
|
</div>
|
||||||
<div class="button is-secondary is-default hide" id="summary">
|
<div class="button is-secondary is-default hide" id="summary">
|
||||||
{{ _("Submit") }}
|
{{ _("Submit") }}
|
||||||
</div>
|
</div>
|
||||||
<small id="submission-message" class="font-weight-bold hide">
|
<small id="submission-message" class="font-weight-bold hide">
|
||||||
{{ _("Please join the course to submit the Quiz.") }}
|
{{ _("Please join the course to submit the Quiz.") }}
|
||||||
</small>
|
</small>
|
||||||
<div class="button is-secondary hide" id="try-again">
|
<div class="button is-secondary hide" id="try-again">
|
||||||
{{ _("Try Again") }}
|
{{ _("Try Again") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
0
lms/www/assignments/__init__.py
Normal file
0
lms/www/assignments/__init__.py
Normal file
63
lms/www/assignments/assignment.html
Normal file
63
lms/www/assignments/assignment.html
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
{% extends "templates/base.html" %}
|
||||||
|
{% block title %}
|
||||||
|
{{ _("Assignments") }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="common-page-style">
|
||||||
|
<div class="container">
|
||||||
|
<div class="common-card-style column-card">
|
||||||
|
<div class="course-home-headings"> {{ _("Assignment Grading") }} </div>
|
||||||
|
<div class="medium w-50 mt-3">
|
||||||
|
<a class="btn btn-secondary btn-sm" href="{{ assignment.assignment }}" target="_blank">
|
||||||
|
{{ _("Open Attachment") }}
|
||||||
|
</a>
|
||||||
|
<select class="btn btn-secondary btn-sm ml-2 lms-menu" id="result" data-type="{{ assignment.status }}">
|
||||||
|
<option selected> {{ _("Not Graded") }} </option>
|
||||||
|
<option value="Pass"> {{ _("Pass") }} </option>
|
||||||
|
<option value="Fail"> {{ _("Fail") }} </option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div class="mt-3">
|
||||||
|
<span class="subheading">
|
||||||
|
{{ _("Member") }}:
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{ assignment.member_name }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3">
|
||||||
|
{% set course_title = frappe.db.get_value("LMS Course", assignment.course, "title") %}
|
||||||
|
<span class="subheading">
|
||||||
|
{{ _("Course") }}:
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{ course_title }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3">
|
||||||
|
{% set lesson_title = frappe.db.get_value("Course Lesson", assignment.lesson, "title") %}
|
||||||
|
<span class="subheading"> {{ _("Lesson") }}: </span>
|
||||||
|
<span>
|
||||||
|
{{ lesson_title }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="subheading mt-3"> {{ _("Comments") }}: </div>
|
||||||
|
<div class="control-input-wrapper">
|
||||||
|
<div class="control-input">
|
||||||
|
<textarea type="text" class="input-with-feedback form-control" id="comments" spellcheck="false"
|
||||||
|
autocomplete="off" placeholder="Comments">{% if assignment.comments %}{{ assignment.comments }}{% endif %}
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="btn btn-primary btn-sm mt-3" id="save-assignment" data-assignment="{{ assignment.name }}">
|
||||||
|
{{ _("Save") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
46
lms/www/assignments/assignment.js
Normal file
46
lms/www/assignments/assignment.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
frappe.ready(() => {
|
||||||
|
this.result;
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
set_result();
|
||||||
|
|
||||||
|
$("#save-assignment").click((e) => {
|
||||||
|
save_assignment(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#result").change((e) => {
|
||||||
|
$("#result option:selected").each(function () {
|
||||||
|
self.result = $(this).val();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const set_result = () => {
|
||||||
|
let self = this;
|
||||||
|
let result = $("#result").data("type");
|
||||||
|
if (result) {
|
||||||
|
$("#result option").each((i, elem) => {
|
||||||
|
if ($(elem).val() == result) {
|
||||||
|
$(elem).attr("selected", true);
|
||||||
|
self.result = result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const save_assignment = (e) => {
|
||||||
|
frappe.call({
|
||||||
|
method: "lms.lms.doctype.lesson_assignment.lesson_assignment.grade_assignment",
|
||||||
|
args: {
|
||||||
|
name: $(e.currentTarget).data("assignment"),
|
||||||
|
result: self.result,
|
||||||
|
comments: $("#comments").val(),
|
||||||
|
},
|
||||||
|
callback: (data) => {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: __("Saved"),
|
||||||
|
indicator: "green",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
22
lms/www/assignments/assignment.py
Normal file
22
lms/www/assignments/assignment.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import frappe
|
||||||
|
from lms.lms.utils import has_course_moderator_role
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
context.no_cache = 1
|
||||||
|
assignment = frappe.form_dict["assignment"]
|
||||||
|
|
||||||
|
if not has_course_moderator_role():
|
||||||
|
message = "Only Moderators have access to this page."
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
message = "Please login to access this page."
|
||||||
|
|
||||||
|
raise frappe.PermissionError(_(message))
|
||||||
|
|
||||||
|
context.assignment = frappe.db.get_value(
|
||||||
|
"Lesson Assignment",
|
||||||
|
assignment,
|
||||||
|
["assignment", "comments", "status", "name", "member_name", "course", "lesson"],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
@@ -412,10 +412,24 @@ const fetch_assignments = () => {
|
|||||||
callback: (data) => {
|
callback: (data) => {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
const assignment = data.message;
|
const assignment = data.message;
|
||||||
|
const status = assignment.status;
|
||||||
let target = $(".attach-file");
|
let target = $(".attach-file");
|
||||||
target.addClass("hide");
|
target.addClass("hide");
|
||||||
target.siblings(".submit-work").addClass("hide");
|
target.siblings(".submit-work").addClass("hide");
|
||||||
target.siblings(".preview-work").removeClass("hide");
|
target.siblings(".preview-work").removeClass("hide");
|
||||||
|
if (status != "Not Graded") {
|
||||||
|
let color = status == "Pass" ? "green" : "red";
|
||||||
|
$(".assignment-status")
|
||||||
|
.removeClass("hide")
|
||||||
|
.addClass(color)
|
||||||
|
.text(data.message.status);
|
||||||
|
target.siblings(".alert").addClass("hide");
|
||||||
|
$(".clear-work").addClass("hide");
|
||||||
|
if (assignment.comments) {
|
||||||
|
$(".comments").removeClass("hide");
|
||||||
|
$(".comment").text(assignment.comments);
|
||||||
|
}
|
||||||
|
}
|
||||||
target
|
target
|
||||||
.siblings(".preview-work")
|
.siblings(".preview-work")
|
||||||
.find("a")
|
.find("a")
|
||||||
|
|||||||
146
lms/www/classes/class.html
Normal file
146
lms/www/classes/class.html
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
{% extends "templates/base.html" %}
|
||||||
|
{% block title %}
|
||||||
|
{{ _(class_info.title) }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="common-page-style">
|
||||||
|
<div class="container">
|
||||||
|
{{ BreadCrumb(class_info) }}
|
||||||
|
<div class="common-card-style column-card">
|
||||||
|
{{ ClassDetails(class_info) }}
|
||||||
|
{{ ClassSections(class_info, class_courses, class_students, published_courses) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- BreadCrumb -->
|
||||||
|
{% macro BreadCrumb(class_info) %}
|
||||||
|
<div class="breadcrumb">
|
||||||
|
<a class="dark-links" href="/classes">{{ _("All Classes") }}</a>
|
||||||
|
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||||
|
<span class="breadcrumb-destination">{{ class_info.title }}</span>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Class Details -->
|
||||||
|
{% macro ClassDetails(class_info) %}
|
||||||
|
<div class="class-details" data-class="{{ class_info.name }}">
|
||||||
|
<div class="course-home-headings">
|
||||||
|
{{ class_info.title }}
|
||||||
|
</div>
|
||||||
|
{% if class_info.description %}
|
||||||
|
<div class="medium">
|
||||||
|
{{ class_info.description }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="medium">
|
||||||
|
{% if class_info.start_date %}
|
||||||
|
<span>
|
||||||
|
{{ frappe.utils.format_date(class_info.start_date, "medium") }} -
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if class_info.end_date %}
|
||||||
|
<span>
|
||||||
|
{{ frappe.utils.format_date(class_info.end_date, "medium") }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Class Sections -->
|
||||||
|
{% macro ClassSections(class_info, class_courses, class_students, published_courses) %}
|
||||||
|
<div class="mt-4">
|
||||||
|
<ul class="nav lms-nav" id="classes-tab">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" data-toggle="tab" href="#courses">
|
||||||
|
{{ _("Courses") }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#students">
|
||||||
|
{{ _("Students") }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="border-bottom mb-4"></div>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane active" id="courses" role="tabpanel" aria-labelledby="courses">
|
||||||
|
{{ CoursesSection(class_info, class_courses, published_courses) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="students" role="tabpanel" aria-labelledby="students">
|
||||||
|
{{ StudentsSection(class_info, class_students) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro CoursesSection(class_info, class_courses, published_courses) %}
|
||||||
|
<div class="class-course-list">
|
||||||
|
{% if published_courses | length %}
|
||||||
|
{% for course in published_courses %}
|
||||||
|
{% set checked = course.name in class_courses %}
|
||||||
|
<label class="class-course" data-course="{{ course.name }}">
|
||||||
|
<input type="checkbox" {% if checked %} checked {% endif %}>
|
||||||
|
{{ course.title }}
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro StudentsSection(class_info, class_students) %}
|
||||||
|
<div class="medium">
|
||||||
|
{{ AddStudents() }}
|
||||||
|
|
||||||
|
{% if class_students | length %}
|
||||||
|
<div class="mt-10">
|
||||||
|
{% for student in class_students %}
|
||||||
|
<div class="d-flex" style="position: relative;">
|
||||||
|
<a class="subheading button-links flex-grow-1" href="/classes/{{ class_info.name }}/students/{{ student.username }}">
|
||||||
|
{{ student.student_name }}
|
||||||
|
</a>
|
||||||
|
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}">
|
||||||
|
<use href="#icon-delete"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
{% if not loop.last %} <hr> {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-muted mt-3"> {{ _("No Students are added to this class.") }} </p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro AddStudents() %}
|
||||||
|
<div>
|
||||||
|
<div class="mb-2">
|
||||||
|
{{ _("Add Student") }}
|
||||||
|
</div>
|
||||||
|
<form>
|
||||||
|
<div class="control-input-wrapper mb-2 w-50">
|
||||||
|
<div class="control-input">
|
||||||
|
<input type="text" autocomplete="off" class="input-with-feedback form-control" id="student-email"
|
||||||
|
spellcheck="false">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary btn-sm" id="submit-student"> {{ _("Add") }} </button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
70
lms/www/classes/class.js
Normal file
70
lms/www/classes/class.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
frappe.ready(() => {
|
||||||
|
$("#submit-student").click((e) => {
|
||||||
|
submit_student(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".remove-student").click((e) => {
|
||||||
|
remove_student(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".class-course").click((e) => {
|
||||||
|
update_course(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const submit_student = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
frappe.call({
|
||||||
|
method: "lms.lms.doctype.lms_class.lms_class.add_student",
|
||||||
|
args: {
|
||||||
|
email: $("#student-email").val(),
|
||||||
|
class_name: $(".class-details").data("class"),
|
||||||
|
},
|
||||||
|
callback: (data) => {
|
||||||
|
frappe.show_alert(
|
||||||
|
{
|
||||||
|
message: __("Student added successfully"),
|
||||||
|
indicator: "green",
|
||||||
|
},
|
||||||
|
3
|
||||||
|
);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const remove_student = (e) => {
|
||||||
|
frappe.confirm(
|
||||||
|
"Are you sure you want to remove this student from the class?",
|
||||||
|
() => {
|
||||||
|
frappe.call({
|
||||||
|
method: "lms.lms.doctype.lms_class.lms_class.remove_student",
|
||||||
|
args: {
|
||||||
|
student: $(e.currentTarget).data("student"),
|
||||||
|
class_name: $(".class-details").data("class"),
|
||||||
|
},
|
||||||
|
callback: (data) => {
|
||||||
|
frappe.show_alert(
|
||||||
|
{
|
||||||
|
message: __("Student removed successfully"),
|
||||||
|
indicator: "green",
|
||||||
|
},
|
||||||
|
3
|
||||||
|
);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const update_course = (e) => {
|
||||||
|
frappe.call({
|
||||||
|
method: "lms.lms.doctype.lms_class.lms_class.update_course",
|
||||||
|
args: {
|
||||||
|
course: $(e.currentTarget).data("course"),
|
||||||
|
value: $(e.currentTarget).children("input").prop("checked") ? 1 : 0,
|
||||||
|
class_name: $(".class-details").data("class"),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
34
lms/www/classes/class.py
Normal file
34
lms/www/classes/class.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import frappe
|
||||||
|
from lms.lms.utils import has_course_moderator_role
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
context.no_cache = 1
|
||||||
|
|
||||||
|
if not has_course_moderator_role():
|
||||||
|
message = "Only Moderators have access to this page."
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
message = "Please login to access this page."
|
||||||
|
|
||||||
|
raise frappe.PermissionError(_(message))
|
||||||
|
|
||||||
|
class_name = frappe.form_dict["classname"]
|
||||||
|
|
||||||
|
context.class_info = frappe.db.get_value(
|
||||||
|
"LMS Class",
|
||||||
|
class_name,
|
||||||
|
["name", "title", "start_date", "end_date", "description"],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
context.published_courses = frappe.get_all(
|
||||||
|
"LMS Course", {"published": 1}, ["name", "title"]
|
||||||
|
)
|
||||||
|
|
||||||
|
context.class_courses = frappe.get_all(
|
||||||
|
"Class Course", {"parent": class_name}, pluck="course"
|
||||||
|
)
|
||||||
|
|
||||||
|
context.class_students = frappe.get_all(
|
||||||
|
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
|
||||||
|
)
|
||||||
66
lms/www/classes/index.html
Normal file
66
lms/www/classes/index.html
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
{% extends "templates/base.html" %}
|
||||||
|
{% block title %}
|
||||||
|
{{ _("All Classes") }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="common-page-style">
|
||||||
|
<div class="container">
|
||||||
|
<a class="btn btn-default btn-sm pull-right" href="/class/new">
|
||||||
|
{{ _("Create Class") }}
|
||||||
|
</a>
|
||||||
|
<div class="course-home-headings"> {{ _("All Classes") }} </div>
|
||||||
|
{% if classes %}
|
||||||
|
{{ ClassCards(classes) }}
|
||||||
|
{% else %}
|
||||||
|
<div class="empty-state">
|
||||||
|
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
|
||||||
|
<div class="empty-state-text">
|
||||||
|
<div class="empty-state-heading">{{ _("No Classes") }}</div>
|
||||||
|
<div class="course-meta">{{ _("Nothing to see here.") }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro ClassCards(classes) %}
|
||||||
|
<div class="cards-parent">
|
||||||
|
{% for class in classes %}
|
||||||
|
{% set course_count = frappe.db.count("Class Course", {"parent": class.name}) %}
|
||||||
|
{% set student_count = frappe.db.count("Class Student", {"parent": class.name}) %}
|
||||||
|
|
||||||
|
<div class="common-card-style column-card">
|
||||||
|
<div class="text-muted small">
|
||||||
|
{% if course_count %}
|
||||||
|
<span>
|
||||||
|
{{ course_count }} {{ _("Courses") }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if student_count %}
|
||||||
|
<span class="ml-3">
|
||||||
|
{{ student_count }} {{ _("Students") }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="course-card-title mb-4">
|
||||||
|
{{ class.title }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="">
|
||||||
|
<span>
|
||||||
|
{{ frappe.utils.format_date(class.start_date, "medium") }} -
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{ frappe.utils.format_date(class.end_date, "medium") }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<a class="stretched-link" href="/classes/{{ class.name }}"></a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
18
lms/www/classes/index.py
Normal file
18
lms/www/classes/index.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import frappe
|
||||||
|
from lms.lms.utils import has_course_moderator_role
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
context.no_cache = 1
|
||||||
|
|
||||||
|
if not has_course_moderator_role():
|
||||||
|
message = "Only Moderators have access to this page."
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
message = "Please login to access this page."
|
||||||
|
|
||||||
|
raise frappe.PermissionError(_(message))
|
||||||
|
|
||||||
|
context.classes = frappe.get_all(
|
||||||
|
"LMS Class", fields=["name", "title", "start_date", "end_date"]
|
||||||
|
)
|
||||||
144
lms/www/classes/progress.html
Normal file
144
lms/www/classes/progress.html
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
{% extends "templates/base.html" %}
|
||||||
|
{% block title %}
|
||||||
|
{{ student.first_name }} 's {{ _("Progress") }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="common-page-style">
|
||||||
|
<div class="container">
|
||||||
|
{{ BreadCrumb(class_info, student) }}
|
||||||
|
<div class="common-card-style column-card">
|
||||||
|
<div class="course-home-headings">
|
||||||
|
{{ student.full_name }}
|
||||||
|
</div>
|
||||||
|
{{ Progress(class_courses, student) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro BreadCrumb(class_info, student) %}
|
||||||
|
<div class="breadcrumb">
|
||||||
|
<a class="dark-links" href="/classes">{{ _("All Classes") }}</a>
|
||||||
|
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||||
|
<a class="dark-links" href="/classes/{{ class_info.name }}">{{ class_info.name }}</a>
|
||||||
|
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||||
|
<span class="breadcrumb-destination">{{ student.full_name }}</span>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro Progress(class_info, student) %}
|
||||||
|
<div>
|
||||||
|
{% for course in class_courses %}
|
||||||
|
{% set progress = course.membership.progress %}
|
||||||
|
<div class="medium">
|
||||||
|
<div class="progress-course-header">
|
||||||
|
<div class="section-heading"> {{ course.title }} </div>
|
||||||
|
<div class="ml-3"> {{ frappe.utils.cint(course.membership.progress) }}% </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if course.quizzes | length or course.assignments | length %}
|
||||||
|
<div class="my-5">
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th style="width: 40%;">
|
||||||
|
{{ _("Activity") }}
|
||||||
|
</th>
|
||||||
|
<th style="width: 20%;">
|
||||||
|
{{ _("Type") }}
|
||||||
|
</th>
|
||||||
|
<th style="width: 20%;">
|
||||||
|
{{ _("Score/Status") }}
|
||||||
|
</th>
|
||||||
|
<th style="width: 20%;">
|
||||||
|
{{ _("Last Attempt Date") }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for quiz in course.quizzes %}
|
||||||
|
{% set filters = { "member": student.name, "course": course.course } %}
|
||||||
|
{% set has_submitted = frappe.db.exists("LMS Quiz Submission", filters) %}
|
||||||
|
{% set submission = frappe.db.get_value("LMS Quiz Submission", filters, ["score", "creation"], as_dict=True) %}
|
||||||
|
{% set total_questions = frappe.db.count("LMS Quiz Question", {"parent": quiz.name}) %}
|
||||||
|
|
||||||
|
<tr class="">
|
||||||
|
<td>
|
||||||
|
{{ quiz.title }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ _("Quiz") }}
|
||||||
|
</td>
|
||||||
|
{% if has_submitted %}
|
||||||
|
<td>
|
||||||
|
{{ submission.score }}/{{ total_questions }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ frappe.utils.format_date(submission.creation, "medium") }}
|
||||||
|
</td>
|
||||||
|
{% else %}
|
||||||
|
<td>
|
||||||
|
-
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="indicator-pill red">
|
||||||
|
{{ _("Not Attempted") }}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for assignment in course.assignments %}
|
||||||
|
|
||||||
|
{% set filters = { "member": student.name, "course": course.course, "lesson": assignment.name } %}
|
||||||
|
{% set has_submitted = frappe.db.exists("Lesson Assignment", filters) %}
|
||||||
|
{% set submission = frappe.db.get_value("Lesson Assignment", filters, ["assignment", "creation", "status"], as_dict=True) %}
|
||||||
|
{% set status = submission.status %}
|
||||||
|
{% set color = "green" if status == "Pass" else "red" if status == "Fail" else "orange" %}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ assignment.title }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ _("Assignment") }}
|
||||||
|
</td>
|
||||||
|
{% if has_submitted %}
|
||||||
|
<td>
|
||||||
|
{% if status == "Not Graded" %}
|
||||||
|
<a class="btn btn-secondary btn-sm" href="/assignments/{{ has_submitted }}"> {{ _("Grade") }} </a>
|
||||||
|
{% else %}
|
||||||
|
<div class="indicator-pill {{ color }}">
|
||||||
|
{{ status }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ frappe.utils.format_date(submission.creation, "medium") }}
|
||||||
|
</td>
|
||||||
|
{% else %}
|
||||||
|
<td>
|
||||||
|
-
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="indicator-pill red">
|
||||||
|
{{ _("Not Attempted") }}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="text-muted medium my-5">
|
||||||
|
{{ _("There are no activities in this course.") }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
46
lms/www/classes/progress.py
Normal file
46
lms/www/classes/progress.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import frappe
|
||||||
|
from lms.lms.utils import has_course_moderator_role
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
|
def get_context(context):
|
||||||
|
context.no_cache = 1
|
||||||
|
|
||||||
|
if not has_course_moderator_role():
|
||||||
|
message = "Only Moderators have access to this page."
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
message = "Please login to access this page."
|
||||||
|
|
||||||
|
raise frappe.PermissionError(_(message))
|
||||||
|
|
||||||
|
student = frappe.form_dict["username"]
|
||||||
|
classname = frappe.form_dict["classname"]
|
||||||
|
|
||||||
|
context.student = frappe.db.get_value(
|
||||||
|
"User", {"username": student}, ["first_name", "full_name", "name"], as_dict=True
|
||||||
|
)
|
||||||
|
context.class_info = frappe.db.get_value(
|
||||||
|
"LMS Class", classname, ["name"], as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
|
class_courses = frappe.get_all(
|
||||||
|
"Class Course", {"parent": classname}, ["course", "title"]
|
||||||
|
)
|
||||||
|
|
||||||
|
for course in class_courses:
|
||||||
|
course.membership = frappe.db.get_value(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
{"member": context.student.name, "course": course.course},
|
||||||
|
["progress"],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
course.quizzes = frappe.get_all(
|
||||||
|
"LMS Quiz", {"course": course.course}, ["name", "title"]
|
||||||
|
)
|
||||||
|
course.assignments = frappe.get_all(
|
||||||
|
"Course Lesson",
|
||||||
|
{"course": course.course, "question": ["is", "set"]},
|
||||||
|
["name", "title"],
|
||||||
|
)
|
||||||
|
|
||||||
|
context.class_courses = class_courses
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
frappe.ready(() => {
|
|
||||||
$(".nav-link").click((e) => {
|
|
||||||
change_hash(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.location.hash) {
|
|
||||||
open_tab();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const change_hash = (e) => {
|
|
||||||
window.location.hash = $(e.currentTarget).attr("href");
|
|
||||||
};
|
|
||||||
|
|
||||||
const open_tab = () => {
|
|
||||||
$(`a[href="${window.location.hash}"]`).click();
|
|
||||||
};
|
|
||||||
@@ -205,14 +205,14 @@
|
|||||||
<div class="course-home-headings"> {{ _("Role Settings") }} </div>
|
<div class="course-home-headings"> {{ _("Role Settings") }} </div>
|
||||||
<div class="medium">
|
<div class="medium">
|
||||||
<label class="role">
|
<label class="role">
|
||||||
<input type="checkbox" id="instructor" data-role="Course Instructor"
|
<input type="checkbox" id="instructor" data-role="Instructor"
|
||||||
{% if has_course_instructor_role(member.name) %} checked {% endif %}>
|
{% if has_course_instructor_role(member.name) %} checked {% endif %}>
|
||||||
{{ _("Course Instructor") }}
|
{{ _("Instructor") }}
|
||||||
</label>
|
</label>
|
||||||
<label class="role">
|
<label class="role">
|
||||||
<input type="checkbox" id="moderator" data-role="Course Moderator"
|
<input type="checkbox" id="moderator" data-role="Moderator"
|
||||||
{% if has_course_moderator_role(member.name) %} checked {% endif %}>
|
{% if has_course_moderator_role(member.name) %} checked {% endif %}>
|
||||||
{{ _("Course Moderator") }}
|
{{ _("Moderator") }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,14 +4,6 @@ frappe.ready(() => {
|
|||||||
$(".role").change((e) => {
|
$(".role").change((e) => {
|
||||||
save_role(e);
|
save_role(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".nav-link").click((e) => {
|
|
||||||
change_hash(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.location.hash) {
|
|
||||||
open_tab();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const make_profile_active_in_navbar = () => {
|
const make_profile_active_in_navbar = () => {
|
||||||
@@ -46,11 +38,3 @@ const save_role = (e) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const change_hash = (e) => {
|
|
||||||
window.location.hash = $(e.currentTarget).attr("href");
|
|
||||||
};
|
|
||||||
|
|
||||||
const open_tab = () => {
|
|
||||||
$(`a[href="${window.location.hash}"]`).click();
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user