From 99f1a8dfc3294b49afcc5de9887c0d66fd826a0d Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 23 Jun 2023 20:16:48 +0530 Subject: [PATCH] fix: class improvements --- .../lms_assignment/lms_assignment.json | 17 +- lms/lms/doctype/lms_class/lms_class.json | 5 +- lms/lms/doctype/lms_class/lms_class.py | 4 + lms/lms/doctype/lms_quiz/lms_quiz.json | 14 +- lms/lms/utils.py | 20 ++ lms/lms/widgets/CourseCard.html | 3 + lms/public/css/style.css | 28 +- lms/public/js/common_functions.js | 1 + lms/www/classes/class.html | 319 +++++++++++------- lms/www/classes/class.js | 88 +++-- lms/www/classes/class.py | 122 +++++-- lms/www/classes/index.html | 38 +-- lms/www/classes/progress.html | 1 - lms/www/courses/index.py | 1 + lms/www/people/index.html | 2 +- 15 files changed, 463 insertions(+), 200 deletions(-) diff --git a/lms/lms/doctype/lms_assignment/lms_assignment.json b/lms/lms/doctype/lms_assignment/lms_assignment.json index e7659c04..0dde9649 100644 --- a/lms/lms/doctype/lms_assignment/lms_assignment.json +++ b/lms/lms/doctype/lms_assignment/lms_assignment.json @@ -46,7 +46,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-05-29 14:50:55.259990", + "modified": "2023-06-23 12:34:21.314971", "modified_by": "Administrator", "module": "LMS", "name": "LMS Assignment", @@ -64,9 +64,22 @@ "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": [] + "states": [], + "title_field": "title" } \ No newline at end of file diff --git a/lms/lms/doctype/lms_class/lms_class.json b/lms/lms/doctype/lms_class/lms_class.json index 6a69486d..3f3b61e3 100644 --- a/lms/lms/doctype/lms_class/lms_class.json +++ b/lms/lms/doctype/lms_class/lms_class.json @@ -50,7 +50,8 @@ { "fieldname": "description", "fieldtype": "Small Text", - "label": "Description" + "label": "Description", + "reqd": 1 }, { "fieldname": "section_break_6", @@ -137,7 +138,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-06-15 12:30:26.929156", + "modified": "2023-06-22 15:57:25.190084", "modified_by": "Administrator", "module": "LMS", "name": "LMS Class", diff --git a/lms/lms/doctype/lms_class/lms_class.py b/lms/lms/doctype/lms_class/lms_class.py index 634f41e6..5c7a3cae 100644 --- a/lms/lms/doctype/lms_class/lms_class.py +++ b/lms/lms/doctype/lms_class/lms_class.py @@ -8,6 +8,7 @@ from frappe.utils import cint, format_date, format_datetime import requests import base64 import json +from lms.lms.utils import has_course_moderator_role class LMSClass(Document): @@ -188,6 +189,9 @@ def create_class( @frappe.whitelist() def update_assessment(type, name, value, class_name): + if not has_course_moderator_role(): + return + value = cint(value) filters = { "assessment_type": type, diff --git a/lms/lms/doctype/lms_quiz/lms_quiz.json b/lms/lms/doctype/lms_quiz/lms_quiz.json index 7f3a8d48..39e9b282 100644 --- a/lms/lms/doctype/lms_quiz/lms_quiz.json +++ b/lms/lms/doctype/lms_quiz/lms_quiz.json @@ -70,7 +70,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-06-21 09:13:01.322701", + "modified": "2023-06-23 12:35:25.204131", "modified_by": "Administrator", "module": "LMS", "name": "LMS Quiz", @@ -87,6 +87,18 @@ "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 } ], "show_title_field_in_link": 1, diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 522084fe..6e2d981d 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -733,3 +733,23 @@ def is_onboarding_complete(): if course_created else None, } + + +def has_submitted_assessment(assessment, type, member=None): + if not member: + member = frappe.session.user + + doctype = ( + "LMS Assignment Submission" if type == "LMS Assignment" else "LMS Quiz Submission" + ) + docfield = "assignment" if type == "LMS Assignment" else "quiz" + + filters = {} + filters[docfield] = assessment + filters["member"] = member + return frappe.db.exists(doctype, filters) + + +def has_graded_assessment(submission): + status = frappe.db.get_value("LMS Assignment Submission", submission, "status") + return False if status == "Not Graded" else True diff --git a/lms/lms/widgets/CourseCard.html b/lms/lms/widgets/CourseCard.html index 78472396..486471c9 100644 --- a/lms/lms/widgets/CourseCard.html +++ b/lms/lms/widgets/CourseCard.html @@ -72,6 +72,9 @@ {% endif %}
{{ course.title }}
+
+ {{ course.short_introduction }} +
{% if membership and not is_instructor(course.name) and not read_only %}
diff --git a/lms/public/css/style.css b/lms/public/css/style.css index a7930781..fe07f084 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -374,10 +374,18 @@ input[type=checkbox] { .course-card-title { font-weight: 600; color: var(--gray-900); - margin-bottom: 1.25rem; font-size: 1.125rem; } +.short-introduction { + text-overflow: ellipsis; + width: 100%; + overflow: hidden; + white-space: nowrap; + margin-bottom: 1.25rem; + +} + .card-divider { border-top: 1px solid var(--gray-300); margin-bottom: 1rem; @@ -1385,6 +1393,10 @@ pre { margin: 0 1rem; } +.seperator::after { + content: "\00B7"; +} + .course-overlay-card { background-color: white; border-radius: var(--border-radius-lg); @@ -1890,6 +1902,14 @@ li { padding: 0 1rem !important; } +.modal-dialog-scrollable .modal-body { + overflow-y: unset; +} + +.modal-dialog-scrollable .modal-content { + overflow: unset; +} + .modal-header, .modal-body { margin-bottom: 0.5rem !important; } @@ -2167,4 +2187,10 @@ select { .awesomplete ul li:last-child { display: none; +} + +.students-parent { + display: grid; + grid-template-columns: repeat(auto-fill, 150px); + grid-gap: 1rem; } \ No newline at end of file diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index cd28f6af..2eeb43ae 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -326,6 +326,7 @@ const open_class_dialog = () => { label: __("Description"), fieldname: "description", default: class_info && class_info.description, + reqd: 1, }, ], primary_action_label: __("Save"), diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index 01f895ac..2b415517 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -34,23 +34,46 @@
{{ class_info.title }}
-
- - - - - {{ frappe.utils.format_date(class_info.start_date, "long") }} - - - - {{ frappe.utils.format_date(class_info.end_date, "long") }} - -
+ {% if class_info.description %} -
+
{{ class_info.description }}
{% endif %} +
+
+ + + + + {{ frappe.utils.format_date(class_info.start_date, "long") }} - + + + {{ frappe.utils.format_date(class_info.end_date, "long") }} + +
+ + + +
+ + + + {{ class_courses | length }} {{ _("Courses") }} +
+ + + +
+ + + + {{ class_students | length }} {{ _("Students") }} +
+
+ + {% if class_info.custom_component %} {{ class_info.custom_component }} {% endif %} @@ -155,20 +178,9 @@ {% if class_courses | length %} -
+
{% for course in class_courses %} -
- - {{ course.title }} - - {% if is_moderator %} -
- - - -
- {% endif %} -
+ {{ widgets.CourseCard(course=course, read_only=False) }} {% endfor %}
{% else %} @@ -177,7 +189,6 @@
{% endif %} - {% endmacro %} @@ -198,24 +209,71 @@ {% if class_students | length %} -
+
+
+
+
+
+ {{ _("Full Name") }} +
+
+ {{ _("Courses Completed") }} +
+
+ {{ _("Assessments Completed") }} +
+
+ {{ _("Assessments Graded") }} +
+
+ {{ _("Last Active") }} +
+ {% if is_moderator %} +
+ + + +
+ {% endif %} +
+
+
{% for student in class_students %} - {% set last_active = frappe.db.get_value("User", student.student, "last_active") %} {% set allow_progress = is_moderator or student.student == frappe.session.user %} - -
-
- +
+
+ {{ student.student_name }} +
+ {{ student.courses_completed }} +
+
+ {{ student.assessments_completed }} +
+
+ {{ student.assessments_graded }} +
+
+ {{ frappe.utils.format_datetime(student.last_active, "medium") }} +
+ {% if is_moderator %} +
+ + + +
+ {% endif %}
- {% if is_moderator %} -
- - - -
- {% endif %} + + + +
{% endfor %} @@ -239,13 +297,13 @@ {% endif %} - {{ CreateAssessment() }} + {{ AssessmentList(assessments) }} {% endmacro %} -{% macro CreateAssessment() %} +{% macro ManageAssessments() %} {% if is_moderator %}