chore: resolved conflicts
This commit is contained in:
@@ -51,7 +51,7 @@ frappe.ready(() => {
|
||||
frappe.call({
|
||||
"method": "lms.lms.doctype.lms_batch_membership.lms_batch_membership.create_membership",
|
||||
"args": {
|
||||
"batch": {{ batch.name }},
|
||||
"batch_old": {{ batch.name }},
|
||||
"course": {{ batch.course }}
|
||||
},
|
||||
"callback": (data) => {
|
||||
|
||||
@@ -4,8 +4,8 @@ import frappe
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
batch_name = frappe.form_dict["batch"]
|
||||
context.batch = frappe.get_doc("LMS Batch", batch_name)
|
||||
context.already_a_member = context.batch.is_member(frappe.session.user)
|
||||
context.batch.course_title = frappe.db.get_value(
|
||||
"LMS Course", context.batch.course, "title"
|
||||
context.batch_old = frappe.get_doc("LMS Batch Old", batch_name)
|
||||
context.already_a_member = context.batch_old.is_member(frappe.session.user)
|
||||
context.batch_old.course_title = frappe.db.get_value(
|
||||
"LMS Course", context.batch_old.course, "title"
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ def get_context(context):
|
||||
context.page_extensions = get_page_extensions(context)
|
||||
context.page_context = {
|
||||
"course": context.course.name,
|
||||
"batch": context.batch,
|
||||
"batch_old": context.batch_old,
|
||||
"lesson": context.lesson.name if context.lesson.name else "New Lesson",
|
||||
"is_member": context.membership is not None,
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@ def get_context(context):
|
||||
context.doctype = doctype
|
||||
|
||||
if not frappe.db.exists(doctype, docname):
|
||||
print(doctype, docname)
|
||||
raise ValueError(_("Module Name is incorrect or does not exist."))
|
||||
|
||||
if doctype == "LMS Course":
|
||||
membership = frappe.db.exists(
|
||||
"LMS Batch Membership", {"member": frappe.session.user, "course": docname}
|
||||
"LMS Enrollment", {"member": frappe.session.user, "course": docname}
|
||||
)
|
||||
if membership:
|
||||
raise frappe.PermissionError(_("You are already enrolled for this course"))
|
||||
|
||||
@@ -627,21 +627,29 @@ const get_slots = () => {
|
||||
|
||||
const display_slots = (slots) => {
|
||||
let slot_html = "";
|
||||
let day = moment(this.eval_form.get_value("date")).format("dddd");
|
||||
let slots_available = false;
|
||||
if (slots.length) {
|
||||
slot_html = `<div>
|
||||
<div class="mb-2"> ${__("Select a Slot")} </div>
|
||||
<div class="slots-parent">`;
|
||||
let day = moment(this.eval_form.get_value("date")).format("dddd");
|
||||
|
||||
slots.forEach((slot) => {
|
||||
if (slot.day == day) {
|
||||
slot_html += `<div class="btn btn-sm btn-default slot" data-day="${
|
||||
slot.day
|
||||
}"
|
||||
data-start="${slot.start_time}" data-end="${slot.end_time}">
|
||||
${moment(slot.start_time, "hh:mm").format("hh:mm a")} -
|
||||
${moment(slot.end_time, "hh:mm").format("hh:mm a")}
|
||||
</div>`;
|
||||
}
|
||||
});
|
||||
slots.forEach((slot) => {
|
||||
if (slot.day == day) {
|
||||
slots_available = true;
|
||||
slot_html += `<div class="btn btn-sm btn-default slot" data-day="${
|
||||
slot.day
|
||||
}"
|
||||
data-start="${slot.start_time}" data-end="${slot.end_time}">
|
||||
${moment(slot.start_time, "hh:mm").format("hh:mm a")} -
|
||||
${moment(slot.end_time, "hh:mm").format("hh:mm a")}
|
||||
</div>`;
|
||||
}
|
||||
});
|
||||
slot_html += "</div> </div>";
|
||||
}
|
||||
|
||||
if (!slot_html) {
|
||||
if (!slots_available) {
|
||||
slot_html = `<div class="alert alert-danger" role="alert">
|
||||
No slots available for this date.
|
||||
</div>`;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if is_moderator %}
|
||||
<a class="btn btn-primary btn-sm btn-evaluate ml-2" href=/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class={{class_info.name}}">
|
||||
<a class="btn btn-primary btn-sm btn-evaluate ml-2" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class_name={{class_info.name}}">
|
||||
{{ _("Evaluate") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,78 +1,69 @@
|
||||
{% extends "www/cohorts/base.html" %}
|
||||
{% block title %}
|
||||
{{ _("Manage") }} {{ course.title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="course-home-headings">
|
||||
{{ cohort.title }}
|
||||
</div>
|
||||
{% extends "www/cohorts/base.html" %} {% block title %} {{ _("Manage") }} {{
|
||||
course.title }} {% endblock %} {% block page_content %}
|
||||
<div class="course-home-headings">{{ cohort.title }}</div>
|
||||
|
||||
<p>
|
||||
{{ 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") }}
|
||||
{{ frappe.db.count("Cohort Subgroup", {"cohort": cohort.name}) }} {{
|
||||
_("Subgroups") }} | {{ frappe.db.count("Cohort Mentor", {"cohort":
|
||||
cohort.name}) }} {{ _("Mentors") }} | {{ frappe.db.count("LMS Enrollment",
|
||||
{"cohort": cohort.name}) }} {{ _("Students") }} | {{ frappe.db.count("Cohort
|
||||
Join Request", {"cohort": cohort.name}) }} {{ _("Join Requests") }}
|
||||
</p>
|
||||
|
||||
{% if is_mentor %}
|
||||
{% set sg = mentor.get_subgroup() %}
|
||||
{% if is_mentor %} {% 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>
|
||||
<a href="{{sg.get_url()}}">
|
||||
{{ _("You are a mentor of {0} subgroup.").format(frappe.bold(sg.title))
|
||||
}}
|
||||
</a>
|
||||
</div>
|
||||
{% 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 %}
|
||||
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% 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>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,53 +1,40 @@
|
||||
{% extends "www/cohorts/base.html" %}
|
||||
{% 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 %}
|
||||
{% endblock %}
|
||||
|
||||
{% macro render_cohort(course, cohort) %}
|
||||
{% extends "www/cohorts/base.html" %} {% 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 %} {% endblock %} {% macro render_cohort(course, cohort) %}
|
||||
<div class="cards-parent">
|
||||
<div class="common-card-style flex-column p-5">
|
||||
<h5 class="card-title">
|
||||
{{ cohort.title }}
|
||||
</h5>
|
||||
<div class="common-card-style flex-column p-5">
|
||||
<h5 class="card-title">{{ cohort.title }}</h5>
|
||||
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
|
||||
<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>
|
||||
<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
|
||||
Enrollment", {"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>
|
||||
<a
|
||||
class="stretched-link"
|
||||
href="/courses/{{course.name}}/cohorts/{{cohort.slug}}"
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
@@ -85,7 +85,7 @@ def set_course_context(context, course_name):
|
||||
context.course = course
|
||||
membership = get_membership(course.name, frappe.session.user)
|
||||
context.course.query_parameter = (
|
||||
"?batch=" + membership.batch if membership and membership.batch else ""
|
||||
"?batch=" + membership.batch_old if membership and membership.batch_old else ""
|
||||
)
|
||||
context.membership = membership
|
||||
context.is_instructor = is_instructor(course.name)
|
||||
|
||||
@@ -56,7 +56,7 @@ def get_courses():
|
||||
live_courses, upcoming_courses = [], []
|
||||
for course in courses:
|
||||
course.enrollment_count = frappe.db.count(
|
||||
"LMS Batch Membership", {"course": course.name, "member_type": "Student"}
|
||||
"LMS Enrollment", {"course": course.name, "member_type": "Student"}
|
||||
)
|
||||
course.avg_rating = get_average_rating(course.name) or 0
|
||||
if course.upcoming:
|
||||
|
||||
@@ -27,9 +27,11 @@ def get_common_context(context):
|
||||
membership = get_membership(course.name, frappe.session.user, batch_name)
|
||||
context.membership = membership
|
||||
context.progress = frappe.utils.cint(membership.progress) if membership else 0
|
||||
context.batch = membership.batch if membership and membership.batch else None
|
||||
context.batch_old = (
|
||||
membership.batch_old if membership and membership.batch_old else None
|
||||
)
|
||||
context.course.query_parameter = (
|
||||
"?batch=" + membership.batch if membership and membership.batch else ""
|
||||
"?batch=" + membership.batch_old if membership and membership.batch_old else ""
|
||||
)
|
||||
context.livecode_url = get_livecode_url()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user