diff --git a/lms/hooks.py b/lms/hooks.py
index 52a1a34f..c7ae9831 100644
--- a/lms/hooks.py
+++ b/lms/hooks.py
@@ -242,6 +242,10 @@ jinja = {
# "lms.plugins.LiveCodeExtension"
# ]
+has_website_permission = {
+ "LMS Certificate Evaluation": "lms.lms.doctype.lms_certificate_evaluation.lms_certificate_evaluation.has_website_permission"
+}
+
profile_mandatory_fields = [
"first_name",
"last_name",
diff --git a/lms/install.py b/lms/install.py
index 03645ab9..4caab84e 100644
--- a/lms/install.py
+++ b/lms/install.py
@@ -100,9 +100,10 @@ def delete_custom_fields():
def add_pages_to_nav():
pages = [
{"label": "Courses", "url": "/courses", "parent": "Explore", "idx": 2},
- {"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 3},
- {"label": "Jobs", "url": "/jobs", "parent": "Explore", "idx": 4},
- {"label": "People", "url": "/community", "parent": "Explore", "idx": 5},
+ {"label": "Classes", "url": "/classes", "parent": "Explore", "idx": 3},
+ {"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 4},
+ {"label": "Jobs", "url": "/jobs", "parent": "Explore", "idx": 5},
+ {"label": "People", "url": "/community", "parent": "Explore", "idx": 6},
]
if not frappe.db.exists("Top Bar Item", {"label": "Explore"}):
diff --git a/lms/lms/doctype/lms_certificate_evaluation/lms_certificate_evaluation.py b/lms/lms/doctype/lms_certificate_evaluation/lms_certificate_evaluation.py
index 3567982d..82105486 100644
--- a/lms/lms/doctype/lms_certificate_evaluation/lms_certificate_evaluation.py
+++ b/lms/lms/doctype/lms_certificate_evaluation/lms_certificate_evaluation.py
@@ -4,12 +4,19 @@
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
+from lms.lms.utils import has_course_moderator_role
class LMSCertificateEvaluation(Document):
pass
+def has_website_permission(doc, ptype, user, verbose=False):
+ if has_course_moderator_role() or doc.member == frappe.session.user:
+ return True
+ return False
+
+
@frappe.whitelist()
def create_lms_certificate(source_name, target_doc=None):
doc = get_mapped_doc(
diff --git a/lms/lms/doctype/lms_class/lms_class.json b/lms/lms/doctype/lms_class/lms_class.json
index 4cbaaeb9..58854f88 100644
--- a/lms/lms/doctype/lms_class/lms_class.json
+++ b/lms/lms/doctype/lms_class/lms_class.json
@@ -15,7 +15,8 @@
"description",
"section_break_6",
"students",
- "courses"
+ "courses",
+ "custom_component"
],
"fields": [
{
@@ -61,11 +62,18 @@
"fieldtype": "Date",
"label": "Start Date",
"reqd": 1
+ },
+ {
+ "description": "The HTML code entered here will be displayed on the class details page.",
+ "fieldname": "custom_component",
+ "fieldtype": "Code",
+ "label": "Custom Component",
+ "options": "HTML"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2022-11-21 10:55:50.067225",
+ "modified": "2022-11-25 10:37:24.250557",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Class",
diff --git a/lms/lms/web_form/evaluation/evaluation.json b/lms/lms/web_form/evaluation/evaluation.json
index 85123e71..0da8031d 100644
--- a/lms/lms/web_form/evaluation/evaluation.json
+++ b/lms/lms/web_form/evaluation/evaluation.json
@@ -20,7 +20,7 @@
"list_columns": [],
"login_required": 1,
"max_attachment_size": 0,
- "modified": "2022-11-23 14:57:47.700695",
+ "modified": "2022-11-25 17:05:30.851109",
"modified_by": "Administrator",
"module": "LMS",
"name": "evaluation",
@@ -29,7 +29,7 @@
"published": 1,
"route": "evaluation",
"show_attachments": 0,
- "show_list": 1,
+ "show_list": 0,
"show_sidebar": 0,
"title": "Evaluation",
"web_form_fields": [
@@ -146,4 +146,4 @@
"show_in_filter": 0
}
]
-}
\ No newline at end of file
+}
diff --git a/lms/lms/web_form/evaluation/evaluation.py b/lms/lms/web_form/evaluation/evaluation.py
index 2298b1c2..d1af4111 100644
--- a/lms/lms/web_form/evaluation/evaluation.py
+++ b/lms/lms/web_form/evaluation/evaluation.py
@@ -1,13 +1,6 @@
import frappe
from frappe import _
-from lms.lms.utils import has_course_moderator_role
def get_context(context):
-
- 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))
+ pass
diff --git a/lms/patches.txt b/lms/patches.txt
index afbf07ed..a8673351 100644
--- a/lms/patches.txt
+++ b/lms/patches.txt
@@ -36,6 +36,6 @@ lms.patches.v0_0.set_dashboard #11-10-2022
lms.patches.v0_0.set_courses_page_as_home
lms.patches.v0_0.set_member_in_progress #09-11-2022
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 #25-11-2022
lms.patches.v0_0.change_role_names
lms.patches.v0_0.quiz_submission_result
diff --git a/lms/www/assignments/assignment.html b/lms/www/assignments/assignment.html
index f319ba61..eebfee2f 100644
--- a/lms/www/assignments/assignment.html
+++ b/lms/www/assignments/assignment.html
@@ -45,7 +45,8 @@
diff --git a/lms/www/assignments/assignment.py b/lms/www/assignments/assignment.py
index dbbd5509..33823012 100644
--- a/lms/www/assignments/assignment.py
+++ b/lms/www/assignments/assignment.py
@@ -7,16 +7,29 @@ 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."
+ context.assignment = frappe.db.get_value(
+ "Lesson Assignment",
+ assignment,
+ [
+ "assignment",
+ "comments",
+ "status",
+ "name",
+ "member",
+ "member_name",
+ "course",
+ "lesson",
+ ],
+ as_dict=True,
+ )
+ context.is_moderator = has_course_moderator_role()
+
+ if (
+ not has_course_moderator_role()
+ and not frappe.session.user == context.assignment.member
+ ):
+ message = "You don't have the permissions to access 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,
- )
diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html
index 92462595..7362d35c 100644
--- a/lms/www/classes/class.html
+++ b/lms/www/classes/class.html
@@ -50,6 +50,9 @@
{% endif %}
+ {% if class_info.custom_component %}
+ {{ class_info.custom_component }}
+ {% endif %}
{% endmacro %}
@@ -94,7 +97,8 @@
{% for course in published_courses %}
{% set checked = course.name in class_courses %}
{% endfor %}
@@ -105,10 +109,12 @@
{% macro StudentsSection(class_info, class_students) %}
+ {% if is_moderator %}
{{ AddStudents() }}
+ {% endif %}
{% if class_students | length %}
-
+
|
{{ _("Student") }}
@@ -116,7 +122,9 @@
|
{{ _("Last Active") }}
|
+ {% if is_moderator %}
|
+ {% endif %}
{% for student in class_students %}
{% set last_active = frappe.db.get_value("User", student.student, "last_active") %}
@@ -129,11 +137,13 @@
{{ frappe.utils.format_datetime(last_active, "medium") }}
|
+ {% if is_moderator %}
|
+ {% endif %}
{% endfor %}
@@ -147,7 +157,7 @@
{% macro AddStudents() %}
-
+
{{ _("Add Student") }}
@@ -158,7 +168,9 @@
spellcheck="false">
-
+
{% endmacro %}
diff --git a/lms/www/classes/class.py b/lms/www/classes/class.py
index 7ff4337d..dce859c3 100644
--- a/lms/www/classes/class.py
+++ b/lms/www/classes/class.py
@@ -5,20 +5,12 @@ 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"],
+ ["name", "title", "start_date", "end_date", "description", "custom_component"],
as_dict=True,
)
@@ -33,3 +25,5 @@ def get_context(context):
context.class_students = frappe.get_all(
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
)
+
+ context.is_moderator = has_course_moderator_role()
diff --git a/lms/www/classes/index.html b/lms/www/classes/index.html
index 065e1e1b..4f20a534 100644
--- a/lms/www/classes/index.html
+++ b/lms/www/classes/index.html
@@ -6,9 +6,11 @@
{% block content %}
+ {% if has_course_moderator_role() %}
{{ _("Create Class") }}
+ {% endif %}
{{ _("All Classes") }}
{% if classes %}
{{ ClassCards(classes) }}
@@ -63,4 +65,4 @@
{% endfor %}
-{% endmacro %}
+{% endmacro %}
diff --git a/lms/www/classes/index.py b/lms/www/classes/index.py
index 7f5153f6..483b54e9 100644
--- a/lms/www/classes/index.py
+++ b/lms/www/classes/index.py
@@ -1,18 +1,10 @@
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"]
)
diff --git a/lms/www/classes/progress.html b/lms/www/classes/progress.html
index 70f89eb4..d86a8653 100644
--- a/lms/www/classes/progress.html
+++ b/lms/www/classes/progress.html
@@ -19,9 +19,11 @@
{{ frappe.utils.format_datetime(student.last_active, "medium") }}
+ {% if is_moderator %}
{{ _("Evaluate") }}
+ {% endif %}
{{ student.full_name }}
@@ -55,7 +57,7 @@
{{ frappe.utils.cint(course.membership.progress) }}%
- {% if course.quizzes | length or course.assignments | length %}
+ {% if course.quizzes | length or course.assignments | length or course.evaluations | length %}
@@ -73,90 +75,10 @@
- {% 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}) %}
+ {{ Quiz(course, student) }}
+ {{ Assignment(course, student, is_moderator) }}
+ {{ Evaluation(course, student, is_moderator) }}
-
- |
-
- {{ _("Quiz") }}
- |
- {{ quiz.title }} |
- {% if has_submitted %}
- {{ submission.score }}/{{ total_questions }} |
- {{ frappe.utils.format_date(submission.creation, "medium") }} |
- {% else %}
- - |
-
-
- {{ _("Not Attempted") }}
-
- |
- {% 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" %}
-
-
- |
-
- {{ _("Assignment") }}
- |
-
- {{ assignment.title }} |
-
- {% if has_submitted %}
-
-
- {{ status }}
-
- |
-
- {{ frappe.utils.format_date(submission.creation, "medium") }} |
-
- {% else %}
- - |
-
-
-
- {{ _("Not Attempted") }}
-
- |
- {% endif %}
-
- {% endfor %}
-
- {% for evaluation in course.evaluations %}
- {% set color = "green" if evaluation.status == "Pass" else "red" %}
-
- |
-
- {{ _("Evaluation") }}
- |
- - |
-
-
- {{ evaluation.status }}
-
- |
- {{ frappe.utils.format_date(evaluation.creation, "medium") }} |
-
- {% endfor %}
{% else %}
@@ -168,3 +90,100 @@
{% endfor %}
{% endmacro %}
+
+
+{% macro Quiz(course, student) %}
+ {% 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}) %}
+
+
+ |
+
+ {{ _("Quiz") }}
+ |
+ {{ quiz.title }} |
+ {% if has_submitted %}
+ {{ submission.score }}/{{ total_questions }} |
+ {{ frappe.utils.format_date(submission.creation, "medium") }} |
+ {% else %}
+ - |
+
+
+ {{ _("Not Attempted") }}
+
+ |
+ {% endif %}
+
+ {% endfor %}
+{% endmacro %}
+
+
+{% macro Assignment(course, student, is_moderator) %}
+ {% 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" %}
+ {% set can_see_details = has_submitted and (is_moderator or frappe.session.user == student.name) %}
+
+
+ |
+
+ {{ _("Assignment") }}
+ |
+
+ {{ assignment.title }} |
+
+ {% if has_submitted %}
+
+
+ {{ status }}
+
+ |
+
+ {{ frappe.utils.format_date(submission.creation, "medium") }} |
+
+ {% else %}
+ - |
+
+
+
+ {{ _("Not Attempted") }}
+
+ |
+ {% endif %}
+
+ {% endfor %}
+{% endmacro %}
+
+
+{% macro Evaluation(course, student, is_moderator) %}
+ {% for evaluation in course.evaluations %}
+ {% set color = "green" if evaluation.status == "Pass" else "red" %}
+ {% set can_see_details = is_moderator or frappe.session.user == student.name %}
+
+
+ |
+
+ {{ _("Evaluation") }}
+ |
+ - |
+
+
+ {{ evaluation.status }}
+
+ |
+ {{ frappe.utils.format_date(evaluation.creation, "medium") }} |
+
+ {% endfor %}
+{% endmacro %}
diff --git a/lms/www/classes/progress.py b/lms/www/classes/progress.py
index 306aea53..383f2fb6 100644
--- a/lms/www/classes/progress.py
+++ b/lms/www/classes/progress.py
@@ -6,15 +6,9 @@ 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.is_moderator = has_course_moderator_role()
context.student = frappe.db.get_value(
"User",
diff --git a/lms/www/quiz_result/__init__.py b/lms/www/quiz_result/__init__.py
new file mode 100644
index 00000000..e69de29b