mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 02:14:48 +00:00
feat: added student profile page
This commit is contained in:
@@ -15,5 +15,5 @@ def get_context(context):
|
||||
context.progress = get_topic_progress(context.topics, course, context.program)
|
||||
|
||||
def get_topic_progress(topics, course, program):
|
||||
progress = {topic.name: utils.get_student_topic_details(topic, course.name, program) for topic in topics}
|
||||
progress = {topic.name: utils.get_topic_progress(topic, course.name, program) for topic in topics}
|
||||
return progress
|
||||
|
||||
56
erpnext/www/lms/profile.html
Normal file
56
erpnext/www/lms/profile.html
Normal file
@@ -0,0 +1,56 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}Profile{% endblock %}
|
||||
{% from "www/lms/macros/hero.html" import hero %}
|
||||
|
||||
{% macro card(program) %}
|
||||
<div class="col-sm-4 mb-4 text-left">
|
||||
<a href="/lms/program?program={{ program.name }}" class="no-decoration no-underline">
|
||||
<div class="card h-100">
|
||||
<div class='card-body'>
|
||||
<h5 class='card-title'>{{ program.program }}</h5>
|
||||
<ul class="list-unstyled text-muted">
|
||||
{% for course in program.progress %}
|
||||
<li>
|
||||
{% if course.completed %} <span class="indicator green">
|
||||
{% elif course.started %} <span class="indicator orange">
|
||||
{% else %} <span class="indicator blue">{{ course }}</span>
|
||||
{% endif %}
|
||||
<a class="text-muted" href="/lms/course?program={{ program.name }}&name={{ course.course }}">{{ course.course }}</a>
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class='card-footer'>
|
||||
<span class="small">{{ program.completion }}% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% block content %}
|
||||
<section class="section">
|
||||
<div class='container pb-5'>
|
||||
<div class="mb-3 row">
|
||||
<div class="col-md-7">
|
||||
<a href="/lms" class="text-muted">
|
||||
<i class="fa fa-chevron-left"></i> Back to Home
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-5 text-right">
|
||||
<a href="/update-profile?name={{ frappe.session.user }}" target="blank" class="mt-0 text-muted">Edit Profile</a>
|
||||
</div>
|
||||
</div>
|
||||
<h1>{{ student.first_name }} {{ student.last_name or '' }}</h1>
|
||||
<p class="lead" style="max-width: 100%;">{{ student.name }}</p>
|
||||
</div>
|
||||
<div class='container'>
|
||||
<div class="row mt-5">
|
||||
{% for program in progress %}
|
||||
{{ card(program) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
24
erpnext/www/lms/profile.py
Normal file
24
erpnext/www/lms/profile.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import unicode_literals
|
||||
import erpnext.education.utils as utils
|
||||
import frappe
|
||||
|
||||
no_cache = 1
|
||||
|
||||
def get_context(context):
|
||||
context.student = utils.get_current_student()
|
||||
context.progress = get_program_progress(context.student.name)
|
||||
|
||||
def get_program_progress(student):
|
||||
enrolled_programs = frappe.get_all("Program Enrollment", filters={'student':student}, fields=['program'])
|
||||
student_progress = []
|
||||
for list_item in enrolled_programs:
|
||||
program = frappe.get_doc("Program", list_item.program)
|
||||
progress = utils.get_program_progress(program)
|
||||
completion = utils.get_program_completion(program)
|
||||
student_progress.append({'program': program.program_name, 'name': program.name, 'progress':progress, 'completion': completion})
|
||||
|
||||
return student_progress
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,5 +18,5 @@ def get_program(program_name):
|
||||
frappe.throw(_("Program {0} does not exist.".format(program_name)))
|
||||
|
||||
def get_course_progress(courses, program):
|
||||
progress = {course.name: utils.get_student_course_details(course, program) for course in courses}
|
||||
progress = {course.name: utils.get_course_progress(course, program) for course in courses}
|
||||
return progress
|
||||
Reference in New Issue
Block a user