Merge pull request #480 from pateljannat/class-fixes
This commit is contained in:
@@ -9,8 +9,9 @@
|
|||||||
"member",
|
"member",
|
||||||
"member_name",
|
"member_name",
|
||||||
"column_break_5",
|
"column_break_5",
|
||||||
"course",
|
|
||||||
"status",
|
"status",
|
||||||
|
"course",
|
||||||
|
"class",
|
||||||
"section_break_6",
|
"section_break_6",
|
||||||
"date",
|
"date",
|
||||||
"start_time",
|
"start_time",
|
||||||
@@ -93,11 +94,17 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_10",
|
"fieldname": "column_break_10",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "class",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Class",
|
||||||
|
"options": "LMS Class"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-11-23 11:49:01.400292",
|
"modified": "2023-02-22 16:00:34.361934",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate Evaluation",
|
"name": "LMS Certificate Evaluation",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "member",
|
"fieldname": "member",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Member",
|
"label": "Member",
|
||||||
"options": "User",
|
"options": "User",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
@@ -68,7 +68,6 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "end_time",
|
"fieldname": "end_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "End Time",
|
"label": "End Time",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -94,7 +93,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-02-17 09:26:13.776325",
|
"modified": "2023-02-23 09:47:46.480376",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate Request",
|
"name": "LMS Certificate Request",
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("LMS Class", {
|
frappe.ui.form.on("LMS Class", {
|
||||||
// refresh: function(frm) {
|
onload: function (frm) {
|
||||||
// }
|
frm.set_query("student", "students", function (doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
ignore_user_type: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -108,4 +108,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": []
|
"states": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,29 @@ from frappe.utils import cint
|
|||||||
|
|
||||||
class LMSClass(Document):
|
class LMSClass(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
validate_membership(self)
|
self.validate_duplicate_students()
|
||||||
|
self.validate_membership()
|
||||||
|
|
||||||
|
def validate_duplicate_students(self):
|
||||||
|
students = [row.student for row in self.students]
|
||||||
|
duplicates = {student for student in students if students.count(student) > 1}
|
||||||
|
if len(duplicates):
|
||||||
|
frappe.throw(
|
||||||
|
_("Student {0} has already been added to this class.").format(
|
||||||
|
frappe.bold(next(iter(duplicates)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def validate_membership(self):
|
def validate_membership(self):
|
||||||
for course in self.courses:
|
for course in self.courses:
|
||||||
for student in self.students:
|
for student in self.students:
|
||||||
filters = {
|
filters = {
|
||||||
"doctype": "LMS Batch Membership",
|
"doctype": "LMS Batch Membership",
|
||||||
"member": student.student,
|
"member": student.student,
|
||||||
"course": course.course,
|
"course": course.course,
|
||||||
}
|
}
|
||||||
if not frappe.db.exists(filters):
|
if not frappe.db.exists(filters):
|
||||||
frappe.get_doc(filters).save()
|
frappe.get_doc(filters).save()
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -29,6 +39,17 @@ def add_student(email, class_name):
|
|||||||
if not frappe.db.exists("User", email):
|
if not frappe.db.exists("User", email):
|
||||||
frappe.throw(_("There is no such user. Please create a user with this Email ID."))
|
frappe.throw(_("There is no such user. Please create a user with this Email ID."))
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"student": email,
|
||||||
|
"parent": class_name,
|
||||||
|
"parenttype": "LMS Class",
|
||||||
|
"parentfield": "students",
|
||||||
|
}
|
||||||
|
if frappe.db.exists("Class Student", filters):
|
||||||
|
frappe.throw(
|
||||||
|
_("Student {0} has already been added to this class.").format(frappe.bold(email))
|
||||||
|
)
|
||||||
|
|
||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Class Student",
|
"doctype": "Class Student",
|
||||||
|
|||||||
@@ -261,7 +261,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"make_attachments_public": 1,
|
"make_attachments_public": 1,
|
||||||
"modified": "2023-02-16 10:11:17.557472",
|
"modified": "2023-02-23 09:45:54.826324",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Course",
|
"name": "LMS Course",
|
||||||
@@ -295,6 +295,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"search_fields": "title",
|
"search_fields": "title",
|
||||||
|
"show_title_field_in_link": 1,
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
|
|||||||
@@ -6,9 +6,10 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"default_home",
|
"default_home",
|
||||||
"is_onboarding_complete",
|
|
||||||
"column_break_zdel",
|
|
||||||
"send_calendar_invite_for_evaluations",
|
"send_calendar_invite_for_evaluations",
|
||||||
|
"allow_student_progress",
|
||||||
|
"column_break_zdel",
|
||||||
|
"is_onboarding_complete",
|
||||||
"force_profile_completion",
|
"force_profile_completion",
|
||||||
"section_break_szgq",
|
"section_break_szgq",
|
||||||
"search_placeholder",
|
"search_placeholder",
|
||||||
@@ -180,12 +181,18 @@
|
|||||||
"fieldname": "mentor_request_tab",
|
"fieldname": "mentor_request_tab",
|
||||||
"fieldtype": "Tab Break",
|
"fieldtype": "Tab Break",
|
||||||
"label": "Mentor Request"
|
"label": "Mentor Request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "allow_student_progress",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Allow students to see each others progress in class"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-02-15 17:13:11.802215",
|
"modified": "2023-02-23 10:39:38.912549",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Settings",
|
"name": "LMS Settings",
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
frappe.ready(function () {
|
frappe.ready(function () {
|
||||||
frappe.web_form.after_save = () => {
|
frappe.web_form.after_save = () => {
|
||||||
setTimeout(() => {
|
let data = frappe.web_form.get_values();
|
||||||
window.history.back();
|
if (data.class) {
|
||||||
});
|
setTimeout(() => {
|
||||||
|
window.location.href = `/classes/${data.class}`;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"list_columns": [],
|
"list_columns": [],
|
||||||
"login_required": 1,
|
"login_required": 1,
|
||||||
"max_attachment_size": 0,
|
"max_attachment_size": 0,
|
||||||
"modified": "2022-11-25 17:05:30.851109",
|
"modified": "2023-02-23 13:04:00.405266",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "evaluation",
|
"name": "evaluation",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"published": 1,
|
"published": 1,
|
||||||
"route": "evaluation",
|
"route": "evaluation",
|
||||||
"show_attachments": 0,
|
"show_attachments": 0,
|
||||||
"show_list": 0,
|
"show_list": 1,
|
||||||
"show_sidebar": 0,
|
"show_sidebar": 0,
|
||||||
"title": "Evaluation",
|
"title": "Evaluation",
|
||||||
"web_form_fields": [
|
"web_form_fields": [
|
||||||
@@ -59,6 +59,31 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "summary",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Summary",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"options": "",
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "date",
|
"fieldname": "date",
|
||||||
@@ -95,19 +120,6 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"options": "",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "rating",
|
"fieldname": "rating",
|
||||||
@@ -135,15 +147,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "summary",
|
"fieldname": "class",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 1,
|
||||||
"label": "Summary",
|
"label": "Class",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"options": "LMS Class",
|
||||||
|
"read_only": 1,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -463,6 +463,11 @@ input[type=checkbox] {
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.course-home-headings:hover {
|
||||||
|
color: var(--gray-900);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
.modal-headings {
|
.modal-headings {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@@ -1869,10 +1874,21 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.table th {
|
.table th {
|
||||||
color: var(--gray-900);
|
font-weight: 400;
|
||||||
font-weight: 500;
|
border: none;
|
||||||
|
font-size: var(--text-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table tr:first-child, .table tr:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table tr {
|
||||||
border-bottom: 1px solid var(--gray-300);
|
border-bottom: 1px solid var(--gray-300);
|
||||||
border-top: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.lms-dropdown {
|
.lms-dropdown {
|
||||||
@@ -1957,3 +1973,5 @@ select {
|
|||||||
color: var(--gray-900);
|
color: var(--gray-900);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,15 +30,7 @@
|
|||||||
<!-- Class Details -->
|
<!-- Class Details -->
|
||||||
{% macro ClassDetails(class_info) %}
|
{% macro ClassDetails(class_info) %}
|
||||||
<div class="class-details" data-class="{{ class_info.name }}">
|
<div class="class-details" data-class="{{ class_info.name }}">
|
||||||
<div class="course-home-headings">
|
<div class="medium pull-right">
|
||||||
{{ class_info.title }}
|
|
||||||
</div>
|
|
||||||
{% if class_info.description %}
|
|
||||||
<div class="medium">
|
|
||||||
{{ class_info.description }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="medium">
|
|
||||||
{% if class_info.start_date %}
|
{% if class_info.start_date %}
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(class_info.start_date, "medium") }} -
|
{{ frappe.utils.format_date(class_info.start_date, "medium") }} -
|
||||||
@@ -50,6 +42,15 @@
|
|||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="course-home-headings">
|
||||||
|
{{ class_info.title }}
|
||||||
|
</div>
|
||||||
|
{% if class_info.description %}
|
||||||
|
<div class="medium">
|
||||||
|
{{ class_info.description }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if class_info.custom_component %}
|
{% if class_info.custom_component %}
|
||||||
{{ class_info.custom_component }}
|
{{ class_info.custom_component }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -128,9 +129,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for student in class_students %}
|
{% for student in class_students %}
|
||||||
{% set last_active = frappe.db.get_value("User", student.student, "last_active") %}
|
{% set last_active = frappe.db.get_value("User", student.student, "last_active") %}
|
||||||
|
{% set allow_progress = is_moderator or student.student == frappe.session.user or frappe.db.get_single_value("LMS Settings", "allow_student_progress") %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a class="subheading button-links d-block" href="/classes/{{ class_info.name }}/students/{{ student.username }}">
|
<a class="subheading button-links d-block" {% if allow_progress %} href="/classes/{{ class_info.name }}/students/{{ student.username }}" {% endif %}>
|
||||||
{{ student.student_name }}
|
{{ student.student_name }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ from frappe import _
|
|||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
class_name = frappe.form_dict["classname"]
|
class_name = frappe.form_dict["classname"]
|
||||||
|
session_user = []
|
||||||
|
remaining_students = []
|
||||||
|
|
||||||
context.class_info = frappe.db.get_value(
|
context.class_info = frappe.db.get_value(
|
||||||
"LMS Class",
|
"LMS Class",
|
||||||
@@ -22,8 +24,19 @@ def get_context(context):
|
|||||||
"Class Course", {"parent": class_name}, pluck="course"
|
"Class Course", {"parent": class_name}, pluck="course"
|
||||||
)
|
)
|
||||||
|
|
||||||
context.class_students = frappe.get_all(
|
class_students = frappe.get_all(
|
||||||
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
|
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for student in class_students:
|
||||||
|
if student.student == frappe.session.user:
|
||||||
|
session_user.append(student)
|
||||||
|
else:
|
||||||
|
remaining_students.append(student)
|
||||||
|
|
||||||
|
if len(session_user):
|
||||||
|
context.class_students = session_user + remaining_students
|
||||||
|
else:
|
||||||
|
context.class_students = class_students
|
||||||
|
|
||||||
context.is_moderator = has_course_moderator_role()
|
context.is_moderator = has_course_moderator_role()
|
||||||
|
|||||||
@@ -15,14 +15,14 @@
|
|||||||
{{ frappe.utils.format_datetime(student.last_active, "medium") }}
|
{{ frappe.utils.format_datetime(student.last_active, "medium") }}
|
||||||
</span>
|
</span>
|
||||||
{% if is_moderator %}
|
{% if is_moderator %}
|
||||||
<a class="btn btn-secondary btn-sm ml-3" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}">
|
<a class="btn btn-secondary btn-sm ml-3" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class={{class_info.name}}">
|
||||||
{{ _("Evaluate") }}
|
{{ _("Evaluate") }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="course-home-headings">
|
<a class="course-home-headings" href="/users/{{student.username}}">
|
||||||
{{ student.full_name }}
|
{{ student.full_name }}
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{{ Progress(class_courses, student) }}
|
{{ Progress(class_courses, student) }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def get_context(context):
|
|||||||
context.student = frappe.db.get_value(
|
context.student = frappe.db.get_value(
|
||||||
"User",
|
"User",
|
||||||
{"username": student},
|
{"username": student},
|
||||||
["first_name", "full_name", "name", "last_active"],
|
["first_name", "full_name", "name", "last_active", "username"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
context.class_info = frappe.db.get_value(
|
context.class_info = frappe.db.get_value(
|
||||||
|
|||||||
Reference in New Issue
Block a user