feat: progress page
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}
|
||||
{{ _(class_info.title) }}
|
||||
{{ _(class_info.title) }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="course-home-headings">
|
||||
{{ class_info.title }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="medium">
|
||||
{{ class_info.description }}
|
||||
</div>
|
||||
<div class="medium">
|
||||
@@ -108,11 +108,12 @@
|
||||
{% if class_students | length %}
|
||||
<div class="mt-10">
|
||||
{% for student in class_students %}
|
||||
<div class="">
|
||||
<div class="" style="position: relative;">
|
||||
<span>{{ student.student_name }}</span>
|
||||
<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 %}
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import frappe
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
from frappe import _
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
if not has_course_moderator_role():
|
||||
message = "Only Moderators have access to this page."
|
||||
if frappe.session.user == "Guest":
|
||||
message = "Please login to access this page."
|
||||
|
||||
raise frappe.PermissionError(_(message))
|
||||
|
||||
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)
|
||||
@@ -14,4 +24,4 @@ def get_context(context):
|
||||
|
||||
context.class_students = frappe.get_all("Class Student", {
|
||||
"parent": class_name
|
||||
}, ["student", "student_name"])
|
||||
}, ["student", "student_name", "username"])
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import frappe
|
||||
from lms.lms.utils import has_course_moderator_role
|
||||
from frappe import _
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
if not has_course_moderator_role():
|
||||
message = "Only Moderators have access to this page."
|
||||
if frappe.session.user == "Guest":
|
||||
message = "Please login to access this page."
|
||||
|
||||
raise frappe.PermissionError(_(message))
|
||||
|
||||
context.classes = frappe.get_all("LMS Class", fields=["name", "title", "start_date", "end_date"])
|
||||
|
||||
76
lms/www/classes/progress.html
Normal file
76
lms/www/classes/progress.html
Normal file
@@ -0,0 +1,76 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}
|
||||
{{ student.first_name }} 's {{ _("Progress") }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="common-page-style">
|
||||
<div class="container">
|
||||
{{ BreadCrumb(class_info, student) }}
|
||||
<div class="common-card-style column-card">
|
||||
<div class="course-home-headings">
|
||||
{{ student.full_name }}
|
||||
</div>
|
||||
{{ Progress(class_courses, student) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% macro BreadCrumb(class_info, student) %}
|
||||
<div class="breadcrumb">
|
||||
<a class="dark-links" href="/classes">{{ _("All Classes") }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/classes/{{ class_info.name }}">{{ class_info.name }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<span class="breadcrumb-destination">{{ student.full_name }}</span>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro Progress(class_info, student) %}
|
||||
<div>
|
||||
{% for course in class_courses %}
|
||||
<div class="medium">
|
||||
<div class="progress-course-header">
|
||||
<div class="section-heading"> {{ course.title }} </div>
|
||||
<div> {{ frappe.utils.cint(course.membership.progress) }}% </div>
|
||||
</div>
|
||||
|
||||
|
||||
{% for quiz in course.quizzes %}
|
||||
|
||||
{% set filters = { "member": student.name, "course": course.course } %}
|
||||
{% set submitted = frappe.db.exists("LMS Quiz Submission", filters) %}
|
||||
{% set score = frappe.db.get_value("LMS Quiz Submission", filters, ["score"]) %}
|
||||
|
||||
<div class="my-5">
|
||||
<div class="subheading"> {{ _("Quiz") }}: </div>
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
{{ quiz.title }}
|
||||
</div>
|
||||
{% if submitted %}
|
||||
<div class="ml-5">
|
||||
{{ score }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="indicator-pill red ml-5">
|
||||
Not Attempted
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
{% for quiz in class_courses.assignments %}
|
||||
<div>
|
||||
{{ assignments.assignment }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
26
lms/www/classes/progress.py
Normal file
26
lms/www/classes/progress.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
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)
|
||||
|
||||
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("Lesson Assignment", {"course": course.course}, ["name", "assignment"])
|
||||
|
||||
print(class_courses)
|
||||
context.class_courses = class_courses
|
||||
Reference in New Issue
Block a user