diff --git a/lms/hooks.py b/lms/hooks.py index 15ce3873..ea03c729 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -159,7 +159,8 @@ website_route_rules = [ {"from_route": "/users", "to_route": "profiles/profile"}, {"from_route": "/jobs/", "to_route": "jobs/job"}, {"from_route": "/classes//students/", - "to_route": "/classes/progress"} + "to_route": "/classes/progress"}, + {"from_route": "/assignments/", "to_route": "assignments/assignment"} ] website_redirects = [ diff --git a/lms/lms/doctype/lesson_assignment/lesson_assignment.json b/lms/lms/doctype/lesson_assignment/lesson_assignment.json index 18e41b8a..46f316f3 100644 --- a/lms/lms/doctype/lesson_assignment/lesson_assignment.json +++ b/lms/lms/doctype/lesson_assignment/lesson_assignment.json @@ -9,9 +9,11 @@ "assignment", "lesson", "course", + "status", "column_break_3", "member", - "member_name" + "member_name", + "comments" ], "fields": [ { @@ -59,12 +61,24 @@ "in_standard_filter": 1, "label": "Course", "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, "links": [], "make_attachments_public": 1, - "modified": "2022-10-31 13:18:09.609729", + "modified": "2022-11-16 12:11:59.472025", "modified_by": "Administrator", "module": "LMS", "name": "Lesson Assignment", @@ -85,6 +99,19 @@ ], "sort_field": "modified", "sort_order": "DESC", - "states": [], + "states": [ + { + "color": "Green", + "title": "Pass" + }, + { + "color": "Orange", + "title": "Not Graded" + }, + { + "color": "Red", + "title": "Fail" + } + ], "title_field": "lesson" } \ No newline at end of file diff --git a/lms/lms/doctype/lesson_assignment/lesson_assignment.py b/lms/lms/doctype/lesson_assignment/lesson_assignment.py index 8c61faa2..426ee0ae 100644 --- a/lms/lms/doctype/lesson_assignment/lesson_assignment.py +++ b/lms/lms/doctype/lesson_assignment/lesson_assignment.py @@ -12,7 +12,7 @@ class LessonAssignment(Document): def validate_duplicates(self): 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") frappe.throw( diff --git a/lms/plugins.py b/lms/plugins.py index 0c9bdb63..f20f94dc 100644 --- a/lms/plugins.py +++ b/lms/plugins.py @@ -152,7 +152,7 @@ def assignment_renderer(detail): file_type = detail.split("-")[1] accept = supported_types[file_type] if file_type else "" return frappe.render_template( - "templates/assignment.html", {"question": question, "accept": accept} + "templates/assignment.html", {"question": question, "accept": accept, "file_type": file_type} ) diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 94c7ead0..5c7b7ca2 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -1841,10 +1841,8 @@ select { .progress-course-header { display: flex; - justify-content: space-between; background-color: var(--gray-100); padding: 0.5rem; - border-radius: var(--border-radius-sm); } .section-heading { @@ -1852,3 +1850,9 @@ select { color: var(--gray-900); font-weight: 500; } + +.table th { + color: var(--gray-900); + font-weight: 500; + border-bottom: 1px solid var(--gray-300); +} diff --git a/lms/templates/assignment.html b/lms/templates/assignment.html index f32fcb99..a0f04659 100644 --- a/lms/templates/assignment.html +++ b/lms/templates/assignment.html @@ -1,12 +1,15 @@
-
-

{{ _("Assignment") }}

-
{{ _(question) }}
- -
{{ _("Submit") }}
-
- -
{{ _("Change") }}
-
-
+
+

{{ _("Assignment") }}

+
{{ _(question) }}
+
+ {{ _("Only files of type {0} will be accepted").format(file_type) }} +
+ +
{{ _("Submit") }}
+
+ +
{{ _("Change") }}
+
+
diff --git a/lms/www/assignments/assignment.html b/lms/www/assignments/assignment.html new file mode 100644 index 00000000..7165a6c8 --- /dev/null +++ b/lms/www/assignments/assignment.html @@ -0,0 +1,36 @@ +{% extends "templates/base.html" %} +{% block title %} + {{ _("Assignments") }} +{% endblock %} + + +{% block content %} +
+
+
+
{{ _("Save") }}
+
{{ _("Assignments") }}
+
+
+ +
+ +
+
+
+
{% if assignment.comments %}{{ assignment.comments }}{% endif %}
+
+
+
+
+
+{% endblock %} diff --git a/lms/www/assignments/assignment.py b/lms/www/assignments/assignment.py new file mode 100644 index 00000000..ebf38eed --- /dev/null +++ b/lms/www/assignments/assignment.py @@ -0,0 +1,16 @@ +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"], as_dict=True) diff --git a/lms/www/classes/class.py b/lms/www/classes/class.py index 2ccc3c77..7eda4d07 100644 --- a/lms/www/classes/class.py +++ b/lms/www/classes/class.py @@ -1,6 +1,7 @@ import frappe from lms.lms.utils import has_course_moderator_role from frappe import _ +from lms.lms.utils import has_course_moderator_role def get_context(context): diff --git a/lms/www/classes/progress.html b/lms/www/classes/progress.html index 78908e2d..0fdacccc 100644 --- a/lms/www/classes/progress.html +++ b/lms/www/classes/progress.html @@ -36,40 +36,106 @@
{{ course.title }}
-
{{ frappe.utils.cint(course.membership.progress) }}%
+
{{ frappe.utils.cint(course.membership.progress) }}%
- - {% for quiz in course.quizzes %} - - {% set filters = { "member": student.name, "course": course.course } %} - {% set submitted = frappe.db.exists("LMS Quiz Submission", filters) %} - {% set score = frappe.db.get_value("LMS Quiz Submission", filters, ["score"]) %} - + {% if course.quizzes | length or course.assignments | length %}
-
{{ _("Quiz") }}:
-
-
- {{ quiz.title }} -
- {% if submitted %} -
- {{ score }} -
- {% else %} -
- Not Attempted -
- {% endif %} -
-
+ + + + + + + + {% for quiz in course.quizzes %} - {% endfor %} - {% for quiz in class_courses.assignments %} -
- {{ assignments.assignment }} + {% 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) %} + +
+ + + {% if has_submitted %} + + + {% else %} + + + {% endif %} + + {% 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" %} + + + + + {% if has_submitted %} + + + {% else %} + + + {% endif %} + + {% endfor %} +
+ {{ _("Activity") }} + + {{ _("Type") }} + + {{ _("Score/Status") }} + + {{ _("Last Attempt Date") }} +
+ {{ quiz.title }} + + {{ _("Quiz") }} + + {{ submission.score }} + + {{ frappe.utils.format_date(submission.creation, "medium") }} + + - + +
+ {{ _("Not Attempted") }} +
+
+ {{ assignment.title }} + + {{ _("Assignment") }} + + {% if status == "Not Graded" %} + {{ _("Grade") }} + {% else %} +
+ {{ status }} +
+ {% endif %} +
+ {{ frappe.utils.format_date(submission.creation, "medium") }} + + - + +
+ {{ _("Not Attempted") }} +
+
- {% endfor %} + {% else %} +
+ {{ _("There are no activities in this course.") }} +
+ {% endif %} {% endfor %} diff --git a/lms/www/classes/progress.py b/lms/www/classes/progress.py index d5049332..ba2fd726 100644 --- a/lms/www/classes/progress.py +++ b/lms/www/classes/progress.py @@ -1,9 +1,17 @@ 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"] @@ -20,7 +28,6 @@ def get_context(context): "course": course.course }, ["progress"], as_dict=True) course.quizzes = frappe.get_all("LMS Quiz", {"course": course.course}, ["name", "title"]) - course.assignments = frappe.get_all("Lesson Assignment", {"course": course.course}, ["name", "assignment"]) + course.assignments = frappe.get_all("Course Lesson", {"course": course.course, "question": ["is", "set"]}, ["name", "title"]) - print(class_courses) context.class_courses = class_courses