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 = {
|
doc_events = {
|
||||||
"Discussion Reply": {"after_insert": "lms.lms.utils.create_notification_log"},
|
"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
|
# Scheduled Tasks
|
||||||
@@ -138,29 +138,40 @@ website_route_rules = [
|
|||||||
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
||||||
{"from_route": "/courses/<course>/<certificate>", "to_route": "courses/certificate"},
|
{"from_route": "/courses/<course>/<certificate>", "to_route": "courses/certificate"},
|
||||||
{"from_route": "/courses/<course>/learn", "to_route": "batch/learn"},
|
{"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", "to_route": "batch/quiz_list"},
|
||||||
{"from_route": "/quizzes/<quizname>", "to_route": "batch/quiz"},
|
{"from_route": "/quizzes/<quizname>", "to_route": "batch/quiz"},
|
||||||
{"from_route": "/classes/<classname>", "to_route": "classes/class"},
|
{"from_route": "/classes/<classname>", "to_route": "classes/class"},
|
||||||
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
|
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
|
||||||
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
|
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
|
||||||
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},
|
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},
|
||||||
{"from_route": "/courses/<course>/cohorts/<cohort>",
|
{"from_route": "/courses/<course>/cohorts/<cohort>", "to_route": "cohorts/cohort"},
|
||||||
"to_route": "cohorts/cohort"},
|
{
|
||||||
{"from_route": "/courses/<course>/cohorts/<cohort>/<page>",
|
"from_route": "/courses/<course>/cohorts/<cohort>/<page>",
|
||||||
"to_route": "cohorts/cohort"},
|
"to_route": "cohorts/cohort",
|
||||||
{"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>",
|
},
|
||||||
"to_route": "cohorts/subgroup"},
|
{
|
||||||
{"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>/<page>",
|
"from_route": "/courses/<course>/subgroups/<cohort>/<subgroup>",
|
||||||
"to_route": "cohorts/subgroup"},
|
"to_route": "cohorts/subgroup",
|
||||||
{"from_route": "/courses/<course>/join/<cohort>/<subgroup>/<invite_code>",
|
},
|
||||||
"to_route": "cohorts/join"},
|
{
|
||||||
|
"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": "/users", "to_route": "profiles/profile"},
|
||||||
{"from_route": "/jobs/<job>", "to_route": "jobs/job"},
|
{"from_route": "/jobs/<job>", "to_route": "jobs/job"},
|
||||||
{"from_route": "/classes/<classname>/students/<username>",
|
{
|
||||||
"to_route": "/classes/progress"},
|
"from_route": "/classes/<classname>/students/<username>",
|
||||||
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"}
|
"to_route": "/classes/progress",
|
||||||
|
},
|
||||||
|
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"},
|
||||||
]
|
]
|
||||||
|
|
||||||
website_redirects = [
|
website_redirects = [
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class ClassCourse(Document):
|
class ClassCourse(Document):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// Copyright (c) 2022, Frappe and contributors
|
// Copyright (c) 2022, Frappe and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Class Student', {
|
frappe.ui.form.on("Class Student", {
|
||||||
// refresh: function(frm) {
|
// refresh: function(frm) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class ClassStudent(Document):
|
class ClassStudent(Document):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class LessonAssignment(Document):
|
|||||||
|
|
||||||
def validate_duplicates(self):
|
def validate_duplicates(self):
|
||||||
if frappe.db.exists(
|
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")
|
lesson_title = frappe.db.get_value("Course Lesson", self.lesson, "title")
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
@@ -50,3 +51,11 @@ def get_assignment(lesson):
|
|||||||
"File", {"file_url": assignment.assignment}, "file_name"
|
"File", {"file_url": assignment.assignment}, "file_name"
|
||||||
)
|
)
|
||||||
return assignment
|
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
|
// Copyright (c) 2022, Frappe and contributors
|
||||||
// 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) {
|
// refresh: function(frm) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ from frappe.model.document import Document
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
class LMSClass(Document):
|
|
||||||
|
|
||||||
|
class LMSClass(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
validate_membership(self)
|
validate_membership(self)
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ def validate_membership(self):
|
|||||||
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()
|
||||||
@@ -29,36 +29,37 @@ 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."))
|
||||||
|
|
||||||
frappe.get_doc({
|
frappe.get_doc(
|
||||||
"doctype": "Class Student",
|
{
|
||||||
"student": email,
|
"doctype": "Class Student",
|
||||||
"student_name": frappe.db.get_value("User", email, "full_name"),
|
"student": email,
|
||||||
"parent": class_name,
|
"student_name": frappe.db.get_value("User", email, "full_name"),
|
||||||
"parenttype": "LMS Class",
|
"parent": class_name,
|
||||||
"parentfield": "students"
|
"parenttype": "LMS Class",
|
||||||
}).save()
|
"parentfield": "students",
|
||||||
|
}
|
||||||
|
).save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def remove_student(student, class_name):
|
def remove_student(student, class_name):
|
||||||
frappe.db.delete("Class Student", {
|
frappe.db.delete("Class Student", {"student": student, "parent": class_name})
|
||||||
"student": student,
|
|
||||||
"parent": class_name
|
|
||||||
})
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def update_course(class_name, course, value):
|
def update_course(class_name, course, value):
|
||||||
if cint(value):
|
if cint(value):
|
||||||
doc = frappe.get_doc({
|
doc = frappe.get_doc(
|
||||||
|
{
|
||||||
"doctype": "Class Course",
|
"doctype": "Class Course",
|
||||||
"parent": class_name,
|
"parent": class_name,
|
||||||
"course": course,
|
"course": course,
|
||||||
"parenttype": "LMS Class",
|
"parenttype": "LMS Class",
|
||||||
"parentfield": "courses"
|
"parentfield": "courses",
|
||||||
})
|
}
|
||||||
|
)
|
||||||
doc.save()
|
doc.save()
|
||||||
else:
|
else:
|
||||||
frappe.db.delete("Class Course", {"parent": class_name, "course": course})
|
frappe.db.delete("Class Course", {"parent": class_name, "course": course})
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ class LMSQuiz(Document):
|
|||||||
|
|
||||||
def update_lesson_info(doc, method):
|
def update_lesson_info(doc, method):
|
||||||
if doc.quiz_id:
|
if doc.quiz_id:
|
||||||
frappe.db.set_value("LMS Quiz", doc.quiz_id, {
|
frappe.db.set_value(
|
||||||
"lesson": doc.name,
|
"LMS Quiz", doc.quiz_id, {"lesson": doc.name, "course": doc.course}
|
||||||
"course": doc.course
|
)
|
||||||
})
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def quiz_summary(quiz, results):
|
def quiz_summary(quiz, results):
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
frappe.ready(function() {
|
frappe.ready(function () {
|
||||||
// bind events here
|
// bind events here
|
||||||
})
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
# do your magic here
|
# do your magic here
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.rename_doc("Role", "Course Instructor", "Instructor")
|
frappe.rename_doc("Role", "Course Instructor", "Instructor")
|
||||||
frappe.rename_doc("Role", "Course Moderator", "Moderator")
|
frappe.rename_doc("Role", "Course Moderator", "Moderator")
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ def assignment_renderer(detail):
|
|||||||
file_type = detail.split("-")[1]
|
file_type = detail.split("-")[1]
|
||||||
accept = supported_types[file_type] if file_type else ""
|
accept = supported_types[file_type] if file_type else ""
|
||||||
return frappe.render_template(
|
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 {
|
.column-card {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
@@ -1674,9 +1675,9 @@ li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.indicator-pill::before {
|
.indicator-pill::before {
|
||||||
width: 0;
|
width: 0 !important;
|
||||||
height: 0;
|
height: 0 !important;
|
||||||
margin-right: 0;
|
margin-right: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.role {
|
.role {
|
||||||
@@ -1855,4 +1856,22 @@ select {
|
|||||||
color: var(--gray-900);
|
color: var(--gray-900);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-bottom: 1px solid var(--gray-300);
|
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 = () => {
|
const generate_course_completion_graph = () => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.utils.get_course_completion_data",
|
method: "lms.lms.utils.get_course_completion_data",
|
||||||
@@ -220,12 +219,10 @@ const generate_course_completion_graph = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const change_hash = (e) => {
|
const change_hash = (e) => {
|
||||||
window.location.hash = $(e.currentTarget).attr("href");
|
window.location.hash = $(e.currentTarget).attr("href");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const open_tab = () => {
|
const open_tab = () => {
|
||||||
$(`a[href="${window.location.hash}"]`).click();
|
$(`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="common-page-style">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="common-card-style column-card">
|
<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"> {{ _("Assignment Grading") }} </div>
|
||||||
<div class="course-home-headings"> {{ _("Assignments") }} </div>
|
<div class="medium w-50 mt-3">
|
||||||
<div class="row medium">
|
<a class="btn btn-secondary btn-sm" href="{{ assignment.assignment }}" target="_blank">
|
||||||
<div class="col">
|
{{ _("Open Attachment") }}
|
||||||
<div>
|
</a>
|
||||||
<a href="{{ assignment.assignment }}" target="_blank">
|
<select class="btn btn-secondary btn-sm ml-2 lms-menu" id="result" data-type="{{ assignment.status }}">
|
||||||
{{ _("Click to open assignment") }}
|
<option selected> {{ _("Not Graded") }} </option>
|
||||||
</a>
|
<option value="Pass"> {{ _("Pass") }} </option>
|
||||||
</div>
|
<option value="Fail"> {{ _("Fail") }} </option>
|
||||||
<div>
|
</select>
|
||||||
<select class="btn btn-default ml-2" id="file-type" data-type="{{ assignment.status }}">
|
|
||||||
<option selected> {{ _("Result") }} </option>
|
<div class="mt-3">
|
||||||
<option value="Image"> {{ _("Pass") }} </option>
|
<span class="subheading">
|
||||||
<option value="Document"> {{ _("Fail") }} </option>
|
{{ _("Member") }}:
|
||||||
</select>
|
</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>
|
</div>
|
||||||
<div class="col">
|
|
||||||
<div contenteditable="true" data-placeholder="{{ _('Comments') }}"
|
<div class="btn btn-primary btn-sm mt-3" id="save-assignment" data-assignment="{{ assignment.name }}">
|
||||||
style="height: 100px;" >{% if assignment.comments %}{{ assignment.comments }}{% endif %}</div>
|
{{ _("Save") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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 lms.lms.utils import has_course_moderator_role
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
assignment = frappe.form_dict["assignment"]
|
assignment = frappe.form_dict["assignment"]
|
||||||
@@ -13,4 +14,9 @@ def get_context(context):
|
|||||||
|
|
||||||
raise frappe.PermissionError(_(message))
|
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">
|
<div class="course-home-headings">
|
||||||
{{ class_info.title }}
|
{{ class_info.title }}
|
||||||
</div>
|
</div>
|
||||||
|
{% if class_info.description %}
|
||||||
<div class="medium">
|
<div class="medium">
|
||||||
{{ class_info.description }}
|
{{ class_info.description }}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="medium">
|
<div class="medium">
|
||||||
{% if class_info.start_date %}
|
{% if class_info.start_date %}
|
||||||
<span>
|
<span>
|
||||||
@@ -108,18 +110,19 @@
|
|||||||
{% if class_students | length %}
|
{% if class_students | length %}
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
{% for student in class_students %}
|
{% for student in class_students %}
|
||||||
<div class="" style="position: relative;">
|
<div class="d-flex" style="position: relative;">
|
||||||
<span>{{ student.student_name }}</span>
|
<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 }}">
|
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}">
|
||||||
<use href="#icon-delete"></use>
|
<use href="#icon-delete"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<a class="stretched-link" href="/classes/{{ class_info.name }}/students/{{ student.username }}"></a>
|
|
||||||
</div>
|
</div>
|
||||||
{% if not loop.last %} <hr> {% endif %}
|
{% if not loop.last %} <hr> {% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
frappe.ready(() => {
|
frappe.ready(() => {
|
||||||
|
|
||||||
$("#submit-student").click((e) => {
|
$("#submit-student").click((e) => {
|
||||||
submit_student(e);
|
submit_student(e);
|
||||||
});
|
});
|
||||||
@@ -11,57 +10,61 @@ frappe.ready(() => {
|
|||||||
$(".class-course").click((e) => {
|
$(".class-course").click((e) => {
|
||||||
update_course(e);
|
update_course(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const submit_student = (e) => {
|
const submit_student = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.doctype.lms_class.lms_class.add_student",
|
method: "lms.lms.doctype.lms_class.lms_class.add_student",
|
||||||
args: {
|
args: {
|
||||||
"email": $("#student-email").val(),
|
email: $("#student-email").val(),
|
||||||
"class_name": $(".class-details").data("class")
|
class_name: $(".class-details").data("class"),
|
||||||
},
|
},
|
||||||
callback: (data) => {
|
callback: (data) => {
|
||||||
frappe.show_alert({
|
frappe.show_alert(
|
||||||
|
{
|
||||||
message: __("Student added successfully"),
|
message: __("Student added successfully"),
|
||||||
indicator: "green",
|
indicator: "green",
|
||||||
} ,3);
|
},
|
||||||
|
3
|
||||||
|
);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const remove_student = (e) => {
|
const remove_student = (e) => {
|
||||||
frappe.confirm("Are you sure you want to remove this student from the class?",
|
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",
|
frappe.call({
|
||||||
args: {
|
method: "lms.lms.doctype.lms_class.lms_class.remove_student",
|
||||||
"student": $(e.currentTarget).data("student"),
|
args: {
|
||||||
"class_name": $(".class-details").data("class")
|
student: $(e.currentTarget).data("student"),
|
||||||
},
|
class_name: $(".class-details").data("class"),
|
||||||
callback: (data) => {
|
},
|
||||||
frappe.show_alert({
|
callback: (data) => {
|
||||||
message: __("Student removed successfully"),
|
frappe.show_alert(
|
||||||
indicator: "green",
|
{
|
||||||
}, 3);
|
message: __("Student removed successfully"),
|
||||||
window.location.reload();
|
indicator: "green",
|
||||||
}
|
},
|
||||||
});
|
3
|
||||||
})
|
);
|
||||||
}
|
window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const update_course = (e) => {
|
const update_course = (e) => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.doctype.lms_class.lms_class.update_course",
|
method: "lms.lms.doctype.lms_class.lms_class.update_course",
|
||||||
args: {
|
args: {
|
||||||
"course": $(e.currentTarget).data("course"),
|
course: $(e.currentTarget).data("course"),
|
||||||
"value": $(e.currentTarget).children("input").prop("checked") ? 1 : 0,
|
value: $(e.currentTarget).children("input").prop("checked") ? 1 : 0,
|
||||||
"class_name": $(".class-details").data("class")
|
class_name: $(".class-details").data("class"),
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from lms.lms.utils import has_course_moderator_role
|
from lms.lms.utils import has_course_moderator_role
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from lms.lms.utils import has_course_moderator_role
|
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
@@ -16,13 +15,20 @@ def get_context(context):
|
|||||||
|
|
||||||
class_name = frappe.form_dict["classname"]
|
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.class_info = frappe.db.get_value(
|
||||||
context.published_courses = frappe.get_all("LMS Course", {"published": 1}, ["name", "title"])
|
"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", {
|
context.class_courses = frappe.get_all(
|
||||||
"parent": class_name
|
"Class Course", {"parent": class_name}, pluck="course"
|
||||||
}, pluck="course")
|
)
|
||||||
|
|
||||||
context.class_students = frappe.get_all("Class Student", {
|
context.class_students = frappe.get_all(
|
||||||
"parent": class_name
|
"Class Student", {"parent": class_name}, ["student", "student_name", "username"]
|
||||||
}, ["student", "student_name", "username"])
|
)
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ def get_context(context):
|
|||||||
|
|
||||||
raise frappe.PermissionError(_(message))
|
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) %}
|
{% macro Progress(class_info, student) %}
|
||||||
<div>
|
<div>
|
||||||
{% for course in class_courses %}
|
{% for course in class_courses %}
|
||||||
|
{% set progress = course.membership.progress %}
|
||||||
<div class="medium">
|
<div class="medium">
|
||||||
<div class="progress-course-header">
|
<div class="progress-course-header">
|
||||||
<div class="section-heading"> {{ course.title }} </div>
|
<div class="section-heading"> {{ course.title }} </div>
|
||||||
@@ -56,11 +57,12 @@
|
|||||||
{{ _("Last Attempt Date") }}
|
{{ _("Last Attempt Date") }}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for quiz in course.quizzes %}
|
|
||||||
|
|
||||||
|
{% for quiz in course.quizzes %}
|
||||||
{% set filters = { "member": student.name, "course": course.course } %}
|
{% set filters = { "member": student.name, "course": course.course } %}
|
||||||
{% set has_submitted = frappe.db.exists("LMS Quiz Submission", filters) %}
|
{% 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 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="">
|
<tr class="">
|
||||||
<td>
|
<td>
|
||||||
@@ -71,7 +73,7 @@
|
|||||||
</td>
|
</td>
|
||||||
{% if has_submitted %}
|
{% if has_submitted %}
|
||||||
<td>
|
<td>
|
||||||
{{ submission.score }}
|
{{ submission.score }}/{{ total_questions }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ frappe.utils.format_date(submission.creation, "medium") }}
|
{{ frappe.utils.format_date(submission.creation, "medium") }}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import frappe
|
|||||||
from lms.lms.utils import has_course_moderator_role
|
from lms.lms.utils import has_course_moderator_role
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
|
|
||||||
@@ -15,19 +16,31 @@ def get_context(context):
|
|||||||
student = frappe.form_dict["username"]
|
student = frappe.form_dict["username"]
|
||||||
classname = frappe.form_dict["classname"]
|
classname = frappe.form_dict["classname"]
|
||||||
|
|
||||||
context.student = frappe.db.get_value("User", {"username": student}, ["first_name", "full_name", "name"], as_dict=True)
|
context.student = frappe.db.get_value(
|
||||||
context.class_info = frappe.db.get_value("LMS Class", classname, ["name"], as_dict=True)
|
"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", {
|
class_courses = frappe.get_all(
|
||||||
"parent": classname
|
"Class Course", {"parent": classname}, ["course", "title"]
|
||||||
}, ["course", "title"])
|
)
|
||||||
|
|
||||||
for course in class_courses:
|
for course in class_courses:
|
||||||
course.membership = frappe.db.get_value("LMS Batch Membership", {
|
course.membership = frappe.db.get_value(
|
||||||
"member": context.student.name,
|
"LMS Batch Membership",
|
||||||
"course": course.course
|
{"member": context.student.name, "course": course.course},
|
||||||
}, ["progress"], as_dict=True)
|
["progress"],
|
||||||
course.quizzes = frappe.get_all("LMS Quiz", {"course": course.course}, ["name", "title"])
|
as_dict=True,
|
||||||
course.assignments = frappe.get_all("Course Lesson", {"course": course.course, "question": ["is", "set"]}, ["name", "title"])
|
)
|
||||||
|
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
|
context.class_courses = class_courses
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
frappe.ready(() => {
|
frappe.ready(() => {});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const change_hash = (e) => {
|
const change_hash = (e) => {
|
||||||
window.location.hash = $(e.currentTarget).attr("href");
|
window.location.hash = $(e.currentTarget).attr("href");
|
||||||
|
|||||||
Reference in New Issue
Block a user