Merge pull request #405 from pateljannat/cohorts
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Slug",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
@@ -105,7 +106,7 @@
|
||||
"link_fieldname": "cohort"
|
||||
}
|
||||
],
|
||||
"modified": "2021-12-16 14:44:25.406301",
|
||||
"modified": "2022-10-13 15:46:32.322926",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Cohort",
|
||||
@@ -127,5 +128,6 @@
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class LMSCourse(Document):
|
||||
|
||||
|
||||
def get_cohorts(self):
|
||||
return frappe.get_all("Cohort", {"course": self.name}, order_by="creation")
|
||||
return frappe.get_all("Cohort", {"course": self.name}, ["name", "slug"], order_by="creation")
|
||||
|
||||
|
||||
def get_cohort(self, cohort_slug):
|
||||
|
||||
@@ -2,22 +2,25 @@
|
||||
{% block title %}Manage {{ course.title }}{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<h2>{{cohort.title}} <span class="badge badge-secondary">Cohort</span></h2>
|
||||
<div class="course-home-headings">
|
||||
{{ cohort.title }}
|
||||
</div>
|
||||
|
||||
<p>
|
||||
{% set stats = cohort.get_stats() %}
|
||||
|
||||
{{ stats.subgroups }} Subgroups
|
||||
| {{ stats.mentors }} Mentors
|
||||
| {{ stats.students }} students
|
||||
| {{ stats.join_requests }} join requests
|
||||
{{ stats.subgroups }} {{ _("Subgroups")}}
|
||||
| {{ stats.mentors }} {{ _("Mentors") }}
|
||||
| {{ stats.students }} {{ _("Students") }}
|
||||
| {{ stats.join_requests }} {{ _("Join Requests") }}
|
||||
</p>
|
||||
|
||||
{% if is_mentor %}
|
||||
<div class="alert alert-info">
|
||||
{% set sg = mentor.get_subgroup() %}
|
||||
<p>You are a mentor of <b>{{sg.title}}</b> subgroup.</p>
|
||||
<p><a href="{{sg.get_url()}}" class="btn btn-primary">Visit Your Subgroup →</a></p>
|
||||
{% set sg = mentor.get_subgroup() %}
|
||||
<div class="alert alert-info medium">
|
||||
<a href="{{sg.get_url()}}">
|
||||
{{ _("You are a mentor of {0} subgroup.").format(frappe.bold(sg.title)) }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -40,38 +43,36 @@
|
||||
{% endblock %}
|
||||
|
||||
{% macro render_subgroups() %}
|
||||
<ul class="list-group">
|
||||
{% for sg in cohort.get_subgroups(include_counts=True) %}
|
||||
<li class="list-group-item">
|
||||
<div>
|
||||
<a class="subgroup-title"
|
||||
style="font-weight: 700; color: inherit;"
|
||||
href="/courses/{{course.name}}/subgroups/{{cohort.slug}}/{{sg.slug}}"
|
||||
>{{sg.title}}</a>
|
||||
</div>
|
||||
<div style="font-size: 0.8em;">
|
||||
{{sg.num_mentors}} Mentors
|
||||
|
|
||||
{{sg.num_students}} Students
|
||||
|
|
||||
{{sg.num_join_requests}} Join Requests
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
{% for sg in cohort.get_subgroups(include_counts=True) %}
|
||||
<li class="list-group-item">
|
||||
<div>
|
||||
<a class="subgroup-title" style="font-weight: 700; color: inherit;"
|
||||
href="/courses/{{course.name}}/subgroups/{{cohort.slug}}/{{sg.slug}}">
|
||||
{{ sg.title }}
|
||||
</a>
|
||||
</div>
|
||||
<div style="font-size: 0.8em;">
|
||||
{{ sg.num_mentors }} {{ _("Mentors") }}
|
||||
|
|
||||
{{sg.num_students}} {{ _(Students) }}
|
||||
|
|
||||
{{sg.num_join_requests}} {{ _("Join Requests") }}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_navitem(title, link, page, count=-1) %}
|
||||
<li class="nav-item">
|
||||
<a
|
||||
class="nav-link {{ 'active' if link==page }}"
|
||||
href="/courses/{{course.name}}/cohorts/{{cohort.slug}}/{{link}}"
|
||||
>{{title}}
|
||||
{% if count != -1 %}
|
||||
<span
|
||||
class="badge {{'badge-primary' if link==page else 'badge-secondary'}}"
|
||||
>{{count}}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if link==page }}" href="/courses/{{course.name}}/cohorts/{{cohort.slug}}/{{link}}">
|
||||
{{ title }}
|
||||
{% if count != -1 %}
|
||||
<span class="badge {{'badge-primary' if link==page else 'badge-secondary'}}">
|
||||
{{ count }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
from .utils import get_course, add_nav
|
||||
from frappe.utils import get_url
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -14,7 +15,7 @@ def get_context(context):
|
||||
|
||||
context.cohorts = get_cohorts(context.course)
|
||||
if len(context.cohorts) == 1:
|
||||
frappe.local.flags.redirect_location = context.cohorts[0].get_url()
|
||||
frappe.local.flags.redirect_location = f"{get_url()}/courses/{context.course.name}/cohorts/{context.cohorts[0].slug}"
|
||||
raise frappe.Redirect
|
||||
|
||||
add_nav(context, "All Courses", "/courses")
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
{% block title %} Subgroup {{subgroup.title}} - {{ course.title }} {% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<h2 id="page-title"
|
||||
data-subgroup="{{subgroup.name}}"
|
||||
data-title="{{subgroup.title}}"
|
||||
>{{subgroup.title}} <span class="badge badge-secondary">Subgroup</span></h2>
|
||||
<div id="page-title" class="course-home-headings" data-subgroup="{{subgroup.name}}" data-title="{{subgroup.title}}">
|
||||
{{subgroup.title}}
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
{{ render_navitem("Mentors", "/mentors", stats.mentors, page=="mentors")}}
|
||||
@@ -51,31 +50,30 @@
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_mentors() %}
|
||||
<h5>Mentors</h5>
|
||||
{% set mentors = subgroup.get_mentors() %}
|
||||
{% if mentors %}
|
||||
<div class="member-parent">
|
||||
{% for m in mentors %}
|
||||
{{ widgets.MemberCard(member=m, show_course_count=False) }}
|
||||
{{ widgets.MemberCard(member=m, avatar_class="avatar-medium", show_course_count=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<em>None found.</em>
|
||||
<div>None found.</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro render_students() %}
|
||||
{% set students = subgroup.get_students() %}
|
||||
{% if students %}
|
||||
<div class="member-parent">
|
||||
{% for student in students %}
|
||||
{{ widgets.MemberCard(member=student, show_course_count=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<em>None found.</em>
|
||||
{% endif %}
|
||||
{% set students = subgroup.get_students() %}
|
||||
{% if students %}
|
||||
<div class="member-parent">
|
||||
{% for student in students %}
|
||||
{{ widgets.MemberCard(member=student, avatar_class="avatar-medium", show_course_count=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div>None found.</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -110,7 +108,7 @@
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<p><em>There are no pending join requests.</em></p>
|
||||
<div> {{ _("There are no pending join requests.") }} </div>
|
||||
{% endif %}
|
||||
{% set rejected_requests = subgroup.get_join_requests(status="Rejected") %}
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@
|
||||
|
||||
{% elif is_cohort_staff(course.name, frappe.session.user) %}
|
||||
<a class="btn btn-secondary button-links wide-button" href="/courses/{{course.name}}/manage">
|
||||
{{ _("Manage the course") }}
|
||||
{{ _("Manage Cohorts") }}
|
||||
</a>
|
||||
|
||||
{% elif membership %}
|
||||
|
||||
0
lms/www/dashboard/__init__.py
Normal file
0
lms/www/dashboard/__init__.py
Normal file
Reference in New Issue
Block a user