Compare commits
24 Commits
style-fixe
...
lesson-mar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9185c0b6b | ||
|
|
5363fb7eb3 | ||
|
|
d90a1247f1 | ||
|
|
ef0c3e4a24 | ||
|
|
3619b136f8 | ||
|
|
671b4a0650 | ||
|
|
586b39c0fd | ||
|
|
4fd7af053b | ||
|
|
5fd1143f76 | ||
|
|
0dc4743556 | ||
|
|
c96a14c972 | ||
|
|
400e706be1 | ||
|
|
a12a52747e | ||
|
|
b9a93bb160 | ||
|
|
9c65ff8ae6 | ||
|
|
bb0aa09b4e | ||
|
|
a8752afb3b | ||
|
|
327bde870b | ||
|
|
640ead4922 | ||
|
|
687f7f7f7b | ||
|
|
527a563e4a | ||
|
|
5bc9a7fe37 | ||
|
|
3648b3ab47 | ||
|
|
823cf4e431 |
@@ -143,7 +143,8 @@ primary_rules = [
|
|||||||
{"from_route": "/courses/<course>/<batch>/members", "to_route": "batch/members"},
|
{"from_route": "/courses/<course>/<batch>/members", "to_route": "batch/members"},
|
||||||
{"from_route": "/courses/<course>/<batch>/discuss", "to_route": "batch/discuss"},
|
{"from_route": "/courses/<course>/<batch>/discuss", "to_route": "batch/discuss"},
|
||||||
{"from_route": "/courses/<course>/<batch>/about", "to_route": "batch/about"},
|
{"from_route": "/courses/<course>/<batch>/about", "to_route": "batch/about"},
|
||||||
{"from_route": "/courses/<course>/<batch>/progress", "to_route": "batch/progress"}
|
{"from_route": "/courses/<course>/<batch>/progress", "to_route": "batch/progress"},
|
||||||
|
{"from_route": "/courses/<course>/<batch>/join", "to_route": "batch/join"}
|
||||||
]
|
]
|
||||||
|
|
||||||
# Any frappe default URL is blocked by profile-rules, add it here to unblock it
|
# Any frappe default URL is blocked by profile-rules, add it here to unblock it
|
||||||
@@ -175,3 +176,15 @@ profile_rules = [
|
|||||||
website_route_rules = primary_rules + whitelist_rules + profile_rules
|
website_route_rules = primary_rules + whitelist_rules + profile_rules
|
||||||
|
|
||||||
update_website_context = 'community.widgets.update_website_context'
|
update_website_context = 'community.widgets.update_website_context'
|
||||||
|
|
||||||
|
## Specify the additional tabs to be included in the user profile page.
|
||||||
|
## Each entry must be a subclass of community.community.plugins.ProfileTab
|
||||||
|
# profile_tabs = []
|
||||||
|
|
||||||
|
## Specify the extension to be used to control what scripts and stylesheets
|
||||||
|
## to be included in lesson pages. The specified value must be be a
|
||||||
|
## subclass of community.community.plugins.PageExtension
|
||||||
|
# community_lesson_page_extension = None
|
||||||
|
|
||||||
|
## Markdown Macros for Lessons
|
||||||
|
# community_markdown_macro_renderers = {"Exercise": "myapp.mymodule.plugins.render_exercise"}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def save_current_lesson(batch_name, lesson_name):
|
|||||||
doctype="LMS Batch Membership",
|
doctype="LMS Batch Membership",
|
||||||
filters={
|
filters={
|
||||||
"batch": batch_name,
|
"batch": batch_name,
|
||||||
"member_email": frappe.session.user
|
"member": frappe.session.user
|
||||||
},
|
},
|
||||||
fieldname="name")
|
fieldname="name")
|
||||||
if not name:
|
if not name:
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ class Chapter(Document):
|
|||||||
def get_lessons(self):
|
def get_lessons(self):
|
||||||
rows = frappe.db.get_all("Lesson",
|
rows = frappe.db.get_all("Lesson",
|
||||||
filters={"chapter": self.name},
|
filters={"chapter": self.name},
|
||||||
fields='*',
|
fields='name',
|
||||||
order_by="index_")
|
order_by="index_")
|
||||||
return [frappe.get_doc(dict(row, doctype='Lesson')) for row in rows]
|
return [frappe.get_doc('Lesson', row['name']) for row in rows]
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
"hints",
|
"hints",
|
||||||
"tests",
|
"tests",
|
||||||
"image",
|
"image",
|
||||||
"lesson"
|
"lesson",
|
||||||
|
"index_",
|
||||||
|
"index_label"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -27,6 +29,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"options": "LMS Course"
|
"options": "LMS Course"
|
||||||
},
|
},
|
||||||
@@ -73,13 +76,27 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "lesson",
|
"fieldname": "lesson",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Lesson",
|
"label": "Lesson",
|
||||||
"options": "Lesson"
|
"options": "Lesson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "index_",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Index",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "index_label",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Index Label",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-20 13:23:12.340928",
|
"modified": "2021-06-01 05:22:15.656013",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Exercise",
|
"name": "Exercise",
|
||||||
@@ -99,8 +116,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"search_fields": "title",
|
"search_fields": "title",
|
||||||
"sort_field": "modified",
|
"sort_field": "index_label",
|
||||||
"sort_order": "DESC",
|
"sort_order": "ASC",
|
||||||
"title_field": "title",
|
"title_field": "title",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@ class Exercise(Document):
|
|||||||
order_by="creation desc",
|
order_by="creation desc",
|
||||||
page_length=1)
|
page_length=1)
|
||||||
|
|
||||||
print("get_user_submission", result)
|
|
||||||
if result:
|
if result:
|
||||||
return result[0]
|
return result[0]
|
||||||
|
|
||||||
@@ -55,5 +54,6 @@ class Exercise(Document):
|
|||||||
image=image,
|
image=image,
|
||||||
solution=code)
|
solution=code)
|
||||||
doc.insert(ignore_permissions=True)
|
doc.insert(ignore_permissions=True)
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
# Copyright (c) 2021, FOSS United and contributors
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from ..lesson.lesson import update_progress
|
||||||
|
|
||||||
class ExerciseSubmission(Document):
|
class ExerciseSubmission(Document):
|
||||||
pass
|
|
||||||
|
def after_insert(self):
|
||||||
|
course_details = frappe.get_doc("LMS Course", self.course)
|
||||||
|
if not (course_details.is_mentor(frappe.session.user) or frappe.flags.in_test):
|
||||||
|
update_progress(self.lesson)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"lesson_type",
|
"lesson_type",
|
||||||
"title",
|
"title",
|
||||||
"index_",
|
"index_",
|
||||||
|
"index_label",
|
||||||
"body",
|
"body",
|
||||||
"sections"
|
"sections"
|
||||||
],
|
],
|
||||||
@@ -51,11 +52,18 @@
|
|||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Sections",
|
"label": "Sections",
|
||||||
"options": "LMS Section"
|
"options": "LMS Section"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "index_label",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Index Label",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-13 20:03:51.510605",
|
"modified": "2021-06-01 05:30:48.127494",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Lesson",
|
"name": "Lesson",
|
||||||
|
|||||||
@@ -6,20 +6,50 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from ...section_parser import SectionParser
|
from ...section_parser import SectionParser
|
||||||
|
from ...md import markdown_to_html, find_macros
|
||||||
|
|
||||||
class Lesson(Document):
|
class Lesson(Document):
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
sections = SectionParser().parse(self.body or "")
|
macros = find_macros(self.body)
|
||||||
self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)]
|
exercises = [value for name, value in macros if name == "Exercise"]
|
||||||
for s in self.sections:
|
|
||||||
if s.type == "exercise":
|
index = 1
|
||||||
e = s.get_exercise()
|
for name in exercises:
|
||||||
e.lesson = self.name
|
e = frappe.get_doc("Exercise", name)
|
||||||
e.save()
|
e.lesson = self.name
|
||||||
|
e.index_ = index
|
||||||
|
e.save()
|
||||||
|
index += 1
|
||||||
|
self.update_orphan_exercises(exercises)
|
||||||
|
|
||||||
|
def update_orphan_exercises(self, active_exercises):
|
||||||
|
"""Updates the exercises that were previously part of this lesson,
|
||||||
|
but not any more.
|
||||||
|
"""
|
||||||
|
linked_exercises = {row['name'] for row in frappe.get_all('Exercise', {"lesson": self.name})}
|
||||||
|
active_exercises = set(active_exercises)
|
||||||
|
orphan_exercises = linked_exercises - active_exercises
|
||||||
|
for name in orphan_exercises:
|
||||||
|
ex = frappe.get_doc("Exercise", name)
|
||||||
|
ex.lesson = None
|
||||||
|
ex.index_ = 0
|
||||||
|
ex.index_label = ""
|
||||||
|
ex.save()
|
||||||
|
|
||||||
|
def render_html(self):
|
||||||
|
return markdown_to_html(self.body)
|
||||||
|
|
||||||
def get_sections(self):
|
def get_sections(self):
|
||||||
return sorted(self.get('sections'), key=lambda s: s.index)
|
return sorted(self.get('sections'), key=lambda s: s.index)
|
||||||
|
|
||||||
|
def get_exercises(self):
|
||||||
|
if not self.body:
|
||||||
|
return []
|
||||||
|
|
||||||
|
macros = find_macros(self.body)
|
||||||
|
exercises = [value for name, value in macros if name == "Exercise"]
|
||||||
|
return [frappe.get_doc("Exercise", name) for name in exercises]
|
||||||
|
|
||||||
def make_lms_section(self, index, section):
|
def make_lms_section(self, index, section):
|
||||||
s = frappe.new_doc('LMS Section', parent_doc=self, parentfield='sections')
|
s = frappe.new_doc('LMS Section', parent_doc=self, parentfield='sections')
|
||||||
s.type = section.type
|
s.type = section.type
|
||||||
@@ -43,3 +73,65 @@ class Lesson(Document):
|
|||||||
The return value would be like 1.2, 2.1 etc.
|
The return value would be like 1.2, 2.1 etc.
|
||||||
It will be None if there is no next lesson.
|
It will be None if there is no next lesson.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_progress(self):
|
||||||
|
return frappe.db.get_value("LMS Course Progress", {"lesson": self.name, "owner": frappe.session.user}, "status")
|
||||||
|
|
||||||
|
def get_slugified_class(self):
|
||||||
|
if self.get_progress():
|
||||||
|
return ("").join([ s for s in self.get_progress().lower().split() ])
|
||||||
|
return
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def save_progress(lesson, batch):
|
||||||
|
if not frappe.db.exists("LMS Batch Membership",
|
||||||
|
{
|
||||||
|
"member": frappe.session.user,
|
||||||
|
"batch": batch
|
||||||
|
}):
|
||||||
|
return
|
||||||
|
if frappe.db.exists("LMS Course Progress",
|
||||||
|
{
|
||||||
|
"lesson": lesson,
|
||||||
|
"owner": frappe.session.user
|
||||||
|
}):
|
||||||
|
return
|
||||||
|
|
||||||
|
lesson_details = frappe.get_doc("Lesson", lesson)
|
||||||
|
dynamic_content = frappe.db.count("LMS Section",
|
||||||
|
filters={
|
||||||
|
"type": ["not in", ["example", "text"]],
|
||||||
|
"parent": lesson_details.name
|
||||||
|
})
|
||||||
|
|
||||||
|
status = "Complete"
|
||||||
|
if dynamic_content:
|
||||||
|
status = "Partially Complete"
|
||||||
|
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "LMS Course Progress",
|
||||||
|
"lesson": lesson_details.name,
|
||||||
|
"status": status
|
||||||
|
}).save(ignore_permissions=True)
|
||||||
|
|
||||||
|
def update_progress(lesson):
|
||||||
|
user = frappe.session.user
|
||||||
|
if not all_dynamic_content_submitted(lesson, user):
|
||||||
|
return
|
||||||
|
if frappe.db.exists("LMS Course Progress", {"lesson": lesson, "owner": user}):
|
||||||
|
course_progress = frappe.get_doc("LMS Course Progress", {"lesson": lesson, "owner": user})
|
||||||
|
course_progress.status = "Complete"
|
||||||
|
course_progress.save()
|
||||||
|
|
||||||
|
def all_dynamic_content_submitted(lesson, user):
|
||||||
|
exercise_names = frappe.get_list("Exercise", {"lesson": lesson}, ["name"], pluck="name")
|
||||||
|
all_exercises_submitted = False
|
||||||
|
print(exercise_names)
|
||||||
|
query = {
|
||||||
|
"exercise": ["in", exercise_names],
|
||||||
|
"owner": user
|
||||||
|
}
|
||||||
|
if frappe.db.count("Exercise Submission", query) == len(exercise_names):
|
||||||
|
all_exercises_submitted = True
|
||||||
|
|
||||||
|
return all_exercises_submitted
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [
|
||||||
|
{
|
||||||
|
"action": "community.lms.doctype.lms_course.lms_course.reindex_lessons",
|
||||||
|
"action_type": "Server Action",
|
||||||
|
"group": "Reindex",
|
||||||
|
"label": "Reindex Lessons"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "community.lms.doctype.lms_course.lms_course.reindex_exercises",
|
||||||
|
"action_type": "Server Action",
|
||||||
|
"group": "Reindex",
|
||||||
|
"label": "Reindex Exercises"
|
||||||
|
}
|
||||||
|
],
|
||||||
"allow_guest_to_view": 1,
|
"allow_guest_to_view": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"creation": "2021-03-01 16:49:33.622422",
|
"creation": "2021-03-01 16:49:33.622422",
|
||||||
@@ -86,7 +99,7 @@
|
|||||||
"link_fieldname": "course"
|
"link_fieldname": "course"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-05-23 18:14:32.602647",
|
"modified": "2021-06-01 04:36:45.696776",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Course",
|
"name": "LMS Course",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
import json
|
||||||
from ...utils import slugify
|
from ...utils import slugify
|
||||||
from community.query import find, find_all
|
from community.query import find, find_all
|
||||||
|
|
||||||
@@ -157,6 +158,35 @@ class LMSCourse(Document):
|
|||||||
chapter = frappe.get_doc("Chapter", lesson.chapter)
|
chapter = frappe.get_doc("Chapter", lesson.chapter)
|
||||||
return f"{chapter.index_}.{lesson.index_}"
|
return f"{chapter.index_}.{lesson.index_}"
|
||||||
|
|
||||||
|
def reindex_lessons(self):
|
||||||
|
for i, c in enumerate(self.get_chapters(), start=1):
|
||||||
|
c.index_ = i
|
||||||
|
c.save()
|
||||||
|
self._reindex_lessons_in_chapter(c)
|
||||||
|
|
||||||
|
def _reindex_lessons_in_chapter(self, c):
|
||||||
|
for i, lesson in enumerate(c.get_lessons(), start=1):
|
||||||
|
lesson.index = i
|
||||||
|
lesson.index_label = f"{c.index_}.{i}"
|
||||||
|
lesson.save()
|
||||||
|
|
||||||
|
def reindex_exercises(self):
|
||||||
|
for i, c in enumerate(self.get_chapters(), start=1):
|
||||||
|
if c.index_ != i:
|
||||||
|
c.index_ = i
|
||||||
|
c.save()
|
||||||
|
self._reindex_exercises_in_chapter(c)
|
||||||
|
|
||||||
|
def _reindex_exercises_in_chapter(self, c):
|
||||||
|
i = 1
|
||||||
|
for lesson in c.get_lessons():
|
||||||
|
for exercise in lesson.get_exercises():
|
||||||
|
exercise.index_ = i
|
||||||
|
exercise.index_label = f"{c.index_}.{i}"
|
||||||
|
exercise.save()
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def get_outline(self):
|
def get_outline(self):
|
||||||
return CourseOutline(self)
|
return CourseOutline(self)
|
||||||
|
|
||||||
@@ -187,7 +217,8 @@ class CourseOutline:
|
|||||||
def get_chapters(self):
|
def get_chapters(self):
|
||||||
return frappe.db.get_all("Chapter",
|
return frappe.db.get_all("Chapter",
|
||||||
filters={"course": self.course.name},
|
filters={"course": self.course.name},
|
||||||
fields=["name", "title", "index_"])
|
fields=["name", "title", "index_"],
|
||||||
|
order_by="index_")
|
||||||
|
|
||||||
def get_lessons(self):
|
def get_lessons(self):
|
||||||
chapters = [c['name'] for c in self.chapters]
|
chapters = [c['name'] for c in self.chapters]
|
||||||
@@ -199,3 +230,17 @@ class CourseOutline:
|
|||||||
for lesson in lessons:
|
for lesson in lessons:
|
||||||
lesson['number'] = "{}.{}".format(chapter_numbers[lesson['chapter']], lesson['index_'])
|
lesson['number'] = "{}.{}".format(chapter_numbers[lesson['chapter']], lesson['index_'])
|
||||||
return lessons
|
return lessons
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def reindex_lessons(doc):
|
||||||
|
course_data = json.loads(doc)
|
||||||
|
course = frappe.get_doc("LMS Course", course_data['name'])
|
||||||
|
course.reindex_lessons()
|
||||||
|
frappe.msgprint("All lessons in this course have been re-indexed.")
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def reindex_exercises(doc):
|
||||||
|
course_data = json.loads(doc)
|
||||||
|
course = frappe.get_doc("LMS Course", course_data['name'])
|
||||||
|
course.reindex_exercises()
|
||||||
|
frappe.msgprint("All exercises in this course have been re-indexed.")
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('LMS Course Progress', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-31 17:20:13.388453",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"status",
|
||||||
|
"column_break_3",
|
||||||
|
"lesson",
|
||||||
|
"chapter",
|
||||||
|
"course"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fetch_from": "chapter.course",
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "lesson.chapter",
|
||||||
|
"fieldname": "chapter",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Chapter",
|
||||||
|
"options": "Chapter",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lesson",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Lesson",
|
||||||
|
"options": "Lesson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "status",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Status",
|
||||||
|
"options": "Complete\nPartially Complete\nIncomplete"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_3",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-06-02 13:05:31.114939",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "LMS Course Progress",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class LMSCourseProgress(Document):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestLMSCourseProgress(unittest.TestCase):
|
||||||
|
pass
|
||||||
107
community/lms/md.py
Normal file
107
community/lms/md.py
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
"""
|
||||||
|
The md module extends markdown to add macros.
|
||||||
|
|
||||||
|
Macros can be added to the markdown text in the following format.
|
||||||
|
|
||||||
|
{{ MacroName("macro-argument") }}
|
||||||
|
|
||||||
|
These macros will be rendered using a pluggable mechanism.
|
||||||
|
|
||||||
|
Apps can provide a hook community_markdown_macro_renderers, a
|
||||||
|
dictionary mapping the macro name to the function that to render
|
||||||
|
that macro. The function will get the argument passed to the macro
|
||||||
|
as argument.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
import re
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import markdown
|
||||||
|
from markdown import Extension
|
||||||
|
from markdown.inlinepatterns import InlineProcessor
|
||||||
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
|
def markdown_to_html(text):
|
||||||
|
"""Renders markdown text into html.
|
||||||
|
"""
|
||||||
|
return markdown.markdown(text, extensions=['fenced_code', MacroExtension()])
|
||||||
|
|
||||||
|
def find_macros(text):
|
||||||
|
"""Returns all macros in the given text.
|
||||||
|
|
||||||
|
>>> find_macros(text)
|
||||||
|
[
|
||||||
|
('YouTubeVideo': 'abcd1234')
|
||||||
|
('Exercise', 'two-circles'),
|
||||||
|
('Exercise', 'four-circles')
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
macros = re.findall(MACRO_RE, text)
|
||||||
|
# remove the quotes around the argument
|
||||||
|
return [(name, _remove_quotes(arg)) for name, arg in macros]
|
||||||
|
|
||||||
|
def _remove_quotes(value):
|
||||||
|
"""Removes quotes around a value.
|
||||||
|
|
||||||
|
Also strips the whitespace.
|
||||||
|
|
||||||
|
>>> _remove_quotes('"hello"')
|
||||||
|
'hello'
|
||||||
|
>>> _remove_quotes("'hello'")
|
||||||
|
'hello'
|
||||||
|
>>> _remove_quotes("hello")
|
||||||
|
'hello'
|
||||||
|
"""
|
||||||
|
return value.strip(" '\"")
|
||||||
|
|
||||||
|
|
||||||
|
def get_macro_registry():
|
||||||
|
d = frappe.get_hooks("community_markdown_macro_renderers") or {}
|
||||||
|
return {name: frappe.get_attr(klass[0]) for name, klass in d.items()}
|
||||||
|
|
||||||
|
def render_macro(macro_name, macro_argument):
|
||||||
|
# stripping the quotes on either side of the argument
|
||||||
|
macro_argument = _remove_quotes(macro_argument)
|
||||||
|
|
||||||
|
registry = get_macro_registry()
|
||||||
|
if macro_name in registry:
|
||||||
|
return registry[macro_name](macro_argument)
|
||||||
|
else:
|
||||||
|
return f"<p>Unknown macro: {macro_name}</p>"
|
||||||
|
|
||||||
|
MACRO_RE = r'{{ *(\w+)\(([^{}]*)\) *}}'
|
||||||
|
|
||||||
|
class MacroExtension(Extension):
|
||||||
|
"""MacroExtension is a markdown extension to support macro syntax.
|
||||||
|
"""
|
||||||
|
def extendMarkdown(self, md):
|
||||||
|
self.md = md
|
||||||
|
pattern = MacroInlineProcessor(MACRO_RE)
|
||||||
|
pattern.md = md
|
||||||
|
md.inlinePatterns.register(pattern, 'macro', 75)
|
||||||
|
|
||||||
|
class MacroInlineProcessor(InlineProcessor):
|
||||||
|
"""MacroInlineProcessor is class that is handles the logic
|
||||||
|
of how to render each macro occurence in the markdown text.
|
||||||
|
"""
|
||||||
|
def handleMatch(self, m, data):
|
||||||
|
"""Handles each macro match and return rendered contents
|
||||||
|
for that macro as an etree node.
|
||||||
|
"""
|
||||||
|
macro = m.group(1)
|
||||||
|
arg = m.group(2)
|
||||||
|
html = render_macro(macro, arg)
|
||||||
|
html = sanitize_html(str(html))
|
||||||
|
e = etree.fromstring(html)
|
||||||
|
return e, m.start(0), m.end(0)
|
||||||
|
|
||||||
|
def sanitize_html(html):
|
||||||
|
"""Sanotize the html using BeautifulSoup.
|
||||||
|
|
||||||
|
The markdown processor request the correct markup and crashes on
|
||||||
|
any broken tags. This makes sures that all those things are fixed
|
||||||
|
before passing to the etree parser.
|
||||||
|
"""
|
||||||
|
soup = BeautifulSoup(html, features="lxml")
|
||||||
|
nodes = soup.body.children
|
||||||
|
return "<div>" + "\n".join(str(node) for node in nodes) + "</div>"
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"login_required": 1,
|
"login_required": 1,
|
||||||
"max_attachment_size": 0,
|
"max_attachment_size": 0,
|
||||||
"modified": "2021-04-30 11:22:18.188712",
|
"modified": "2021-06-02 15:52:06.383260",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "add-a-new-batch",
|
"name": "add-a-new-batch",
|
||||||
@@ -38,13 +38,13 @@
|
|||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"options": "",
|
"options": "LMS Course",
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
{% for lesson in chapter.get_lessons() %}
|
{% for lesson in chapter.get_lessons() %}
|
||||||
<div class="lesson-teaser">
|
<div class="lesson-teaser">
|
||||||
<a {% if show_link %} class="anchor_style" href="{{ batch.get_learn_url(course.get_lesson_index(lesson.name)) }}" {% endif %}>{{ lesson.title }}</a>
|
<a {% if show_link %} class="anchor_style" href="{{ batch.get_learn_url(course.get_lesson_index(lesson.name)) }}" {% endif %}>{{ lesson.title }}</a>
|
||||||
|
{% if show_progress and not course.is_mentor(frappe.session.user) and lesson.get_progress() %}
|
||||||
|
<a class="pull-right badge p-1 {{ lesson.get_slugified_class() }}"> <img class="progress-image" src="/assets/community/images/Vector.png"> {{ lesson.get_progress() }}</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<h2>Course Outline</h2>
|
<h2>Course Outline</h2>
|
||||||
|
|
||||||
{% for chapter in course.get_chapters() %}
|
{% for chapter in course.get_chapters() %}
|
||||||
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter, course=course, batch=batch, show_link=show_link)}}
|
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter, course=course, batch=batch, show_link=show_link, show_progress=show_progress)}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %}
|
{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %}
|
||||||
|
|
||||||
<div class="exercise">
|
<div class="exercise">
|
||||||
<h2>{{ exercise.title }}</h2>
|
<h2>Exercise {{exercise.index_label}}: {{ exercise.title }}</h2>
|
||||||
<div class="exercise-description">{{frappe.utils.md_to_html(exercise.description)}}</div>
|
<div class="exercise-description">{{frappe.utils.md_to_html(exercise.description)}}</div>
|
||||||
|
|
||||||
{% if exercise.image %}
|
{% if exercise.image %}
|
||||||
|
|||||||
29
community/lms/widgets/RenderBatch.html
Normal file
29
community/lms/widgets/RenderBatch.html
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<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>
|
||||||
|
{% if can_manage or can_join %}
|
||||||
|
<div class="cta">
|
||||||
|
<div class="">
|
||||||
|
{% if can_manage %}
|
||||||
|
<a href="/courses/{{course.name}}/{{batch.name}}/home" class="btn btn-primary">Manage</a>
|
||||||
|
{% elif can_join %}
|
||||||
|
<button class="join-batch btn btn-primary" data-batch="{{ batch.name | urlencode }}"
|
||||||
|
data-course="{{ course.name | urlencode }}">Join this Batch</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
66
community/plugins.py
Normal file
66
community/plugins.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
"""
|
||||||
|
The plugins module provides various plugins to change the default
|
||||||
|
behaviour some parts of the community app.
|
||||||
|
|
||||||
|
A site specify what plugins to use using appropriate entries in the frappe
|
||||||
|
hooks, written in the `hooks.py`.
|
||||||
|
|
||||||
|
This module exposes two plugins: ProfileTab and PageExtension.
|
||||||
|
|
||||||
|
The ProfileTab is used to specify any additional tabs to be displayed
|
||||||
|
on the profile page of the user.
|
||||||
|
|
||||||
|
The PageExtension is used to load additinal stylesheets and scripts to
|
||||||
|
be loaded in a webpage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class PageExtension:
|
||||||
|
"""PageExtension is a plugin to inject custom styles and scripts
|
||||||
|
into a web page.
|
||||||
|
|
||||||
|
The subclasses should overwrite the `render_header()` and
|
||||||
|
`render_footer()` methods to inject whatever styles/scripts into
|
||||||
|
the webpage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def render_header(self):
|
||||||
|
"""Returns the HTML snippet to be included in the head section
|
||||||
|
of the web page.
|
||||||
|
|
||||||
|
Typically used to include the stylesheets and javascripts to be
|
||||||
|
included in the <head> of the webpage.
|
||||||
|
"""
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def render_footer(self):
|
||||||
|
"""Returns the HTML snippet to be included in the body tag at
|
||||||
|
the end of web page.
|
||||||
|
|
||||||
|
Typically used to include javascripts that need to be executed
|
||||||
|
after the page is loaded.
|
||||||
|
"""
|
||||||
|
return ""
|
||||||
|
|
||||||
|
class ProfileTab:
|
||||||
|
"""Base class for profile tabs.
|
||||||
|
|
||||||
|
Every subclass of ProfileTab must implement two methods:
|
||||||
|
- get_title()
|
||||||
|
- render()
|
||||||
|
"""
|
||||||
|
def __init__(self, user):
|
||||||
|
self.user = user
|
||||||
|
|
||||||
|
def get_title(self):
|
||||||
|
"""Returns the title of the tab.
|
||||||
|
|
||||||
|
Every subclass must implement this.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def render(self):
|
||||||
|
"""Renders the contents of the tab as HTML.
|
||||||
|
|
||||||
|
Every subclass must implement this.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
@@ -211,3 +211,63 @@ section {
|
|||||||
background: #eee;
|
background: #eee;
|
||||||
border: 2px solid #ddd;
|
border: 2px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.page-card {
|
||||||
|
max-width: 360px;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 70px auto;
|
||||||
|
border: 1px solid #d1d8dd;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.page-card .page-card-head {
|
||||||
|
padding: 10px 15px;
|
||||||
|
margin: -15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border-bottom: 1px solid #d1d8dd;
|
||||||
|
}
|
||||||
|
.page-card .page-card-head .indicator {
|
||||||
|
color: #36414C;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.page-card .page-card-head .indicator::before {
|
||||||
|
margin: 0 6px 0.5px 0px;
|
||||||
|
}
|
||||||
|
.page-card .btn {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partiallycomplete {
|
||||||
|
background: #FEF4E2;
|
||||||
|
color: #976417;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partiallycomplete img {
|
||||||
|
background: #976417;
|
||||||
|
}
|
||||||
|
|
||||||
|
.complete {
|
||||||
|
background: #EAF5EE;
|
||||||
|
color: #38A160;
|
||||||
|
}
|
||||||
|
|
||||||
|
.complete img {
|
||||||
|
background: #38A160;
|
||||||
|
}
|
||||||
|
|
||||||
|
.incomplete {
|
||||||
|
background: #FEECEC;
|
||||||
|
color: #E24C4C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.incomplete img {
|
||||||
|
background: #E24C4C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-image {
|
||||||
|
margin-right: 3px;
|
||||||
|
border-radius: 50px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ section.lightgray {
|
|||||||
background-color: rgba(255, 255, 255, 0);
|
background-color: rgba(255, 255, 255, 0);
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@@ -284,7 +285,7 @@ section.lightgray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lesson-teaser {
|
.lesson-teaser {
|
||||||
line-height: 35px;
|
line-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#hero h1 {
|
#hero h1 {
|
||||||
|
|||||||
BIN
community/public/images/Vector.png
Normal file
BIN
community/public/images/Vector.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
@@ -1,46 +1,60 @@
|
|||||||
{% extends "templates/base.html" %}
|
{% extends "templates/base.html" %}
|
||||||
{% block title %}Batch{% endblock %}
|
{% block title %} Batch {% endblock %}
|
||||||
|
|
||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="Courses" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
|
||||||
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/" + batch.name + "/join" %}
|
||||||
<div class="container mt-5">
|
<div class="container mt-5">
|
||||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||||
<h1 class="mt-5">{{ batch.title }}</h1>
|
<div>
|
||||||
|
<h1 class="mt-5">{{ batch.title }}</h1>
|
||||||
|
</div>
|
||||||
<div class="course-details">
|
<div class="course-details">
|
||||||
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True) }}
|
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True, show_progress=True) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-md-12">
|
<div class="w-25">
|
||||||
<h2>Batch Schedule</h2>
|
<h2>Batch Schedule</h2>
|
||||||
{{ BatchDetails(batch) }}
|
{{ widgets.RenderBatch(course=course, batch=batch) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if batch.description %}
|
||||||
<h2>Batch Details</h2>
|
<h2>Batch Details</h2>
|
||||||
{{ frappe.utils.md_to_html(batch.description) }}
|
{{ frappe.utils.md_to_html(batch.description) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if course.is_mentor(frappe.session.user) %}
|
||||||
</div>
|
<div class="">
|
||||||
{% endblock %}
|
<h2> Invite Members </h2>
|
||||||
|
<a href="" class="anchor_style mr-5" id="invite-link" data-link="{{ invite_link }}">Get Batch Invitation
|
||||||
{% macro BatchDetails(batch) %}
|
Link</a>
|
||||||
<div class="batch">
|
<small id="copy-message" class="text-muted pull-right" style="display: none;">Copied to Clipboard.</small>
|
||||||
<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>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
|
||||||
|
<script>
|
||||||
|
frappe.ready(() => {
|
||||||
|
$("#invite-link").click((e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
var link_element = $("#invite-link");
|
||||||
|
var input_element = document.createElement("input");
|
||||||
|
input_element.value = link_element.attr("data-link")
|
||||||
|
document.body.appendChild(input_element);
|
||||||
|
input_element.select();
|
||||||
|
document.execCommand("copy");
|
||||||
|
input_element.remove();
|
||||||
|
$("#copy-message").slideDown(function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
$("#copy-message").slideUp();
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
74
community/www/batch/join.html
Normal file
74
community/www/batch/join.html
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
% extends "templates/base.html" %}
|
||||||
|
{% block title %}Join a Course{% endblock %}
|
||||||
|
|
||||||
|
{% block head_include %}
|
||||||
|
<meta name="description" content="Join a Course"/>
|
||||||
|
<meta name="keywords" content="" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if frappe.session.user == "Guest" %}
|
||||||
|
|
||||||
|
<div class="page-card">
|
||||||
|
<div class='page-card-head'>
|
||||||
|
<span class='indicator blue password-box'>Login Required</span>
|
||||||
|
</div>
|
||||||
|
<div class=''>Please log in to confirm to join the course {{ batch.course_title }}.</div>
|
||||||
|
<a type="submit" id="login" class="btn btn-primary w-100"
|
||||||
|
href="/login?redirect-to=/courses/{{ batch.course }}/{{ batch.name }}/join">{{_("Login")}}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif already_a_member %}
|
||||||
|
|
||||||
|
<div class="page-card">
|
||||||
|
<div class='page-card-head'>
|
||||||
|
<span class='indicator blue password-box'>Already a member</span>
|
||||||
|
</div>
|
||||||
|
<div class=''>You are already a member of the batch {{ batch.title }} for the course {{ batch.course_title }}.
|
||||||
|
</div>
|
||||||
|
<a type="submit" id="batch-home" class="btn btn-primary w-100" href="/courses/{{batch.course}}/{{batch.name}}/home">{{_("Go to Batch Home")}}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<div class="page-card">
|
||||||
|
<div class='page-card-head'>
|
||||||
|
<span class='indicator blue password-box'>Confirm your membership</span>
|
||||||
|
</div>
|
||||||
|
<div>Please provide your confirmation to be a part of the batch {{ batch.title }} for the course
|
||||||
|
{{ batch.course_title }}.
|
||||||
|
</div>
|
||||||
|
<a type="submit" id="confirm" class="btn btn-primary w-100" data-batch="{{ batch.name | urlencode }}"
|
||||||
|
data-course="{{ batch.course | urlencode }}">{{_("Confirm")}}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
frappe.ready(() => {
|
||||||
|
var confirm_element = $("#confirm");
|
||||||
|
var batch = decodeURIComponent(confirm_element.attr("data-batch"));
|
||||||
|
var course = decodeURIComponent(confirm_element.attr("data-course"));
|
||||||
|
|
||||||
|
confirm_element.click((e) => {
|
||||||
|
frappe.call({
|
||||||
|
"method": "community.lms.doctype.lms_batch_membership.lms_batch_membership.create_membership",
|
||||||
|
"args": {
|
||||||
|
"batch": batch
|
||||||
|
},
|
||||||
|
"callback": (data) => {
|
||||||
|
if (data.message == "OK") {
|
||||||
|
frappe.msgprint({
|
||||||
|
message: __("You are now a member of this batch!"),
|
||||||
|
clear: true
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location.href = "/courses/" + course + "/" + batch + "/home";
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
8
community/www/batch/join.py
Normal file
8
community/www/batch/join.py
Normal file
@@ -0,0 +1,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")
|
||||||
@@ -9,16 +9,13 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
<link rel="stylesheet" href="{{ livecode_url }}/static/codemirror/lib/codemirror.css">
|
|
||||||
<link rel="stylesheet" href="/assets/css/lms.css">
|
<link rel="stylesheet" href="/assets/css/lms.css">
|
||||||
<link rel="stylesheet" href="/assets/frappe/css/hljs-night-owl.css">
|
<link rel="stylesheet" href="/assets/frappe/css/hljs-night-owl.css">
|
||||||
|
|
||||||
<script src="{{ livecode_url }}/static/codemirror/lib/codemirror.js"></script>
|
{% for ext in page_extensions %}
|
||||||
<script src="{{ livecode_url }}/static/codemirror/mode/python/python.js"></script>
|
{{ ext.render_header() }}
|
||||||
<script src="{{ livecode_url }}/static/codemirror/keymap/sublime.js"></script>
|
{% endfor %}
|
||||||
|
|
||||||
<script src="{{ livecode_url }}/static/codemirror/addon/edit/matchbrackets.js"></script>
|
|
||||||
<script src="{{ livecode_url }}/static/codemirror/addon/comment/comment.js"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,13 +25,9 @@
|
|||||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||||
<div class="lesson-page">
|
<div class="lesson-page">
|
||||||
|
|
||||||
<h2>{{ lesson.title }}</h2>
|
<h2 class="title {% if course.is_mentor(frappe.session.user) %} is_mentor {% endif %}" data-name="{{ lesson.name }}" data-batch="{{ batch.name }}">{{ lesson.title }}</h2>
|
||||||
|
|
||||||
{% for s in lesson.get_sections() %}
|
{{ lesson.render_html() }}
|
||||||
<div class="section section-{{ s.type }}">
|
|
||||||
{{ render_section(s) }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{{ pagination(prev_chap, prev_url, next_chap, next_url) }}
|
{{ pagination(prev_chap, prev_url, next_chap, next_url) }}
|
||||||
</div>
|
</div>
|
||||||
@@ -42,30 +35,6 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% macro render_section(s) %}
|
|
||||||
{% if s.type == "text" %}
|
|
||||||
{{ render_section_text(s) }}
|
|
||||||
{% elif s.type == "example" or s.type == "code" %}
|
|
||||||
{{ LiveCodeEditor(s.name,
|
|
||||||
code=s.get_latest_code_for_user(),
|
|
||||||
reset_code=s.contents,
|
|
||||||
is_exercise=False)
|
|
||||||
}}
|
|
||||||
{% elif s.type == "exercise" %}
|
|
||||||
{{ widgets.Exercise(exercise=s.get_exercise())}}
|
|
||||||
{% else %}
|
|
||||||
<div>Unknown section type: {{s.type}}</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
{% macro render_section_text(s) %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-9">
|
|
||||||
{{ frappe.utils.md_to_html(s.contents) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
{% macro pagination(prev_chap, prev_url, next_chap, next_url) %}
|
{% macro pagination(prev_chap, prev_url, next_chap, next_url) %}
|
||||||
<div class="lesson-pagination">
|
<div class="lesson-pagination">
|
||||||
{% if prev_url %}
|
{% if prev_url %}
|
||||||
@@ -84,8 +53,6 @@
|
|||||||
|
|
||||||
{%- block script %}
|
{%- block script %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{{ LiveCodeEditorJS() }}
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
var batch_name = "{{ batch.name }}";
|
var batch_name = "{{ batch.name }}";
|
||||||
@@ -98,4 +65,8 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% for ext in page_extensions %}
|
||||||
|
{{ ext.render_footer() }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
|||||||
11
community/www/batch/learn.js
Normal file
11
community/www/batch/learn.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
frappe.ready(() => {
|
||||||
|
if (!$(".title").hasClass("is_mentor")) {
|
||||||
|
frappe.call({
|
||||||
|
method: "community.lms.doctype.lesson.lesson.save_progress",
|
||||||
|
args: {
|
||||||
|
lesson: $(".title").attr("data-name"),
|
||||||
|
batch: $(".title").attr("data-batch")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -28,7 +28,7 @@ def get_context(context):
|
|||||||
context.next_url = context.batch.get_learn_url(next_)
|
context.next_url = context.batch.get_learn_url(next_)
|
||||||
context.prev_url = context.batch.get_learn_url(prev_)
|
context.prev_url = context.batch.get_learn_url(prev_)
|
||||||
|
|
||||||
|
context.page_extensions = get_page_extensions()
|
||||||
|
|
||||||
def get_chapter_title(course_name, lesson_number):
|
def get_chapter_title(course_name, lesson_number):
|
||||||
if not lesson_number:
|
if not lesson_number:
|
||||||
@@ -42,4 +42,8 @@ def get_lesson_index(course, batch, user):
|
|||||||
lesson = batch.get_current_lesson(user)
|
lesson = batch.get_current_lesson(user)
|
||||||
return lesson and course.get_lesson_index(lesson)
|
return lesson and course.get_lesson_index(lesson)
|
||||||
|
|
||||||
|
def get_page_extensions():
|
||||||
|
default_value = ["community.community.plugins.PageExtension"]
|
||||||
|
classnames = frappe.get_hooks("community_lesson_page_extensions") or default_value
|
||||||
|
extensions = [frappe.get_attr(name)() for name in classnames]
|
||||||
|
return extensions
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<h1>Batch Progress</h1>
|
<h1>Batch Progress</h1>
|
||||||
{% for exercise in report.exercises %}
|
{% for exercise in report.exercises %}
|
||||||
<div class="exercise-submissions">
|
<div class="exercise-submissions">
|
||||||
<h2>{{exercise.title}}</h2>
|
<h2>Exercise {{exercise.index_label}}: {{exercise.title}}</h2>
|
||||||
{% for s in report.get_submissions_of_exercise(exercise.name) %}
|
{% for s in report.get_submissions_of_exercise(exercise.name) %}
|
||||||
<div class="submission">
|
<div class="submission">
|
||||||
<h4><a href="/{{s.owner.username}}">{{s.owner.full_name}}</a></h4>
|
<h4><a href="/{{s.owner.username}}">{{s.owner.full_name}}</a></h4>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class BatchReport:
|
|||||||
self.submissions_by_exercise[s.exercise].append(s)
|
self.submissions_by_exercise[s.exercise].append(s)
|
||||||
|
|
||||||
def get_exercises(self, course_name):
|
def get_exercises(self, course_name):
|
||||||
return frappe.get_all("Exercise", {"course": course_name}, ["name", "title"])
|
return frappe.get_all("Exercise", {"course": course_name, "lesson": ["!=", ""]}, ["name", "title", "index_label"], order_by="index_label")
|
||||||
|
|
||||||
def get_submissions_of_exercise(self, exercise_name):
|
def get_submissions_of_exercise(self, exercise_name):
|
||||||
return self.submissions_by_exercise[exercise_name]
|
return self.submissions_by_exercise[exercise_name]
|
||||||
|
|||||||
@@ -64,36 +64,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro RenderBatch(batch, can_manage=False) %}
|
|
||||||
<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 class="cta">
|
|
||||||
<div class="">
|
|
||||||
{% if can_manage %}
|
|
||||||
<a href="/courses/{{course.name}}/{{batch.name}}/home" 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>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
{% macro BatchSectionForMentors(course, mentor_batches) %}
|
{% macro BatchSectionForMentors(course, mentor_batches) %}
|
||||||
<h2>Your Batches</h2>
|
<h2>Your Batches</h2>
|
||||||
|
|
||||||
@@ -105,7 +75,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
{% for batch in mentor_batches %}
|
{% for batch in mentor_batches %}
|
||||||
<div class="col-lg-4 col-md-6">
|
<div class="col-lg-4 col-md-6">
|
||||||
{{ RenderBatch(batch, can_manage=True) }}
|
{{ widgets.RenderBatch(course=course, batch=batch, can_manage=True) }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@@ -127,7 +97,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
{% for batch in upcoming_batches %}
|
{% for batch in upcoming_batches %}
|
||||||
<div class="col-lg-4 col-md-6">
|
<div class="col-lg-4 col-md-6">
|
||||||
{{ RenderBatch(batch, can_manage=False) }}
|
{{ widgets.RenderBatch(course=course, batch=batch, can_join=True) }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
frappe.ready(() => {
|
|
||||||
|
|
||||||
})
|
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
<section id="hero">
|
<section id="hero">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<h1 class="display-4">Guided online courses, with a <br />mentor at your back.</h1>
|
<h1 class="display-4">Guided online programming courses, with a <br />mentor at your back.</h1>
|
||||||
<p class="lead">Hands-on online courses designed by experts, delivered by passionate mentors.</p>
|
<p class="lead">Hands-on programming courses designed by experts, delivered by passionate mentors.</p>
|
||||||
{{ widgets.RequestInvite() }}
|
{{ widgets.RequestInvite() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -72,29 +72,26 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
|
<ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
|
||||||
<li class="nav-item">
|
{% for tab in profile_tabs %}
|
||||||
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home"
|
<li class="nav-item">
|
||||||
aria-selected="true">Sketches</a>
|
{% set slug = title.lower().replace(" ", "-") %}
|
||||||
</li>
|
{% set selected = loop.index == 1 %}
|
||||||
|
{% set active = 'active' if loop.index == 1 else '' %}
|
||||||
|
<a class="nav-link {{ active }}" id="{{ slug }}-tab" data-toggle="tab" href="#{{ slug }}" role="tab" aria-controls="{{ slug }}"
|
||||||
|
aria-selected="{{ selected }}">Sketches</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tab-content">
|
{% for tab in profile_tabs %}
|
||||||
<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
|
{% set slug = title.lower().replace(" ", "-") %}
|
||||||
<div class="row">
|
<div class="tab-content">
|
||||||
{% if sketches %}
|
<div class="tab-pane fade py-4 show active" role="tabpanel" id="slug">
|
||||||
{% for sketch in sketches %}
|
{{ tab.render() }}
|
||||||
<div class="col-md-4 col-sm-6">
|
|
||||||
{{ widgets.SketchTeaser(sketch=sketch) }}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% if not sketches %}
|
|
||||||
<p class="text-center">{{member.full_name}} has not created any skecth yet.</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,9 +3,20 @@ from community.lms.models import Sketch
|
|||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
context.member = frappe.get_doc("User", {"username": frappe.form_dict["username"]})
|
context.member = frappe.get_doc("User", {"username": frappe.form_dict["username"]})
|
||||||
except:
|
except:
|
||||||
context.template = "www/404.html"
|
context.template = "www/404.html"
|
||||||
else:
|
return
|
||||||
context.sketches = Sketch.get_recent_sketches(owner=context.member.email)
|
|
||||||
|
context.profile_tabs = get_profile_tabs(context.member)
|
||||||
|
|
||||||
|
def get_profile_tabs(user):
|
||||||
|
"""Returns the enabled ProfileTab objects.
|
||||||
|
|
||||||
|
Each ProfileTab is rendered as a tab on the profile page and the
|
||||||
|
they are specified as profile_tabs hook.
|
||||||
|
"""
|
||||||
|
tabs = frappe.get_hooks("profile_tabs") or []
|
||||||
|
return [frappe.get_attr(tab)(user) for tab in tabs]
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
frappe
|
frappe
|
||||||
websocket_client
|
websocket_client
|
||||||
|
markdown
|
||||||
|
beautifulsoup4
|
||||||
|
lxml
|
||||||
|
|||||||
Reference in New Issue
Block a user