feat: assignment submission and ui
This commit is contained in:
@@ -33,9 +33,11 @@
|
||||
<div class="course-home-headings">
|
||||
{{ class_info.title }}
|
||||
</div>
|
||||
{% if class_info.description %}
|
||||
<div class="medium">
|
||||
{{ class_info.description }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="medium">
|
||||
{% if class_info.start_date %}
|
||||
<span>
|
||||
@@ -108,18 +110,19 @@
|
||||
{% if class_students | length %}
|
||||
<div class="mt-10">
|
||||
{% for student in class_students %}
|
||||
<div class="" style="position: relative;">
|
||||
<span>{{ student.student_name }}</span>
|
||||
<div class="d-flex" style="position: relative;">
|
||||
<a class="button-links flex-grow-1" href="/classes/{{ class_info.name }}/students/{{ student.username }}">
|
||||
{{ student.student_name }}
|
||||
</a>
|
||||
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}">
|
||||
<use href="#icon-delete"></use>
|
||||
</svg>
|
||||
<a class="stretched-link" href="/classes/{{ class_info.name }}/students/{{ student.username }}"></a>
|
||||
</div>
|
||||
{% if not loop.last %} <hr> {% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted"> {{ _("No Students are added to this class.") }} </p>
|
||||
<p class="text-muted mt-3"> {{ _("No Students are added to this class.") }} </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
$("#submit-student").click((e) => {
|
||||
submit_student(e);
|
||||
});
|
||||
@@ -11,57 +10,61 @@ frappe.ready(() => {
|
||||
$(".class-course").click((e) => {
|
||||
update_course(e);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
const submit_student = (e) => {
|
||||
e.preventDefault();
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.add_student",
|
||||
args: {
|
||||
"email": $("#student-email").val(),
|
||||
"class_name": $(".class-details").data("class")
|
||||
email: $("#student-email").val(),
|
||||
class_name: $(".class-details").data("class"),
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __("Student added successfully"),
|
||||
indicator: "green",
|
||||
} ,3);
|
||||
},
|
||||
3
|
||||
);
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const remove_student = (e) => {
|
||||
frappe.confirm("Are you sure you want to remove this student from the class?",
|
||||
() => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.remove_student",
|
||||
args: {
|
||||
"student": $(e.currentTarget).data("student"),
|
||||
"class_name": $(".class-details").data("class")
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
message: __("Student removed successfully"),
|
||||
indicator: "green",
|
||||
}, 3);
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
frappe.confirm(
|
||||
"Are you sure you want to remove this student from the class?",
|
||||
() => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.remove_student",
|
||||
args: {
|
||||
student: $(e.currentTarget).data("student"),
|
||||
class_name: $(".class-details").data("class"),
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __("Student removed successfully"),
|
||||
indicator: "green",
|
||||
},
|
||||
3
|
||||
);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const update_course = (e) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.update_course",
|
||||
args: {
|
||||
"course": $(e.currentTarget).data("course"),
|
||||
"value": $(e.currentTarget).children("input").prop("checked") ? 1 : 0,
|
||||
"class_name": $(".class-details").data("class")
|
||||
}
|
||||
})
|
||||
course: $(e.currentTarget).data("course"),
|
||||
value: $(e.currentTarget).children("input").prop("checked") ? 1 : 0,
|
||||
class_name: $(".class-details").data("class"),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import frappe
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
from frappe import _
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
|
||||
|
||||
def get_context(context):
|
||||
@@ -16,13 +15,20 @@ def get_context(context):
|
||||
|
||||
class_name = frappe.form_dict["classname"]
|
||||
|
||||
context.class_info = frappe.db.get_value("LMS Class", class_name, ["name", "title", "start_date", "end_date", "description"], as_dict=True)
|
||||
context.published_courses = frappe.get_all("LMS Course", {"published": 1}, ["name", "title"])
|
||||
context.class_info = frappe.db.get_value(
|
||||
"LMS Class",
|
||||
class_name,
|
||||
["name", "title", "start_date", "end_date", "description"],
|
||||
as_dict=True,
|
||||
)
|
||||
context.published_courses = frappe.get_all(
|
||||
"LMS Course", {"published": 1}, ["name", "title"]
|
||||
)
|
||||
|
||||
context.class_courses = frappe.get_all("Class Course", {
|
||||
"parent": class_name
|
||||
}, pluck="course")
|
||||
context.class_courses = frappe.get_all(
|
||||
"Class Course", {"parent": class_name}, pluck="course"
|
||||
)
|
||||
|
||||
context.class_students = frappe.get_all("Class Student", {
|
||||
"parent": class_name
|
||||
}, ["student", "student_name", "username"])
|
||||
context.class_students = frappe.get_all(
|
||||
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
|
||||
)
|
||||
|
||||
@@ -13,4 +13,6 @@ def get_context(context):
|
||||
|
||||
raise frappe.PermissionError(_(message))
|
||||
|
||||
context.classes = frappe.get_all("LMS Class", fields=["name", "title", "start_date", "end_date"])
|
||||
context.classes = frappe.get_all(
|
||||
"LMS Class", fields=["name", "title", "start_date", "end_date"]
|
||||
)
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
{% macro Progress(class_info, student) %}
|
||||
<div>
|
||||
{% for course in class_courses %}
|
||||
{% set progress = course.membership.progress %}
|
||||
<div class="medium">
|
||||
<div class="progress-course-header">
|
||||
<div class="section-heading"> {{ course.title }} </div>
|
||||
@@ -56,11 +57,12 @@
|
||||
{{ _("Last Attempt Date") }}
|
||||
</th>
|
||||
</tr>
|
||||
{% for quiz in course.quizzes %}
|
||||
|
||||
{% 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}) %}
|
||||
|
||||
<tr class="">
|
||||
<td>
|
||||
@@ -71,7 +73,7 @@
|
||||
</td>
|
||||
{% if has_submitted %}
|
||||
<td>
|
||||
{{ submission.score }}
|
||||
{{ submission.score }}/{{ total_questions }}
|
||||
</td>
|
||||
<td>
|
||||
{{ frappe.utils.format_date(submission.creation, "medium") }}
|
||||
|
||||
@@ -2,6 +2,7 @@ import frappe
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
from frappe import _
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
@@ -15,19 +16,31 @@ def get_context(context):
|
||||
student = frappe.form_dict["username"]
|
||||
classname = frappe.form_dict["classname"]
|
||||
|
||||
context.student = frappe.db.get_value("User", {"username": student}, ["first_name", "full_name", "name"], as_dict=True)
|
||||
context.class_info = frappe.db.get_value("LMS Class", classname, ["name"], as_dict=True)
|
||||
context.student = frappe.db.get_value(
|
||||
"User", {"username": student}, ["first_name", "full_name", "name"], as_dict=True
|
||||
)
|
||||
context.class_info = frappe.db.get_value(
|
||||
"LMS Class", classname, ["name"], as_dict=True
|
||||
)
|
||||
|
||||
class_courses = frappe.get_all("Class Course", {
|
||||
"parent": classname
|
||||
}, ["course", "title"])
|
||||
class_courses = frappe.get_all(
|
||||
"Class Course", {"parent": classname}, ["course", "title"]
|
||||
)
|
||||
|
||||
for course in class_courses:
|
||||
course.membership = frappe.db.get_value("LMS Batch Membership", {
|
||||
"member": context.student.name,
|
||||
"course": course.course
|
||||
}, ["progress"], as_dict=True)
|
||||
course.quizzes = frappe.get_all("LMS Quiz", {"course": course.course}, ["name", "title"])
|
||||
course.assignments = frappe.get_all("Course Lesson", {"course": course.course, "question": ["is", "set"]}, ["name", "title"])
|
||||
course.membership = frappe.db.get_value(
|
||||
"LMS Batch Membership",
|
||||
{"member": context.student.name, "course": course.course},
|
||||
["progress"],
|
||||
as_dict=True,
|
||||
)
|
||||
course.quizzes = frappe.get_all(
|
||||
"LMS Quiz", {"course": course.course}, ["name", "title"]
|
||||
)
|
||||
course.assignments = frappe.get_all(
|
||||
"Course Lesson",
|
||||
{"course": course.course, "question": ["is", "set"]},
|
||||
["name", "title"],
|
||||
)
|
||||
|
||||
context.class_courses = class_courses
|
||||
|
||||
Reference in New Issue
Block a user