feat: assignment submission and ui
This commit is contained in:
43
lms/hooks.py
43
lms/hooks.py
@@ -96,7 +96,7 @@ override_doctype_class = {
|
||||
|
||||
doc_events = {
|
||||
"Discussion Reply": {"after_insert": "lms.lms.utils.create_notification_log"},
|
||||
"Course Lesson": {"on_update": "lms.lms.doctype.lms_quiz.lms_quiz.update_lesson_info"}
|
||||
"Course Lesson": {"on_update": "lms.lms.doctype.lms_quiz.lms_quiz.update_lesson_info"},
|
||||
}
|
||||
|
||||
# Scheduled Tasks
|
||||
@@ -138,29 +138,40 @@ website_route_rules = [
|
||||
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
||||
{"from_route": "/courses/<course>/<certificate>", "to_route": "courses/certificate"},
|
||||
{"from_route": "/courses/<course>/learn", "to_route": "batch/learn"},
|
||||
{"from_route": "/courses/<course>/learn/<int:chapter>.<int:lesson>",
|
||||
"to_route": "batch/learn"},
|
||||
{
|
||||
"from_route": "/courses/<course>/learn/<int:chapter>.<int:lesson>",
|
||||
"to_route": "batch/learn",
|
||||
},
|
||||
{"from_route": "/quizzes", "to_route": "batch/quiz_list"},
|
||||
{"from_route": "/quizzes/<quizname>", "to_route": "batch/quiz"},
|
||||
{"from_route": "/classes/<classname>", "to_route": "classes/class"},
|
||||
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
|
||||
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
|
||||
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},
|
||||
{"from_route": "/courses/<course>/cohorts/<cohort>",
|
||||
"to_route": "cohorts/cohort"},
|
||||
{"from_route": "/courses/<course>/cohorts/<cohort>/<page>",
|
||||
"to_route": "cohorts/cohort"},
|
||||
{"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>",
|
||||
"to_route": "cohorts/subgroup"},
|
||||
{"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>/<page>",
|
||||
"to_route": "cohorts/subgroup"},
|
||||
{"from_route": "/courses/<course>/join/<cohort>/<subgroup>/<invite_code>",
|
||||
"to_route": "cohorts/join"},
|
||||
{"from_route": "/courses/<course>/cohorts/<cohort>", "to_route": "cohorts/cohort"},
|
||||
{
|
||||
"from_route": "/courses/<course>/cohorts/<cohort>/<page>",
|
||||
"to_route": "cohorts/cohort",
|
||||
},
|
||||
{
|
||||
"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>",
|
||||
"to_route": "cohorts/subgroup",
|
||||
},
|
||||
{
|
||||
"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>/<page>",
|
||||
"to_route": "cohorts/subgroup",
|
||||
},
|
||||
{
|
||||
"from_route": "/courses/<course>/join/<cohort>/<subgroup>/<invite_code>",
|
||||
"to_route": "cohorts/join",
|
||||
},
|
||||
{"from_route": "/users", "to_route": "profiles/profile"},
|
||||
{"from_route": "/jobs/<job>", "to_route": "jobs/job"},
|
||||
{"from_route": "/classes/<classname>/students/<username>",
|
||||
"to_route": "/classes/progress"},
|
||||
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"}
|
||||
{
|
||||
"from_route": "/classes/<classname>/students/<username>",
|
||||
"to_route": "/classes/progress",
|
||||
},
|
||||
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"},
|
||||
]
|
||||
|
||||
website_redirects = [
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class ClassCourse(Document):
|
||||
pass
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2022, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Class Student', {
|
||||
frappe.ui.form.on("Class Student", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class ClassStudent(Document):
|
||||
pass
|
||||
|
||||
@@ -12,7 +12,8 @@ class LessonAssignment(Document):
|
||||
|
||||
def validate_duplicates(self):
|
||||
if frappe.db.exists(
|
||||
"Lesson Assignment", {"lesson": self.lesson, "member": self.member, "name": ["!=", self.name]}
|
||||
"Lesson Assignment",
|
||||
{"lesson": self.lesson, "member": self.member, "name": ["!=", self.name]},
|
||||
):
|
||||
lesson_title = frappe.db.get_value("Course Lesson", self.lesson, "title")
|
||||
frappe.throw(
|
||||
@@ -50,3 +51,11 @@ def get_assignment(lesson):
|
||||
"File", {"file_url": assignment.assignment}, "file_name"
|
||||
)
|
||||
return assignment
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def grade_assignment(name, result, comments):
|
||||
doc = frappe.get_doc("Lesson Assignment", name)
|
||||
doc.status = result
|
||||
doc.comments = comments
|
||||
doc.save()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2022, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Class', {
|
||||
frappe.ui.form.on("LMS Class", {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -6,8 +6,8 @@ from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from frappe.utils import cint
|
||||
|
||||
class LMSClass(Document):
|
||||
|
||||
class LMSClass(Document):
|
||||
def validate(self):
|
||||
validate_membership(self)
|
||||
|
||||
@@ -18,7 +18,7 @@ def validate_membership(self):
|
||||
filters = {
|
||||
"doctype": "LMS Batch Membership",
|
||||
"member": student.student,
|
||||
"course": course.course
|
||||
"course": course.course,
|
||||
}
|
||||
if not frappe.db.exists(filters):
|
||||
frappe.get_doc(filters).save()
|
||||
@@ -29,36 +29,37 @@ 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."))
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "Class Student",
|
||||
"student": email,
|
||||
"student_name": frappe.db.get_value("User", email, "full_name"),
|
||||
"parent": class_name,
|
||||
"parenttype": "LMS Class",
|
||||
"parentfield": "students"
|
||||
}).save()
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Class Student",
|
||||
"student": email,
|
||||
"student_name": frappe.db.get_value("User", email, "full_name"),
|
||||
"parent": class_name,
|
||||
"parenttype": "LMS Class",
|
||||
"parentfield": "students",
|
||||
}
|
||||
).save()
|
||||
return True
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def remove_student(student, class_name):
|
||||
frappe.db.delete("Class Student", {
|
||||
"student": student,
|
||||
"parent": class_name
|
||||
})
|
||||
frappe.db.delete("Class Student", {"student": student, "parent": class_name})
|
||||
return True
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_course(class_name, course, value):
|
||||
if cint(value):
|
||||
doc = frappe.get_doc({
|
||||
doc = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Class Course",
|
||||
"parent": class_name,
|
||||
"course": course,
|
||||
"parenttype": "LMS Class",
|
||||
"parentfield": "courses"
|
||||
})
|
||||
"parentfield": "courses",
|
||||
}
|
||||
)
|
||||
doc.save()
|
||||
else:
|
||||
frappe.db.delete("Class Course", {"parent": class_name, "course": course})
|
||||
|
||||
@@ -62,10 +62,10 @@ class LMSQuiz(Document):
|
||||
|
||||
def update_lesson_info(doc, method):
|
||||
if doc.quiz_id:
|
||||
frappe.db.set_value("LMS Quiz", doc.quiz_id, {
|
||||
"lesson": doc.name,
|
||||
"course": doc.course
|
||||
})
|
||||
frappe.db.set_value(
|
||||
"LMS Quiz", doc.quiz_id, {"lesson": doc.name, "course": doc.course}
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def quiz_summary(quiz, results):
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
frappe.ready(function() {
|
||||
frappe.ready(function () {
|
||||
// bind events here
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.rename_doc("Role", "Course Instructor", "Instructor")
|
||||
frappe.rename_doc("Role", "Course Moderator", "Moderator")
|
||||
|
||||
@@ -152,7 +152,8 @@ def assignment_renderer(detail):
|
||||
file_type = detail.split("-")[1]
|
||||
accept = supported_types[file_type] if file_type else ""
|
||||
return frappe.render_template(
|
||||
"templates/assignment.html", {"question": question, "accept": accept, "file_type": file_type}
|
||||
"templates/assignment.html",
|
||||
{"question": question, "accept": accept, "file_type": file_type},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -895,6 +895,7 @@ pre {
|
||||
.column-card {
|
||||
flex-direction: column;
|
||||
padding: 1.25rem;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
@@ -1674,9 +1675,9 @@ li {
|
||||
}
|
||||
|
||||
.indicator-pill::before {
|
||||
width: 0;
|
||||
height: 0;
|
||||
margin-right: 0;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.role {
|
||||
@@ -1855,4 +1856,22 @@ select {
|
||||
color: var(--gray-900);
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid var(--gray-300);
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.lms-dropdown {
|
||||
border: 1px solid var(--gray-400);
|
||||
border-radius: var(--border-radius-sm);
|
||||
padding: 0.25rem 2rem;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lms-menu {
|
||||
background-image: url(/assets/lms/icons/down-arrow.svg);
|
||||
background-position: right 0.5rem center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 0.75rem;
|
||||
padding-right: 2.5rem;
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,6 @@ const render_chart = (data, chart_name, element, type) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const generate_course_completion_graph = () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.utils.get_course_completion_data",
|
||||
@@ -220,12 +219,10 @@ const generate_course_completion_graph = () => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const change_hash = (e) => {
|
||||
window.location.hash = $(e.currentTarget).attr("href");
|
||||
};
|
||||
|
||||
|
||||
const open_tab = () => {
|
||||
$(`a[href="${window.location.hash}"]`).click();
|
||||
};
|
||||
|
||||
0
lms/www/assignments/__init__.py
Normal file
0
lms/www/assignments/__init__.py
Normal file
@@ -8,26 +8,53 @@
|
||||
<div class="common-page-style">
|
||||
<div class="container">
|
||||
<div class="common-card-style column-card">
|
||||
<div class="btn btn-primary btn-sm pull-right" id="save-assignment"> {{ _("Save") }} </div>
|
||||
<div class="course-home-headings"> {{ _("Assignments") }} </div>
|
||||
<div class="row medium">
|
||||
<div class="col">
|
||||
<div>
|
||||
<a href="{{ assignment.assignment }}" target="_blank">
|
||||
{{ _("Click to open assignment") }}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<select class="btn btn-default ml-2" id="file-type" data-type="{{ assignment.status }}">
|
||||
<option selected> {{ _("Result") }} </option>
|
||||
<option value="Image"> {{ _("Pass") }} </option>
|
||||
<option value="Document"> {{ _("Fail") }} </option>
|
||||
</select>
|
||||
<div class="course-home-headings"> {{ _("Assignment Grading") }} </div>
|
||||
<div class="medium w-50 mt-3">
|
||||
<a class="btn btn-secondary btn-sm" href="{{ assignment.assignment }}" target="_blank">
|
||||
{{ _("Open Attachment") }}
|
||||
</a>
|
||||
<select class="btn btn-secondary btn-sm ml-2 lms-menu" id="result" data-type="{{ assignment.status }}">
|
||||
<option selected> {{ _("Not Graded") }} </option>
|
||||
<option value="Pass"> {{ _("Pass") }} </option>
|
||||
<option value="Fail"> {{ _("Fail") }} </option>
|
||||
</select>
|
||||
|
||||
<div class="mt-3">
|
||||
<span class="subheading">
|
||||
{{ _("Member") }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ assignment.member_name }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{% set course_title = frappe.db.get_value("LMS Course", assignment.course, "title") %}
|
||||
<span class="subheading">
|
||||
{{ _("Course") }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ course_title }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{% set lesson_title = frappe.db.get_value("Course Lesson", assignment.lesson, "title") %}
|
||||
<span class="subheading"> {{ _("Lesson") }}: </span>
|
||||
<span>
|
||||
{{ lesson_title }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="subheading mt-3"> {{ _("Comments") }}: </div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<textarea type="text" class="input-with-feedback form-control" id="comments" spellcheck="false"
|
||||
autocomplete="off" placeholder="Comments">{% if assignment.comments %}{{ assignment.comments }}{% endif %}
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div contenteditable="true" data-placeholder="{{ _('Comments') }}"
|
||||
style="height: 100px;" >{% if assignment.comments %}{{ assignment.comments }}{% endif %}</div>
|
||||
|
||||
<div class="btn btn-primary btn-sm mt-3" id="save-assignment" data-assignment="{{ assignment.name }}">
|
||||
{{ _("Save") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
50
lms/www/assignments/assignment.js
Normal file
50
lms/www/assignments/assignment.js
Normal file
@@ -0,0 +1,50 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
this.result;
|
||||
let self = this;
|
||||
|
||||
set_result();
|
||||
|
||||
$("#save-assignment").click((e) => {
|
||||
save_assignment(e);
|
||||
});
|
||||
|
||||
$("#result").change((e) => {
|
||||
$("#result option:selected").each(function () {
|
||||
self.result = $(this).val();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
const set_result = () => {
|
||||
let self = this;
|
||||
let result = $("#result").data("type");
|
||||
if (result) {
|
||||
$("#result option").each((i, elem) => {
|
||||
if ($(elem).val() == result) {
|
||||
$(elem).attr("selected", true);
|
||||
self.result = result;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const save_assignment = (e) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lesson_assignment.lesson_assignment.grade_assignment",
|
||||
args: {
|
||||
"name": $(e.currentTarget).data("assignment"),
|
||||
"result": self.result,
|
||||
"comments": $("#comments").val(),
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
message: __("Saved"),
|
||||
indicator: "green",
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
assignment = frappe.form_dict["assignment"]
|
||||
@@ -13,4 +14,9 @@ def get_context(context):
|
||||
|
||||
raise frappe.PermissionError(_(message))
|
||||
|
||||
context.assignment = frappe.db.get_value("Lesson Assignment", assignment, ["assignment", "comments", "status", "name"], as_dict=True)
|
||||
context.assignment = frappe.db.get_value(
|
||||
"Lesson Assignment",
|
||||
assignment,
|
||||
["assignment", "comments", "status", "name", "member_name", "course", "lesson"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
});
|
||||
frappe.ready(() => {});
|
||||
|
||||
const change_hash = (e) => {
|
||||
window.location.hash = $(e.currentTarget).attr("href");
|
||||
|
||||
Reference in New Issue
Block a user