Merge pull request #480 from pateljannat/class-fixes

This commit is contained in:
Jannat Patel
2023-02-23 14:12:44 +05:30
committed by GitHub
14 changed files with 156 additions and 65 deletions

View File

@@ -9,8 +9,9 @@
"member",
"member_name",
"column_break_5",
"course",
"status",
"course",
"class",
"section_break_6",
"date",
"start_time",
@@ -93,11 +94,17 @@
{
"fieldname": "column_break_10",
"fieldtype": "Column Break"
},
{
"fieldname": "class",
"fieldtype": "Link",
"label": "Class",
"options": "LMS Class"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-11-23 11:49:01.400292",
"modified": "2023-02-22 16:00:34.361934",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Evaluation",

View File

@@ -31,7 +31,7 @@
{
"fieldname": "member",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Member",
"options": "User",
"reqd": 1
@@ -68,7 +68,6 @@
{
"fieldname": "end_time",
"fieldtype": "Time",
"in_list_view": 1,
"label": "End Time",
"reqd": 1
},
@@ -94,7 +93,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-02-17 09:26:13.776325",
"modified": "2023-02-23 09:47:46.480376",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Request",

View File

@@ -2,6 +2,13 @@
// For license information, please see license.txt
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,
},
};
});
},
});

View File

@@ -108,4 +108,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
}

View File

@@ -9,19 +9,29 @@ from frappe.utils import cint
class LMSClass(Document):
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):
for course in self.courses:
for student in self.students:
filters = {
"doctype": "LMS Batch Membership",
"member": student.student,
"course": course.course,
}
if not frappe.db.exists(filters):
frappe.get_doc(filters).save()
def validate_membership(self):
for course in self.courses:
for student in self.students:
filters = {
"doctype": "LMS Batch Membership",
"member": student.student,
"course": course.course,
}
if not frappe.db.exists(filters):
frappe.get_doc(filters).save()
@frappe.whitelist()
@@ -29,6 +39,17 @@ def add_student(email, class_name):
if not frappe.db.exists("User", email):
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(
{
"doctype": "Class Student",

View File

@@ -261,7 +261,7 @@
}
],
"make_attachments_public": 1,
"modified": "2023-02-16 10:11:17.557472",
"modified": "2023-02-23 09:45:54.826324",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",
@@ -295,6 +295,7 @@
}
],
"search_fields": "title",
"show_title_field_in_link": 1,
"sort_field": "creation",
"sort_order": "DESC",
"states": [],

View File

@@ -6,9 +6,10 @@
"engine": "InnoDB",
"field_order": [
"default_home",
"is_onboarding_complete",
"column_break_zdel",
"send_calendar_invite_for_evaluations",
"allow_student_progress",
"column_break_zdel",
"is_onboarding_complete",
"force_profile_completion",
"section_break_szgq",
"search_placeholder",
@@ -180,12 +181,18 @@
"fieldname": "mentor_request_tab",
"fieldtype": "Tab Break",
"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,
"issingle": 1,
"links": [],
"modified": "2023-02-15 17:13:11.802215",
"modified": "2023-02-23 10:39:38.912549",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",

View File

@@ -1,7 +1,10 @@
frappe.ready(function () {
frappe.web_form.after_save = () => {
setTimeout(() => {
window.history.back();
});
let data = frappe.web_form.get_values();
if (data.class) {
setTimeout(() => {
window.location.href = `/classes/${data.class}`;
}, 2000);
}
};
});

View File

@@ -20,7 +20,7 @@
"list_columns": [],
"login_required": 1,
"max_attachment_size": 0,
"modified": "2022-11-25 17:05:30.851109",
"modified": "2023-02-23 13:04:00.405266",
"modified_by": "Administrator",
"module": "LMS",
"name": "evaluation",
@@ -29,7 +29,7 @@
"published": 1,
"route": "evaluation",
"show_attachments": 0,
"show_list": 0,
"show_list": 1,
"show_sidebar": 0,
"title": "Evaluation",
"web_form_fields": [
@@ -59,6 +59,31 @@
"reqd": 1,
"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,
"fieldname": "date",
@@ -95,19 +120,6 @@
"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,
"fieldname": "rating",
@@ -135,15 +147,16 @@
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "summary",
"fieldtype": "Small Text",
"hidden": 0,
"label": "Summary",
"fieldname": "class",
"fieldtype": "Link",
"hidden": 1,
"label": "Class",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"options": "LMS Class",
"read_only": 1,
"reqd": 0,
"show_in_filter": 0
}
]
}
}

View File

@@ -463,6 +463,11 @@ input[type=checkbox] {
margin-bottom: 1rem;
}
.course-home-headings:hover {
color: var(--gray-900);
text-decoration: none;
}
.modal-headings {
margin: 0;
}
@@ -1869,10 +1874,21 @@ select {
}
.table th {
color: var(--gray-900);
font-weight: 500;
font-weight: 400;
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-top: none;
}
.lms-dropdown {
@@ -1957,3 +1973,5 @@ select {
color: var(--gray-900);
font-weight: 500;
}

View File

@@ -30,15 +30,7 @@
<!-- Class Details -->
{% macro ClassDetails(class_info) %}
<div class="class-details" data-class="{{ class_info.name }}">
<div class="course-home-headings">
{{ class_info.title }}
</div>
{% if class_info.description %}
<div class="medium">
{{ class_info.description }}
</div>
{% endif %}
<div class="medium">
<div class="medium pull-right">
{% if class_info.start_date %}
<span>
{{ frappe.utils.format_date(class_info.start_date, "medium") }} -
@@ -50,6 +42,15 @@
</span>
{% endif %}
</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 %}
{{ class_info.custom_component }}
{% endif %}
@@ -128,9 +129,10 @@
</tr>
{% 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 or frappe.db.get_single_value("LMS Settings", "allow_student_progress") %}
<tr>
<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 }}
</a>
</td>

View File

@@ -6,6 +6,8 @@ from frappe import _
def get_context(context):
context.no_cache = 1
class_name = frappe.form_dict["classname"]
session_user = []
remaining_students = []
context.class_info = frappe.db.get_value(
"LMS Class",
@@ -22,8 +24,19 @@ def get_context(context):
"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"]
)
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()

View File

@@ -15,14 +15,14 @@
{{ frappe.utils.format_datetime(student.last_active, "medium") }}
</span>
{% 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") }}
</a>
{% endif %}
</div>
<div class="course-home-headings">
<a class="course-home-headings" href="/users/{{student.username}}">
{{ student.full_name }}
</div>
</a>
</div>
{{ Progress(class_courses, student) }}
</div>

View File

@@ -13,7 +13,7 @@ def get_context(context):
context.student = frappe.db.get_value(
"User",
{"username": student},
["first_name", "full_name", "name", "last_active"],
["first_name", "full_name", "name", "last_active", "username"],
as_dict=True,
)
context.class_info = frappe.db.get_value(