This commit is contained in:
pateljannat
2021-06-10 13:41:11 +05:30
parent d90a1247f1
commit 1e3152e303
22 changed files with 120 additions and 105 deletions

View File

@@ -11,26 +11,28 @@
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/" + batch.name + "/join" %}
<div class="container mt-5">
{{ widgets.BatchTabs(course=course, batch=batch) }}
<div>
<!-- <div>
<h1 class="mt-5">{{ batch.title }}</h1>
</div>
<div class="course-details">
</div> -->
<div class="course-details mt-5">
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True, show_progress=True) }}
</div>
<div class="w-25">
<h2>Batch Schedule</h2>
<h3>Batch Schedule</h3>
{{ widgets.RenderBatch(course=course, batch=batch) }}
</div>
{% if batch.description %}
<h2>Batch Details</h2>
{{ frappe.utils.md_to_html(batch.description) }}
<div class="mt-5">
<h3>Batch Details</h3>
{{ frappe.utils.md_to_html(batch.description) }}
</div>
{% endif %}
{% if course.is_mentor(frappe.session.user) %}
<div class="">
<h2> Invite Members </h2>
<a href="" class="anchor_style mr-5" id="invite-link" data-link="{{ invite_link }}">Get Batch Invitation
<h3> Invite Members </h3>
<a href="" class="" id="invite-link" data-link="{{ invite_link }}">Get Batch Invitation
Link</a>
<small id="copy-message" class="text-muted pull-right" style="display: none;">Copied to Clipboard.</small>
</div>

View File

@@ -1,6 +1,7 @@
from re import I
import frappe
from . import utils
from frappe.utils import cstr
def get_context(context):
utils.get_common_context(context)
@@ -10,9 +11,10 @@ def get_context(context):
lesson_number = f"{chapter_index}.{lesson_index}"
course_name = context.course.name
print(chapter_index, lesson_index)
if not chapter_index or not lesson_index:
index_ = get_lesson_index(context.course, context.batch, frappe.session.user) or "1.1"
print(index_)
frappe.local.flags.redirect_location = context.batch.get_learn_url(index_)
raise frappe.Redirect
@@ -33,8 +35,9 @@ def get_context(context):
def get_chapter_title(course_name, lesson_number):
if not lesson_number:
return
chapter_index = lesson_number.split(".")[0]
lesson_index = lesson_number.split(".")[1]
lesson_split = cstr(lesson_number).split(".")
chapter_index = lesson_split[0]
lesson_index = lesson_split[1]
chapter_name = frappe.db.get_value("Chapter", {"course": course_name, "index_": chapter_index}, "name")
return frappe.db.get_value("Lesson", {"chapter": chapter_name, "index_": lesson_index}, "title")

View File

@@ -19,23 +19,19 @@
{% macro MembersList(members) %}
<div class="mt-5">
{% for member in members %}
<div class="row mb-5">
<div>
{{ widgets.Avatar(member=member, avatar_class="avatar-large") }}
</div>
<div class="col">
<div class="row ml-1">
<a class="anchor_style" href="/{{member.username}}">
<div class="d-flex align-items-center">
{{ widgets.Avatar(member=member, avatar_class="avatar-large") }}
<div class="d-flex flex-column ml-2">
<div class="d-flex">
<a class="anchor_style ml-2" href="/{{member.username}}">
<h3>{{ member.full_name }}</h3>
</a>
{% if course.is_mentor(member.name) %}
<div class="ml-2">
<div class="badge badge-success">Mentor</div>
</div>
<div class="badge badge-success ml-2 align-self-start">Mentor</div>
{% endif %}
</div>
{% if member.bio %}
<i>{{member.bio}}</i>
<i class="ml-2">{{member.bio}}</i>
{% endif %}
</div>
</div>

View File

@@ -26,7 +26,7 @@
<div class="container">
{{ widgets.BatchTabs(course=course, batch=batch) }}
<div class="mentor-dashboard">
<h1>Batch Progress</h1>
<h3>Batch Progress</h3>
{% for exercise in report.exercises %}
<div class="exercise-submissions">
<h2>Exercise {{exercise.index_label}}: {{exercise.title}}</h2>

View File

@@ -14,12 +14,13 @@ def get_context(context):
context.exercise = exercise
context.report = BatchReport(context.course, context.batch)
print(context.report)
class BatchReport:
def __init__(self, course, batch):
self.submissions = get_submissions(batch)
self.exercises = self.get_exercises(course.name)
print(self.submissions)
self.submissions_by_exercise = defaultdict(list)
for s in self.submissions:
self.submissions_by_exercise[s.exercise].append(s)
@@ -34,7 +35,7 @@ def get_submissions(batch):
students = batch.get_students()
students_map = {s.email: s for s in students}
names, values = nparams("s", students_map.keys())
print(students, names, values)
sql = """
select owner, exercise, name, solution, creation, image
from (
@@ -45,7 +46,7 @@ def get_submissions(batch):
""".format(names)
data = frappe.db.sql(sql, values=values, as_dict=True)
print(data)
for row in data:
row['owner'] = students_map[row['owner']]
return data

View File

@@ -1,21 +1,20 @@
import frappe
from community.lms.models import Course
from community.lms.models import Course, Membership
def get_common_context(context):
context.no_cache = 1
course_name = frappe.form_dict["course"]
batch_name = frappe.form_dict["batch"]
course = Course.find(course_name)
if not course:
context.template = "www/404.html"
return
batch_name = Membership.get_user_batch(course_name)
batch = course.get_batch(batch_name)
if not batch or not batch.is_member(frappe.session.user):
""" if not batch or not batch.is_member(frappe.session.user):
frappe.local.flags.redirect_location = "/courses/" + course_name
raise frappe.Redirect
raise frappe.Redirect """
context.course = course
context.batch = batch