feat: last active time of class students

This commit is contained in:
Jannat Patel
2022-11-22 08:43:12 +05:30
parent 0f46f6a1c1
commit 1d8e3de136
3 changed files with 37 additions and 14 deletions

View File

@@ -108,22 +108,40 @@
{{ AddStudents() }} {{ AddStudents() }}
{% if class_students | length %} {% if class_students | length %}
<div class="mt-10"> <table class="table mt-10">
<tr>
<th style="width: 70%">
{{ _("Student") }}
</th>
<th style="width: 20%">
{{ _("Last Active") }}
</th>
<th style="width: 10%"></th>
</tr>
{% for student in class_students %} {% for student in class_students %}
<div class="d-flex" style="position: relative;"> {% set last_active = frappe.db.get_value("User", student.student, "last_active") %}
<a class="subheading button-links flex-grow-1" href="/classes/{{ class_info.name }}/students/{{ student.username }}"> <tr>
{{ student.student_name }} <td>
</a> <a class="subheading button-links d-block" href="/classes/{{ class_info.name }}/students/{{ student.username }}">
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}"> {{ student.student_name }}
<use href="#icon-delete"></use> </a>
</svg> </td>
</div> <td>
{% if not loop.last %} <hr> {% endif %} {{ frappe.utils.format_datetime(last_active, "medium") }}
</td>
<td>
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}">
<use href="#icon-delete"></use>
</svg>
</td>
</tr>
{% endfor %} {% endfor %}
</div>
</table>
{% else %} {% else %}
<p class="text-muted mt-3"> {{ _("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 %}

View File

@@ -9,8 +9,13 @@
<div class="container"> <div class="container">
{{ BreadCrumb(class_info, student) }} {{ BreadCrumb(class_info, student) }}
<div class="common-card-style column-card"> <div class="common-card-style column-card">
<div class="course-home-headings"> <div class="mb-5">
{{ student.full_name }} <div class="medium pull-right">
{{ frappe.utils.format_datetime(student.last_active, "medium") }}
</div>
<div class="course-home-headings">
{{ student.full_name }}
</div>
</div> </div>
{{ Progress(class_courses, student) }} {{ Progress(class_courses, student) }}
</div> </div>

View File

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