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