fix: discussion, batch home page, new fields for batches
This commit is contained in:
@@ -136,6 +136,7 @@ primary_rules = [
|
||||
{"from_route": "/hackathons/<hackathon>/<project>", "to_route": "hackathons/project"},
|
||||
{"from_route": "/dashboard", "to_route": ""},
|
||||
{"from_route": "/add-a-new-batch", "to_route": "add-a-new-batch"},
|
||||
{"from_route": "/courses/<course>/<batch>/home", "to_route": "batch/home"},
|
||||
{"from_route": "/courses/<course>/<batch>/learn", "to_route": "batch/learn"},
|
||||
{"from_route": "/courses/<course>/<batch>/learn/<int:chapter>.<int:lesson>", "to_route": "batch/learn"},
|
||||
{"from_route": "/courses/<course>/<batch>/schedule", "to_route": "batch/schedule"},
|
||||
|
||||
@@ -34,3 +34,21 @@ def submit_solution(exercise, code):
|
||||
return
|
||||
doc = ex.submit(code)
|
||||
return {"name": doc.name, "creation": doc.creation}
|
||||
|
||||
@frappe.whitelist()
|
||||
def save_current_lesson(batch_name, lesson_name):
|
||||
"""Saves the current lesson for a student/mentor.
|
||||
"""
|
||||
name = frappe.get_value(
|
||||
doctype="LMS Batch Membership",
|
||||
filters={
|
||||
"batch": batch_name,
|
||||
"member_email": frappe.session.user
|
||||
},
|
||||
fieldname="name")
|
||||
if not name:
|
||||
return
|
||||
doc = frappe.get_doc("LMS Batch Membership", name)
|
||||
doc.current_lesson = lesson_name
|
||||
doc.save(ignore_permissions=True)
|
||||
return {"current_lesson": doc.current_lesson}
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"course",
|
||||
"telegram_link",
|
||||
"code",
|
||||
"column_break_3",
|
||||
"title",
|
||||
"video_call_link",
|
||||
"batch_schedule_section",
|
||||
"start_date",
|
||||
"start_time",
|
||||
"column_break_3",
|
||||
"code",
|
||||
"column_break_10",
|
||||
"sessions_on",
|
||||
"end_time",
|
||||
"section_break_5",
|
||||
@@ -84,7 +88,8 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_5",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Batch Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9",
|
||||
@@ -92,7 +97,8 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Batch Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "start_date",
|
||||
@@ -116,6 +122,25 @@
|
||||
"fieldtype": "Time",
|
||||
"in_list_view": 1,
|
||||
"label": "End Time"
|
||||
},
|
||||
{
|
||||
"fieldname": "telegram_link",
|
||||
"fieldtype": "Data",
|
||||
"label": "Telegram Link"
|
||||
},
|
||||
{
|
||||
"fieldname": "video_call_link",
|
||||
"fieldtype": "Data",
|
||||
"label": "Video Call Link"
|
||||
},
|
||||
{
|
||||
"fieldname": "batch_schedule_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Batch Schedule"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_10",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
@@ -126,7 +151,7 @@
|
||||
"link_fieldname": "batch"
|
||||
}
|
||||
],
|
||||
"modified": "2021-05-06 05:46:38.469120",
|
||||
"modified": "2021-05-25 18:28:01.718521",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
|
||||
@@ -17,7 +17,7 @@ class LMSBatch(Document):
|
||||
|
||||
def validate_if_mentor(self):
|
||||
course = frappe.get_doc("LMS Course", self.course)
|
||||
if not course.is_mentor(frappe.session.user):
|
||||
if not course.is_mentor(frappe.session.user) and self.is_new():
|
||||
frappe.throw(_("You are not a mentor of the course {0}").format(course.title))
|
||||
|
||||
def after_insert(self):
|
||||
@@ -69,6 +69,29 @@ class LMSBatch(Document):
|
||||
message.is_author = True
|
||||
return messages
|
||||
|
||||
def get_membership(self, email):
|
||||
"""Returns the membership document of given user.
|
||||
"""
|
||||
name = frappe.get_value(
|
||||
doctype="LMS Batch Membership",
|
||||
filters={
|
||||
"batch": self.name,
|
||||
"member": email
|
||||
},
|
||||
fieldname="name")
|
||||
return frappe.get_doc("LMS Batch Membership", name)
|
||||
|
||||
def get_current_lesson(self, user):
|
||||
"""Returns the name of the current lesson for the given user.
|
||||
"""
|
||||
membership = self.get_membership(user)
|
||||
return membership and membership.current_lesson
|
||||
|
||||
def get_learn_url(self, lesson_number):
|
||||
if not lesson_number:
|
||||
return
|
||||
return f"/courses/{self.course}/{self.name}/learn/{lesson_number}"
|
||||
|
||||
@frappe.whitelist()
|
||||
def save_message(message, batch):
|
||||
doc = frappe.get_doc({
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Batch Membership', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
onload: function(frm) {
|
||||
frm.set_query('member', function(doc) {
|
||||
return {
|
||||
filters: {
|
||||
"ignore_user_type": 1,
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
"batch",
|
||||
"member",
|
||||
"member_name",
|
||||
"member_email",
|
||||
"member_username",
|
||||
"column_break_3",
|
||||
"course",
|
||||
"member_type",
|
||||
"role"
|
||||
"role",
|
||||
"current_lesson"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -59,15 +60,6 @@
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.email",
|
||||
"fieldname": "member_email",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Member Email",
|
||||
"read_only": 1,
|
||||
"read_only_depends_on": "member.email"
|
||||
},
|
||||
{
|
||||
"fetch_from": "batch.course",
|
||||
"fieldname": "course",
|
||||
@@ -75,11 +67,24 @@
|
||||
"in_list_view": 1,
|
||||
"label": "Course",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "current_lesson",
|
||||
"fieldtype": "Link",
|
||||
"label": "Current Lesson",
|
||||
"options": "Lesson"
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.username",
|
||||
"fieldname": "member_username",
|
||||
"fieldtype": "Data",
|
||||
"label": "Memeber Username",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-05-24 09:32:04.128620",
|
||||
"modified": "2021-05-24 12:40:57.125694",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch Membership",
|
||||
|
||||
@@ -17,7 +17,8 @@ class LMSBatchMembership(Document):
|
||||
previous_membership = frappe.db.get_value("LMS Batch Membership",
|
||||
filters={
|
||||
"member": self.member,
|
||||
"batch": self.batch, "name": ["!=", self.name]
|
||||
"batch": self.batch,
|
||||
"name": ["!=", self.name]
|
||||
},
|
||||
fieldname=["member_type","member"],
|
||||
as_dict=1)
|
||||
@@ -30,7 +31,8 @@ class LMSBatchMembership(Document):
|
||||
course = frappe.db.get_value("LMS Batch", self.batch, "course")
|
||||
previous_membership = frappe.get_all("LMS Batch Membership",
|
||||
filters={
|
||||
"member": self.member
|
||||
"member": self.member,
|
||||
"name": ["!=", self.name]
|
||||
},
|
||||
fields=["batch", "member_type", "name"]
|
||||
)
|
||||
|
||||
@@ -3,8 +3,76 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSBatchMembership(unittest.TestCase):
|
||||
pass
|
||||
def setUp(self):
|
||||
frappe.db.sql("DELETE FROM `tabLMS Batch Membership`")
|
||||
frappe.db.sql("DELETE FROM `tabLMS Batch`")
|
||||
frappe.db.sql('delete from `tabLMS Course Mentor Mapping`')
|
||||
frappe.db.sql("DELETE FROM `tabLMS Course`")
|
||||
frappe.db.sql("DELETE FROM `tabUser` where email like '%@test.com'")
|
||||
|
||||
def new_course_batch(self):
|
||||
course = frappe.get_doc({
|
||||
"doctype": "LMS Course",
|
||||
"name": "test-course",
|
||||
"title": "Test Course",
|
||||
"short_code": "XX"
|
||||
})
|
||||
course.insert()
|
||||
|
||||
self.new_user("mentor@test.com", "Test Mentor")
|
||||
# without this, the creating batch will fail
|
||||
course.add_mentor("mentor@test.com")
|
||||
|
||||
frappe.session.user = "mentor@test.com"
|
||||
|
||||
batch = frappe.get_doc({
|
||||
"doctype": "LMS Batch",
|
||||
"name": "test-batch",
|
||||
"title": "Test Batch",
|
||||
"course": course.name
|
||||
})
|
||||
batch.insert(ignore_permissions=True)
|
||||
|
||||
frappe.session.user = "Administrator"
|
||||
return course, batch
|
||||
|
||||
def new_user(self, email="test@test.com", full_name="Test User"):
|
||||
user = frappe.get_doc({
|
||||
"doctype": "User",
|
||||
"name": email,
|
||||
"email": email,
|
||||
"first_name": full_name,
|
||||
})
|
||||
user.insert()
|
||||
return user
|
||||
|
||||
def add_membership(self, batch_name, member_name, member_type="Student"):
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "LMS Batch Membership",
|
||||
"batch": batch_name,
|
||||
"member": member_name,
|
||||
"member_type": member_type
|
||||
})
|
||||
doc.insert()
|
||||
return doc
|
||||
|
||||
def test_membership(self):
|
||||
course, batch = self.new_course_batch()
|
||||
member = self.new_user("test01@test.com")
|
||||
membership = self.add_membership(batch.name, member.name)
|
||||
|
||||
assert membership.course == course.name
|
||||
assert membership.member_name == member.full_name
|
||||
|
||||
def test_membership_change_role(self):
|
||||
course, batch = self.new_course_batch()
|
||||
member = self.new_user("test01@test.com")
|
||||
membership = self.add_membership(batch.name, member.name)
|
||||
|
||||
# it should be possible to change role
|
||||
membership.role = "Admin"
|
||||
membership.save()
|
||||
|
||||
@@ -150,6 +150,13 @@ class LMSCourse(Document):
|
||||
"name")
|
||||
return lesson_name and frappe.get_doc("Lesson", lesson_name)
|
||||
|
||||
def get_lesson_index(self, lesson_name):
|
||||
"""Returns the {chapter_index}.{lesson_index} for the lesson.
|
||||
"""
|
||||
lesson = frappe.get_doc("Lesson", lesson_name)
|
||||
chapter = frappe.get_doc("Chapter", lesson.chapter)
|
||||
return f"{chapter.index_}.{lesson.index_}"
|
||||
|
||||
def get_outline(self):
|
||||
return CourseOutline(self)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class LMSMessage(Document):
|
||||
template = self.get_message_template()
|
||||
message = frappe._dict({
|
||||
"author_name": self.author_name,
|
||||
"message_time": frappe.utils.pretty_date(self.creation),
|
||||
"message_time": frappe.utils.format_datetime(self.creation, "dd-mm-yyyy HH:mm"),
|
||||
"message": frappe.utils.md_to_html(self.message)
|
||||
})
|
||||
|
||||
@@ -32,14 +32,16 @@ class LMSMessage(Document):
|
||||
template = frappe.render_template(template, {{
|
||||
"message": message
|
||||
}})
|
||||
$(".message-section").append(template);
|
||||
$(".messages").append(template);
|
||||
var message_element = document.getElementsByClassName("messages")[0]
|
||||
message_element.scrollTo(0, message_element.scrollHeight);
|
||||
""".format(template, message, self.owner)
|
||||
|
||||
frappe.publish_realtime(event="eval_js", message=js, after_commit=True)
|
||||
|
||||
def get_message_template(self):
|
||||
return """
|
||||
<div class="discussion {% if message.is_author %} is-author {% endif %}">
|
||||
<li class="{% if message.is_author %} ours {% endif %}">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="font-weight-bold">
|
||||
{{ message.author_name }}
|
||||
@@ -51,7 +53,7 @@ class LMSMessage(Document):
|
||||
<div class="mt-5">
|
||||
{{ message.message }}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
"""
|
||||
|
||||
def send_email(self):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="mt-5">
|
||||
<h3>{{course_name}}</h3>
|
||||
<div class="p-5 batch-header">
|
||||
<h3>{{batch_name}}</h3>
|
||||
<div class="text-muted">{{member_count}} members</div>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<div class="mt-5">
|
||||
<a class="font-weight-bold anchor_style" href="/courses">Courses</a> / <a class="font-weight-bold anchor_style" href="/courses/{{ course.name }}"> {{ course.title }}</a>
|
||||
<div class="mt-5 font-weight-bold course-title">
|
||||
<a class="anchor_style" href="/courses">Courses</a> /{% if course.is_mentor(frappe.session.user) %} <a class="anchor_style" href="/courses/{{ course.name }}"> {{ course.title }}</a> {% else %} <span class="text-muted"> {{ course.title }}</span> {% endif %}
|
||||
</div>
|
||||
<ul class="nav nav-tabs mt-4">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="learn" href="/courses/{{course.name}}/{{batch.name}}/learn">Learn</a>
|
||||
<a class="nav-link" id="home" href="/courses/{{course.name}}/{{batch.name}}/home">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="schedule" href="/courses/{{course.name}}/{{batch.name}}/schedule">Schedule</a>
|
||||
<a class="nav-link" id="learn" href="/courses/{{course.name}}/{{batch.name}}/learn">Learn</a>
|
||||
</li>
|
||||
<!-- <li class="nav-item">
|
||||
<a class="nav-link" id="schedule" href="/courses/{{course.name}}/{{batch.name}}/schedule">Schedule</a>
|
||||
</li> -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="members" href="/courses/{{course.name}}/{{batch.name}}/members">Members</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="discussion" href="/courses/{{course.name}}/{{batch.name}}/discuss">Discussion</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<!-- <li class="nav-item">
|
||||
<a class="nav-link" id="about" href="/courses/{{course.name}}/{{batch.name}}/about">About</a>
|
||||
</li>
|
||||
</li> -->
|
||||
{% if batch.is_member(frappe.session.user, member_type="Mentor") %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="progress" href="/courses/{{course.name}}/{{batch.name}}/progress">Progress</a>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="chapter-lessons">
|
||||
{% for lesson in chapter.get_lessons() %}
|
||||
<div class="lesson-teaser">
|
||||
{{lesson.title}}
|
||||
<a {% if show_link %} class="anchor_style" href="{{ batch.get_learn_url(course.get_lesson_index(lesson.name)) }}" {% endif %}>{{ lesson.title }}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
5
community/lms/widgets/CourseOutline.html
Normal file
5
community/lms/widgets/CourseOutline.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<h2>Course Outline</h2>
|
||||
|
||||
{% for chapter in course.get_chapters() %}
|
||||
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter, course=course, batch=batch, show_link=show_link)}}
|
||||
{% endfor %}
|
||||
5
community/lms/widgets/InstructorSection.html
Normal file
5
community/lms/widgets/InstructorSection.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<h3>Instructor</h3>
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{instructor.full_name}}</div>
|
||||
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
|
||||
</div>
|
||||
@@ -119,44 +119,13 @@ img.profile-photo {
|
||||
max-width: 100%
|
||||
}
|
||||
|
||||
|
||||
/* override style of base */
|
||||
|
||||
.message {
|
||||
border: 1px dashed var(--text-color);
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.dashboard__profile {
|
||||
width: 150px;
|
||||
height: 155px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.dashboard__profileSmall {
|
||||
width: 59px;
|
||||
height: 57px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.dashboard__abbr {
|
||||
font-size: 50px;
|
||||
width: 155px;
|
||||
height: 155px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.dashboard__abbrSmall {
|
||||
font-size: 20px;
|
||||
width: 59px;
|
||||
height: 57px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.msger-inputarea {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
padding: 10px;
|
||||
@@ -174,37 +143,6 @@ img.profile-photo {
|
||||
flex: 1;
|
||||
background: #ddd;
|
||||
}
|
||||
.msger-send-btn {
|
||||
margin-left: 10px;
|
||||
background: var(--cta-color);
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: background 0.23s;
|
||||
}
|
||||
|
||||
.discussion {
|
||||
border: 1px solid var(--text-color);
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 10px;
|
||||
background: var(--received-message);
|
||||
width: 50%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.is-author {
|
||||
float: right;
|
||||
background: var(--send-message);
|
||||
}
|
||||
|
||||
.batch-header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
background: var(--bg);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.message-section {
|
||||
margin-left: 3%;
|
||||
@@ -230,3 +168,38 @@ a:hover {
|
||||
section {
|
||||
padding: 5rem 0 5rem 0;
|
||||
}
|
||||
|
||||
.messages-container {
|
||||
margin: 0 auto;
|
||||
background: url("/assets/community/images/wallpaper.png");
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.messages {
|
||||
overflow: auto;
|
||||
height: 450px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
padding: 8px;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.messages li {
|
||||
background: #F7F5F5;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
margin: 2px 8px 2px 0;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.messages li.ours {
|
||||
align-self: flex-end;
|
||||
margin: 2px 0 2px 8px;
|
||||
background: #EBEEC7;
|
||||
}
|
||||
|
||||
.batch-header {
|
||||
background: #eee;
|
||||
border: 2px solid #ddd;
|
||||
}
|
||||
|
||||
BIN
community/public/images/wallpaper.png
Normal file
BIN
community/public/images/wallpaper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 922 B |
@@ -1,6 +1,4 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% from "www/macros/common_macro.html" import InstructorsSection, MentorsSection %}
|
||||
|
||||
{% block title %}About{% endblock %}
|
||||
{% block head_include %}
|
||||
<meta name="description" content="Courses" />
|
||||
@@ -14,8 +12,13 @@
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
<div class="tab-content" id="about">
|
||||
{{ CourseBasicDetail(course)}}
|
||||
{{ InstructorsSection(course.get_instructor()) }}
|
||||
{{ BatchDetails(batch)}}
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="col-lg-4 col-md-12">
|
||||
<div class="sidebar">
|
||||
{{ widgets.InstructorSection(instructor=course.get_instructor()) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -35,25 +38,3 @@
|
||||
<h2>About the Course</h2>
|
||||
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro BatchDetails(batch) %}
|
||||
<h2>About the Batch</h2>
|
||||
|
||||
<div class="batch">
|
||||
<div class="batch-details">
|
||||
<div>Session every {{batch.sessions_on}}</div>
|
||||
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
|
||||
{{frappe.utils.format_time(batch.end_time, "short")}}
|
||||
</div>
|
||||
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||
|
||||
{% for m in batch.get_mentors() %}
|
||||
<div>
|
||||
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
|
||||
<span class="instructor-title">{{m.full_name}}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -3,5 +3,3 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
|
||||
print("context", context)
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
<div class="container">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
{{ widgets.BatchHeader(course_name=course.title, member_count=member_count)}}
|
||||
<div class="messages">
|
||||
<div class="message-section">
|
||||
<div class="messages-container mt-5">
|
||||
{{ widgets.BatchHeader(batch_name=batch.title, member_count=member_count)}}
|
||||
<ol class="messages">
|
||||
{{ Messages(messages) }}
|
||||
</div>
|
||||
</ol>
|
||||
{{ TextArea() }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -24,25 +24,25 @@
|
||||
|
||||
{% macro Messages(messages) %}
|
||||
{% for message in messages %}
|
||||
<div class="discussion {% if message.is_author %} is-author {% endif %}">
|
||||
<li class="discussion {% if message.is_author %} ours {% endif %}">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="font-weight-bold">
|
||||
{{ message.author_name }}
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
{{ frappe.utils.pretty_date(message.creation) }}
|
||||
{{ frappe.utils.format_datetime(message.creation, "dd-mm-yyyy HH:mm") }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
{{ message.message }}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro TextArea() %}
|
||||
<form class="msger-inputarea">
|
||||
<form class="msger-inputarea mb-1">
|
||||
<input type="text" class="msger-input" placeholder="Write your message...">
|
||||
<button type="submit" class="msger-send-btn" data-batch="{{batch.name | urlencode }}">Send</button>
|
||||
<button type="submit" class="btn btn-primary msger-send-btn" data-batch="{{batch.name | urlencode }}">Send</button>
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -11,7 +11,9 @@ frappe.ready(() => {
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
var message_element = document.getElementsByClassName("messages")[0]
|
||||
message_element.scrollTo(0, message_element.scrollHeight);
|
||||
document.getElementsByClassName("messages-container")[0].scrollIntoView({block: "center"})
|
||||
}, 300);
|
||||
|
||||
$(".msger-send-btn").click((e) => {
|
||||
|
||||
57
community/www/batch/home.html
Normal file
57
community/www/batch/home.html
Normal file
@@ -0,0 +1,57 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}About{% endblock %}
|
||||
{% block head_include %}
|
||||
<meta name="description" content="Courses" />
|
||||
<meta name="keywords" content="" />
|
||||
|
||||
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mt-5">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
<h1 class="mt-5">{{ batch.title }}</h1>
|
||||
<div class="course-details">
|
||||
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True) }}
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-12">
|
||||
<h2>Batch Schedule</h2>
|
||||
{{ BatchDetails(batch) }}
|
||||
</div>
|
||||
<h2>Batch Details</h2>
|
||||
{{ frappe.utils.md_to_html(batch.description) }}
|
||||
{{ ConnectWithBatch(batch) }}
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% macro BatchDetails(batch) %}
|
||||
<div class="batch">
|
||||
<div class="batch-details">
|
||||
<div>Session every {{batch.sessions_on}}</div>
|
||||
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
|
||||
{{frappe.utils.format_time(batch.end_time, "short")}}
|
||||
</div>
|
||||
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||
|
||||
{% for m in batch.get_mentors() %}
|
||||
<div>
|
||||
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
|
||||
<span class="instructor-title">{{m.full_name}}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro ConnectWithBatch(batch)%}
|
||||
<h2>Connect with your Batch</h2>
|
||||
<p>
|
||||
Reach out on <a href="{{ batch.telegram_link }}">Telegram</a>.
|
||||
</p>
|
||||
<p>
|
||||
Join the <a href="{{ batch.video_call_link }}">Online Class</a>.
|
||||
</p>
|
||||
{% endmacro %}
|
||||
5
community/www/batch/home.py
Normal file
5
community/www/batch/home.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import frappe
|
||||
from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
@@ -86,49 +86,16 @@
|
||||
{{ super() }}
|
||||
{{ LiveCodeEditorJS() }}
|
||||
|
||||
|
||||
<!-- <script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var editorLookup = {};
|
||||
var batch_name = "{{ batch.name }}";
|
||||
var lesson_name = "{{ lesson.name }}";
|
||||
|
||||
$(".canvas-editor").each((i, e) => {
|
||||
var data = $(e).data();
|
||||
var editor = new LiveCodeEditor(e, {
|
||||
runtime: "python-canvas",
|
||||
base_url: "{{ livecode_url }}",
|
||||
codemirror: true,
|
||||
userdata: data,
|
||||
autosave: function(editor, code) {
|
||||
// can't autosave when user is Guest
|
||||
if (frappe.session.user == "Guest") {
|
||||
return;
|
||||
}
|
||||
var data = editor.options.userdata;
|
||||
var code = editor.codemirror.doc.getValue();
|
||||
// console.log("autosaving...")
|
||||
frappe.call("community.lms.api.autosave_section", {
|
||||
section: data.section,
|
||||
code: code
|
||||
}).then((r) => {
|
||||
// TODO: verify
|
||||
})
|
||||
}
|
||||
})
|
||||
editorLookup[data.section] = editor;
|
||||
})
|
||||
|
||||
$(".canvas-editor .reset").each((i, e) => {
|
||||
$(e).on("click", function(event) {
|
||||
var data = $(this).parents(".canvas-editor").data();
|
||||
var section = data.section;
|
||||
frappe.call("community.lms.api.get_section", {
|
||||
name: section
|
||||
}).then(r => {
|
||||
var editor = editorLookup[data.section];
|
||||
editor.codemirror.doc.setValue(r.message.contents);
|
||||
})
|
||||
})
|
||||
frappe.call("community.lms.api.save_current_lesson", {
|
||||
"batch_name": batch_name,
|
||||
"lesson_name": lesson_name
|
||||
})
|
||||
})
|
||||
</script> -->
|
||||
</script>
|
||||
|
||||
{%- endblock %}
|
||||
|
||||
@@ -10,28 +10,25 @@ def get_context(context):
|
||||
lesson_number = f"{chapter_index}.{lesson_index}"
|
||||
|
||||
course_name = context.course.name
|
||||
batch_name = context.batch.name
|
||||
|
||||
if not chapter_index or not lesson_index:
|
||||
frappe.local.flags.redirect_location = f"/courses/{course_name}/{batch_name}/learn/1.1"
|
||||
index_ = get_lesson_index(context.course, context.batch, frappe.session.user) or "1.1"
|
||||
frappe.local.flags.redirect_location = context.batch.get_learn_url(index_)
|
||||
raise frappe.Redirect
|
||||
|
||||
context.lesson = context.course.get_lesson(chapter_index, lesson_index)
|
||||
context.lesson_index = lesson_index
|
||||
context.chapter_index = chapter_index
|
||||
print(context.lesson)
|
||||
|
||||
outline = context.course.get_outline()
|
||||
prev_ = outline.get_prev(lesson_number)
|
||||
next_ = outline.get_next(lesson_number)
|
||||
context.prev_chap = get_chapter_title(course_name, prev_)
|
||||
context.next_chap = get_chapter_title(course_name, next_)
|
||||
context.next_url = get_learn_url(course_name, batch_name, next_)
|
||||
context.prev_url = get_learn_url(course_name, batch_name, prev_)
|
||||
context.next_url = context.batch.get_learn_url(next_)
|
||||
context.prev_url = context.batch.get_learn_url(prev_)
|
||||
|
||||
|
||||
def get_learn_url(course_name, batch_name, lesson_number):
|
||||
if not lesson_number:
|
||||
return
|
||||
return f"/courses/{course_name}/{batch_name}/learn/{lesson_number}"
|
||||
|
||||
def get_chapter_title(course_name, lesson_number):
|
||||
if not lesson_number:
|
||||
@@ -40,3 +37,9 @@ def get_chapter_title(course_name, lesson_number):
|
||||
lesson_index = lesson_number.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")
|
||||
|
||||
def get_lesson_index(course, batch, user):
|
||||
lesson = batch.get_current_lesson(user)
|
||||
return lesson and course.get_lesson_index(lesson)
|
||||
|
||||
|
||||
|
||||
@@ -17,25 +17,31 @@
|
||||
|
||||
|
||||
{% macro MembersList(members) %}
|
||||
<div class="mt-5 col">
|
||||
<div class="mt-5">
|
||||
{% for member in members %}
|
||||
<div class="row">
|
||||
<div class="row mb-5">
|
||||
<div>
|
||||
{{ widgets.Avatar(member=member, avatar_class="avatar-large") }}
|
||||
</div>
|
||||
<div class="ml-5">
|
||||
<a class="anchor_style" href="/{{member.username}}">
|
||||
<h3>{{ member.full_name }}</h3>
|
||||
</a>
|
||||
{% if course.is_mentor(member.name) %}
|
||||
<div class="badge badge-success">Mentor</div>
|
||||
{% endif %}
|
||||
{% if member.bio %}
|
||||
<div class="mt-5">
|
||||
<i>{{ member.bio }}</i>
|
||||
<div class="col">
|
||||
<div class="row ml-1">
|
||||
<a class="anchor_style" 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>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if member.bio %}
|
||||
<i>{{member.bio}}</i>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if loop.index != member_count %}
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -3,3 +3,4 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
print(context.members[0].bio)
|
||||
|
||||
@@ -32,8 +32,7 @@ class BatchReport:
|
||||
|
||||
def get_submissions(batch):
|
||||
students = batch.get_students()
|
||||
students_map = {s['email']: s for s in students}
|
||||
|
||||
students_map = {s.email: s for s in students}
|
||||
names, values = nparams("s", students_map.keys())
|
||||
|
||||
sql = """
|
||||
|
||||
@@ -13,7 +13,7 @@ def get_common_context(context):
|
||||
return
|
||||
|
||||
batch = course.get_batch(batch_name)
|
||||
if not batch:
|
||||
if not batch or not batch.is_member(frappe.session.user):
|
||||
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||
raise frappe.Redirect
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% from "www/macros/common_macro.html" import InstructorsSection, MentorsSection %}
|
||||
{% from "www/macros/common_macro.html" import MentorsSection %}
|
||||
{% block title %}{{ course.title }}{% endblock %}
|
||||
{% block head_include %}
|
||||
<meta name="description" content="Courses" />
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
{{ CourseDescription(course) }}
|
||||
{{ BatchSection(course) }}
|
||||
{{ CourseOutline(course) }}
|
||||
{{ widgets.CourseOutline(course=course, show_link=False) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-12">
|
||||
<div class="sidebar">
|
||||
{{ InstructorsSection(course.get_instructor()) }}
|
||||
{{ widgets.InstructorSection(instructor=course.get_instructor()) }}
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user), course.name) }}
|
||||
@@ -88,7 +88,7 @@
|
||||
<div class="cta">
|
||||
<div class="">
|
||||
{% if can_manage %}
|
||||
<a href="/courses/{{course.name}}/{{batch.name}}/about" class="btn btn-secondary">Manage</a>
|
||||
<a href="/courses/{{course.name}}/{{batch.name}}/about" class="btn btn-primary">Manage</a>
|
||||
{% else %}
|
||||
<button class="join-batch btn btn-primary" data-batch="{{ batch.name | urlencode }}"
|
||||
data-course="{{ course.name | urlencode }}">Join this Batch</button>
|
||||
@@ -114,11 +114,11 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<a class="btn btn-primary add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}">Add a new batch</a>
|
||||
<a class="add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}">Add a new batch</a>
|
||||
{% else %}
|
||||
<div class="mentor_message">
|
||||
<p> You are a mentor for this course. </p>
|
||||
<a class="btn btn-primary" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}" >Create your first batch</a>
|
||||
<a class="" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}" >Create your first batch</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -134,11 +134,3 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro CourseOutline(course) %}
|
||||
<h2>Course Outline</h2>
|
||||
|
||||
{% for chapter in course.get_chapters() %}
|
||||
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter)}}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
{% macro InstructorsSection(instructor) %}
|
||||
<h3>Instructor</h3>
|
||||
<div class="instructor">
|
||||
<div class="instructor-title">{{instructor.full_name}}</div>
|
||||
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro MentorsSection(mentors, is_mentor, course_name) %}
|
||||
<h3>Mentors</h3>
|
||||
{% for m in mentors %}
|
||||
|
||||
Reference in New Issue
Block a user