fix: evaluator in evals and link field descriptions
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
},
|
||||
{
|
||||
"fetch_from": "course.evaluator",
|
||||
"fetch_if_empty": 1,
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
@@ -93,7 +94,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-07-13 11:30:41.740461",
|
||||
"modified": "2023-07-21 11:13:38.827783",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Request",
|
||||
@@ -123,6 +124,18 @@
|
||||
"role": "Class Evaluator",
|
||||
"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",
|
||||
|
||||
@@ -88,10 +88,9 @@ def create_certificate_request(
|
||||
|
||||
if not is_member:
|
||||
return
|
||||
|
||||
frappe.get_doc(
|
||||
eval = frappe.new_doc("LMS Certificate Request")
|
||||
eval.update(
|
||||
{
|
||||
"doctype": "LMS Certificate Request",
|
||||
"course": course,
|
||||
"evaluator": get_evaluator(course, class_name),
|
||||
"member": frappe.session.user,
|
||||
@@ -100,7 +99,8 @@ def create_certificate_request(
|
||||
"start_time": start_time,
|
||||
"end_time": end_time,
|
||||
}
|
||||
).save(ignore_permissions=True)
|
||||
)
|
||||
eval.save()
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
import string
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.desk.doctype.dashboard_chart.dashboard_chart import get_result
|
||||
@@ -522,6 +521,14 @@ def has_course_moderator_role(member=None):
|
||||
)
|
||||
|
||||
|
||||
def has_course_evaluator_role(member=None):
|
||||
return frappe.db.get_value(
|
||||
"Has Role",
|
||||
{"parent": member or frappe.session.user, "role": "Evaluator"},
|
||||
"name",
|
||||
)
|
||||
|
||||
|
||||
def get_courses_under_review():
|
||||
return frappe.get_all(
|
||||
"LMS Course",
|
||||
|
||||
@@ -247,7 +247,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{% for student in class_students %}
|
||||
{% set allow_progress = is_moderator or student.student == frappe.session.user %}
|
||||
{% set allow_progress = is_moderator or student.student == frappe.session.user or is_evaluator %}
|
||||
<div class="grid-row">
|
||||
<div class="data-row row">
|
||||
<a class="col grid-static-col {% if allow_progress %} clickable {% endif %}" {% if allow_progress %} href="/classes/{{ class_info.name }}/students/{{ student.username }}" {% endif %}>
|
||||
|
||||
@@ -301,14 +301,6 @@ const show_course_modal = () => {
|
||||
fieldname: "course",
|
||||
reqd: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
options: "Course Evaluator",
|
||||
label: __("Evaluator"),
|
||||
fieldname: "evaluator",
|
||||
fetch_from: "course.evaluator",
|
||||
reqd: 1,
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Add"),
|
||||
primary_action(values) {
|
||||
@@ -318,7 +310,7 @@ const show_course_modal = () => {
|
||||
});
|
||||
course_modal.show();
|
||||
setTimeout(() => {
|
||||
$(".modal-body").css("min-height", "300px");
|
||||
$(".modal-body").css("min-height", "200px");
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
@@ -329,7 +321,6 @@ const add_course = (values) => {
|
||||
doc: {
|
||||
doctype: "Class Course",
|
||||
course: values.course,
|
||||
evaluator: values.evaluator,
|
||||
parenttype: "LMS Class",
|
||||
parentfield: "courses",
|
||||
parent: $(".class-details").data("class"),
|
||||
@@ -383,6 +374,7 @@ const show_student_modal = () => {
|
||||
filters: {
|
||||
ignore_user_type: 1,
|
||||
},
|
||||
filter_description: " ",
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Add"),
|
||||
@@ -457,13 +449,10 @@ const show_assessment_modal = (e) => {
|
||||
label: __("Assessment Type"),
|
||||
fieldname: "assessment_type",
|
||||
reqd: 1,
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: {
|
||||
name: ["in", ["LMS Assignment", "LMS Quiz"]],
|
||||
},
|
||||
};
|
||||
filters: {
|
||||
name: ["in", ["LMS Assignment", "LMS Quiz"]],
|
||||
},
|
||||
filter_description: " ",
|
||||
},
|
||||
{
|
||||
fieldtype: "Dynamic Link",
|
||||
|
||||
@@ -4,6 +4,7 @@ from frappe.utils import getdate
|
||||
from lms.www.utils import get_assessments
|
||||
from lms.lms.utils import (
|
||||
has_course_moderator_role,
|
||||
has_course_evaluator_role,
|
||||
get_course_progress,
|
||||
has_submitted_assessment,
|
||||
has_graded_assessment,
|
||||
@@ -14,6 +15,7 @@ def get_context(context):
|
||||
context.no_cache = 1
|
||||
class_name = frappe.form_dict["classname"]
|
||||
context.is_moderator = has_course_moderator_role()
|
||||
context.is_evaluator = has_course_evaluator_role()
|
||||
|
||||
context.class_info = frappe.db.get_value(
|
||||
"LMS Class",
|
||||
|
||||
@@ -68,46 +68,36 @@
|
||||
{{ _("Upcoming Evaluations") }}
|
||||
</div>
|
||||
{% if upcoming_evals | length %}
|
||||
<article class="form-grid">
|
||||
<div class="grid-heading-row">
|
||||
<div class="grid-row">
|
||||
<div class="data-row row">
|
||||
<div class="col grid-static-col">
|
||||
{{ _("Course") }}
|
||||
</div>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
{{ _("Date") }}
|
||||
</div>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
{{ _("Time") }}
|
||||
</div>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
{{ _("Evaluator") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<article class="cards-parent">
|
||||
{% for eval in upcoming_evals %}
|
||||
<div class="grid-row">
|
||||
<div class="data-row row">
|
||||
<a class="col grid-static-col clickable" href="{{ eval.url }}">
|
||||
{{ eval.course_title }}
|
||||
</a>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
{{ eval.date }}
|
||||
</div>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
{{ eval.start_time }}
|
||||
</div>
|
||||
<div class="col grid-static-col col-xs-2">
|
||||
<div class="common-card-style column-card">
|
||||
<div class="bold-heading">
|
||||
{{ eval.course_title }}
|
||||
</div>
|
||||
<div class="vertically-center">
|
||||
<svg class="icon icon-sm mr-1">
|
||||
<use href="#icon-calendar"></use>
|
||||
</svg>
|
||||
<span>
|
||||
{{ frappe.utils.format_date(eval.date, "medium") }} -
|
||||
</span>
|
||||
<span>
|
||||
{{ frappe.utils.format_time(eval.start_time, "hh:mm a") }}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="field-label">
|
||||
{{ _("Evaluator") }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ eval.evaluator_name }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% else %}
|
||||
<p class="text-muted mt-3"> {{ _("No Upcoming Evaluations") }} </p>
|
||||
<p class="text-muted"> {{ _("No Upcoming Evaluations") }} </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@@ -170,7 +160,7 @@
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% else %}
|
||||
<p class="text-muted mt-3"> {{ _("No Assessments") }} </p>
|
||||
<p class="text-muted"> {{ _("No Assessments") }} </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -22,13 +22,10 @@ const open_evaluation_form = (e) => {
|
||||
label: __("Course"),
|
||||
options: "LMS Course",
|
||||
reqd: 1,
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: {
|
||||
name: ["in", courses],
|
||||
},
|
||||
};
|
||||
filters: {
|
||||
name: ["in", courses],
|
||||
},
|
||||
filter_description: " ",
|
||||
},
|
||||
{
|
||||
fieldtype: "Date",
|
||||
@@ -118,14 +115,17 @@ const submit_evaluation_form = (values) => {
|
||||
start_time: this.current_slot.data("start"),
|
||||
end_time: this.current_slot.data("end"),
|
||||
day: this.current_slot.data("day"),
|
||||
class_name: class_name,
|
||||
},
|
||||
callback: (r) => {
|
||||
frappe.msgprint({
|
||||
title: __("Success"),
|
||||
frappe.show_alert({
|
||||
message: __("Evaluation scheduled successfully"),
|
||||
indicator: "green",
|
||||
});
|
||||
this.eval_form.hide();
|
||||
window.location.reload();
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import frappe
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
from lms.lms.utils import has_course_moderator_role, has_course_evaluator_role
|
||||
from frappe import _
|
||||
from lms.www.utils import get_assessments
|
||||
|
||||
@@ -10,6 +10,7 @@ def get_context(context):
|
||||
student = frappe.form_dict["username"]
|
||||
class_name = frappe.form_dict["classname"]
|
||||
context.is_moderator = has_course_moderator_role()
|
||||
context.is_evaluator = has_course_evaluator_role()
|
||||
|
||||
context.student = frappe.db.get_value(
|
||||
"User",
|
||||
@@ -17,6 +18,13 @@ def get_context(context):
|
||||
["first_name", "full_name", "name", "last_active", "username"],
|
||||
as_dict=True,
|
||||
)
|
||||
if (
|
||||
not context.is_moderator
|
||||
and not context.is_evaluator
|
||||
and not context.student.name == frappe.session.user
|
||||
):
|
||||
raise frappe.PermissionError(_("You don't have permission to access this page."))
|
||||
|
||||
context.class_info = frappe.db.get_value(
|
||||
"LMS Class", class_name, ["name"], as_dict=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user