Merge pull request #416 from pateljannat/cohort-fixes

This commit is contained in:
Jannat Patel
2022-10-27 11:31:38 +05:30
committed by GitHub
4 changed files with 70 additions and 52 deletions

View File

@@ -137,7 +137,10 @@ class LMSCourse(Document):
def get_cohorts(self):
return frappe.get_all("Cohort", {"course": self.name}, ["name", "slug"], order_by="creation")
return frappe.get_all("Cohort",
{"course": self.name},
["name", "slug", "title", "begin_date", "end_date"],
order_by="creation")
def get_cohort(self, cohort_slug):

View File

@@ -1,5 +1,7 @@
{% extends "www/cohorts/base.html" %}
{% block title %}Manage {{ course.title }}{% endblock %}
{% block title %}
{{ _("Manage") }} {{ course.title }}
{% endblock %}
{% block page_content %}
<div class="course-home-headings">
@@ -7,12 +9,10 @@
</div>
<p>
{% set stats = cohort.get_stats() %}
{{ stats.subgroups }} {{ _("Subgroups")}}
| {{ stats.mentors }} {{ _("Mentors") }}
| {{ stats.students }} {{ _("Students") }}
| {{ stats.join_requests }} {{ _("Join Requests") }}
{{ frappe.db.count("Cohort Subgroup", {"cohort": cohort.name}) }} {{ _("Subgroups") }}
| {{ frappe.db.count("Cohort Mentor", {"cohort": cohort.name}) }} {{ _("Mentors") }}
| {{ frappe.db.count("LMS Batch Membership", {"cohort": cohort.name}) }} {{ _("Students") }}
| {{ frappe.db.count("Cohort Join Request", {"cohort": cohort.name}) }} {{ _("Join Requests") }}
</p>
{% if is_mentor %}
@@ -25,19 +25,19 @@
{% endif %}
<ul class="nav nav-tabs">
{% set num_subgroups = cohort.get_subgroups() | length %}
{{ render_navitem("Subgroups", "", page=page, count=num_subgroups) }}
{% for p in cohort.get_pages(scope="Cohort") %}
{{ render_navitem(p.title, p.slug, page=page) }}
{% endfor %}
{% set num_subgroups = cohort.get_subgroups() | length %}
{{ render_navitem("Subgroups", "", page=page, count=num_subgroups) }}
{% for p in cohort.get_pages(scope="Cohort") %}
{{ render_navitem(p.title, p.slug, page=page) }}
{% endfor %}
</ul>
<div class="my-5">
{% if not page %}
{{ render_subgroups() }}
{% else %}
{{ render_page(page) }}
{% endif %}
{% if not page %}
{{ render_subgroups() }}
{% else %}
{{ render_page(page) }}
{% endif %}
</div>
{% endblock %}
@@ -55,7 +55,7 @@
<div style="font-size: 0.8em;">
{{ sg.num_mentors }} {{ _("Mentors") }}
|
{{sg.num_students}} {{ _(Students) }}
{{sg.num_students}} {{ _("Students") }}
|
{{sg.num_join_requests}} {{ _("Join Requests") }}
</div>

View File

@@ -1,38 +1,53 @@
{% extends "www/cohorts/base.html" %}
{% block title %}Manage {{ course.title }}{% endblock %}
{% block title %}
_("Manage") {{ course.title }}
{% endblock %}
{% block page_content %}
{% if cohorts %}
<h2>{{ _("Cohorts") }}</h2>
<div class="row">
{% for cohort in cohorts %}
<div class="col-md-6">
{{ render_cohort(course, cohort) }}
</div>
{% endfor %}
</div>
{% else %}
<h2>{{ _("Permission Denied") }}</h2>
<p>{{ _("You don't have permission to manage this course.") }}</p>
{% endif %}
{% if cohorts %}
<h2>
{{ _("Cohorts") }}
</h2>
<div class="row">
{% for cohort in cohorts %}
<div class="col-md-6">
{{ render_cohort(course, cohort) }}
</div>
{% endfor %}
</div>
{% else %}
<h2>
{{ _("Permission Denied") }}
</h2>
<p>
{{ _("You don't have permission to manage this course.") }}
</p>
{% endif %}
{% endblock %}
{% macro render_cohort(course, cohort) %}
<div class="card">
<div class="card-body">
<h5 class="card-title">{{cohort.title}}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{cohort.begin_date}} - {{cohort.end_date}}</h6>
<p>
{% set stats = cohort.get_stats() %}
<div class="cards-parent">
<div class="common-card-style flex-column p-5">
<h5 class="card-title">
{{ cohort.title }}
</h5>
{{ stats.subgroups }} Subgroups
| {{ stats.mentors }} Mentors
| {{ stats.students }} students
| {{ stats.join_requests }} join requests
</p>
{% if cohort.begin_date %}
<h6 class="card-subtitle mb-2 text-muted">
{{ frappe.utils.format_date(cohort.begin_date, "medium") }} - {{ frappe.utils.format_date(cohort.end_date, "medium") }}
</h6>
{% endif %}
<a href="/courses/{{course.name}}/cohorts/{{cohort.slug}}" class="card-link">{{ _("Manage") }}</a>
</div>
<p class="mb-0">
{{ frappe.db.count("Cohort Subgroup", {"cohort": cohort.name}) }} {{ _("Subgroups") }}
| {{ frappe.db.count("Cohort Mentor", {"cohort": cohort.name}) }} {{ _("Mentors") }}
| {{ frappe.db.count("LMS Batch Membership", {"cohort": cohort.name}) }} {{ _("Students") }}
| {{ frappe.db.count("Cohort Join Request", {"cohort": cohort.name}) }} {{ _("Join Requests") }}
</p>
<a class="stretched-link" href="/courses/{{course.name}}/cohorts/{{cohort.slug}}"></a>
</div>
</div>
{% endmacro %}

View File

@@ -292,12 +292,7 @@
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
{% if show_start_learing_cta(course, membership) %}
<div class="btn btn-primary wide-button join-batch" data-course="{{ course.name | urlencode }}">
{{ _("Start Learning") }}
</div>
{% elif is_instructor(course.name) and not course.published and course.status != "Under Review" %}
{% if is_instructor(course.name) and not course.published and course.status != "Under Review" %}
<div class="btn btn-primary wide-button" id="submit-for-review" data-course="{{ course.name | urlencode }}">
{{ _("Submit for Review") }}
</div>
@@ -323,6 +318,11 @@
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
{{ _("Continue Learning") }}
</a>
{% elif show_start_learing_cta(course, membership) %}
<div class="btn btn-primary wide-button join-batch" data-course="{{ course.name | urlencode }}">
{{ _("Start Learning") }}
</div>
{% endif %}
{% set progress = frappe.utils.cint(membership.progress) %}