diff --git a/community/hooks.py b/community/hooks.py index e7c0a858..ebc19144 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -141,12 +141,13 @@ primary_rules = [ {"from_route": "/hackathons//", "to_route": "hackathons/project"}, {"from_route": "/dashboard", "to_route": ""}, {"from_route": "/add-a-new-batch", "to_route": "add-a-new-batch"}, - {"from_route": "/courses///learn", "to_route": "courses/learn"}, - {"from_route": "/courses///learn/.", "to_route": "courses/learn"}, - {"from_route": "/courses///schedule", "to_route": "courses/schedule"}, - {"from_route": "/courses///members", "to_route": "courses/members"}, - {"from_route": "/courses///discuss", "to_route": "courses/discuss"}, - {"from_route": "/courses///about", "to_route": "courses/about"} + {"from_route": "/courses///learn", "to_route": "batch/learn"}, + {"from_route": "/courses///learn/.", "to_route": "batch/learn"}, + {"from_route": "/courses///schedule", "to_route": "batch/schedule"}, + {"from_route": "/courses///members", "to_route": "batch/members"}, + {"from_route": "/courses///discuss", "to_route": "batch/discuss"}, + {"from_route": "/courses///about", "to_route": "batch/about"}, + {"from_route": "/courses///progress", "to_route": "batch/progress"} ] # Any frappe default URL is blocked by profile-rules, add it here to unblock it diff --git a/community/lms/doctype/exercise/exercise.py b/community/lms/doctype/exercise/exercise.py index 313165cf..151b993a 100644 --- a/community/lms/doctype/exercise/exercise.py +++ b/community/lms/doctype/exercise/exercise.py @@ -24,6 +24,8 @@ class Exercise(Document): }, order_by="creation desc", page_length=1) + + print("get_user_submission", result) if result: return result[0] @@ -41,6 +43,8 @@ class Exercise(Document): course = frappe.get_doc("LMS Course", self.course) batch = course.get_student_batch(user) + image = livecode_to_svg(None, code) + doc = frappe.get_doc( doctype="Exercise Submission", exercise=self.name, @@ -48,7 +52,8 @@ class Exercise(Document): course=self.course, lesson=self.lesson, batch=batch and batch.name, + image=image, solution=code) - doc.insert() + doc.insert(ignore_permissions=True) return doc diff --git a/community/lms/doctype/exercise_submission/exercise_submission.json b/community/lms/doctype/exercise_submission/exercise_submission.json index de7541ea..bd662b11 100644 --- a/community/lms/doctype/exercise_submission/exercise_submission.json +++ b/community/lms/doctype/exercise_submission/exercise_submission.json @@ -10,7 +10,8 @@ "exercise_title", "course", "batch", - "lesson" + "lesson", + "image" ], "fields": [ { @@ -54,11 +55,17 @@ "fieldtype": "Link", "label": "Lesson", "options": "Lesson" + }, + { + "fieldname": "image", + "fieldtype": "Code", + "label": "Image", + "read_only": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-05-20 13:30:16.349278", + "modified": "2021-05-21 11:28:45.833018", "modified_by": "Administrator", "module": "LMS", "name": "Exercise Submission", diff --git a/community/lms/doctype/lesson/lesson.py b/community/lms/doctype/lesson/lesson.py index c544f774..979515ea 100644 --- a/community/lms/doctype/lesson/lesson.py +++ b/community/lms/doctype/lesson/lesson.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document -from ..lms_topic.section_parser import SectionParser +from ...section_parser import SectionParser class Lesson(Document): def before_save(self): diff --git a/community/lms/doctype/lms_batch/lms_batch.py b/community/lms/doctype/lms_batch/lms_batch.py index 6c343651..ce23f782 100644 --- a/community/lms/doctype/lms_batch/lms_batch.py +++ b/community/lms/doctype/lms_batch/lms_batch.py @@ -37,13 +37,37 @@ class LMSBatch(Document): member_names = [m['member'] for m in memberships] return find_all("User", name=["IN", member_names]) - def is_member(self, email): + def is_member(self, email, member_type=None): """Checks if a person is part of a batch. + + If member_type is specified, checks if the person is a Student/Mentor. """ member = find("Community Member", email=email) - return member and frappe.db.exists( + if not member: + return + + filters = { + "batch": self.name, + "member": member.name + } + if member_type: + filters['member_type'] = member_type + return frappe.db.exists("LMS Batch Membership", filters) + + def get_students(self): + """Returns (email, full_name, username) of all the students of this batch as a list of dict. + """ + memberships = frappe.get_all( "LMS Batch Membership", - {"batch": self.name, "member": member.name}) + {"batch": self.name, "member_type": "Student"}, + ["member"]) + member_names = [m['member'] for m in memberships] + members = frappe.get_all( + "Community Member", + {"name": ["IN", member_names]}, + ["email", "full_name", "username"]) + return members + @frappe.whitelist() def get_messages(batch): diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index f81a1598..9e1f87cd 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -35,17 +35,6 @@ class LMSCourse(Document): def __repr__(self): return f"" - def get_topic(self, slug): - """Returns the topic with given slug in this course as a Document. - """ - result = frappe.get_all( - "LMS Topic", - filters={"course": self.name, "slug": slug}) - - if result: - row = result[0] - return frappe.get_doc('LMS Topic', row['name']) - def has_mentor(self, email): """Checks if this course has a mentor with given email. """ diff --git a/community/lms/doctype/lms_topic/lms_topic.js b/community/lms/doctype/lms_topic/lms_topic.js deleted file mode 100644 index 36c3fee7..00000000 --- a/community/lms/doctype/lms_topic/lms_topic.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2021, FOSS United and contributors -// For license information, please see license.txt - -frappe.ui.form.on('LMS Topic', { - // refresh: function(frm) { - - // } -}); diff --git a/community/lms/doctype/lms_topic/lms_topic.json b/community/lms/doctype/lms_topic/lms_topic.json deleted file mode 100644 index 81cc6477..00000000 --- a/community/lms/doctype/lms_topic/lms_topic.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "actions": [], - "allow_guest_to_view": 1, - "creation": "2021-03-02 07:20:41.686573", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "course", - "title", - "slug", - "preview", - "description", - "order", - "sections" - ], - "fields": [ - { - "fieldname": "title", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Title", - "reqd": 1 - }, - { - "fieldname": "description", - "fieldtype": "Markdown Editor", - "label": "Description" - }, - { - "fieldname": "course", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Course", - "options": "LMS Course", - "reqd": 1 - }, - { - "fieldname": "order", - "fieldtype": "Int", - "label": "Order" - }, - { - "fieldname": "preview", - "fieldtype": "Markdown Editor", - "label": "Preview" - }, - { - "fieldname": "sections", - "fieldtype": "Table", - "label": "Sections", - "options": "LMS Section" - }, - { - "description": "The slug of the topic. Autogenerated from the title if not specified.", - "fieldname": "slug", - "fieldtype": "Data", - "label": "Slug" - } - ], - "index_web_pages_for_search": 1, - "links": [], - "modified": "2021-04-06 14:12:48.514062", - "modified_by": "Administrator", - "module": "LMS", - "name": "LMS Topic", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - } - ], - "search_fields": "title", - "sort_field": "creation", - "sort_order": "ASC", - "title_field": "title", - "track_changes": 1, - "track_seen": 1, - "track_views": 1 -} \ No newline at end of file diff --git a/community/lms/doctype/lms_topic/lms_topic.py b/community/lms/doctype/lms_topic/lms_topic.py deleted file mode 100644 index fec5e261..00000000 --- a/community/lms/doctype/lms_topic/lms_topic.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe.model.document import Document -from .section_parser import SectionParser -from ...utils import slugify - -class LMSTopic(Document): - def before_save(self): - course = self.get_course() - if not self.slug: - self.slug = self.generate_slug(title=self.title) - - sections = SectionParser().parse(self.description or "") - self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)] - - def get_course(self): - return frappe.get_doc("LMS Course", self.course) - - def generate_slug(self, title): - result = frappe.get_all( - 'LMS Topic', - filters={'course': self.course}, - fields=['slug']) - slugs = set([row['slug'] for row in result]) - return slugify(title, used_slugs=slugs) - - def get_sections(self): - return sorted(self.sections, key=lambda s: s.index) - - def make_lms_section(self, index, section): - s = frappe.new_doc('LMS Section', parent_doc=self, parentfield='sections') - s.type = section.type - s.label = section.label - s.contents = section.contents - s.index = index - return s - - - diff --git a/community/lms/doctype/lms_topic/test_lms_topic.py b/community/lms/doctype/lms_topic/test_lms_topic.py deleted file mode 100644 index b930c8cd..00000000 --- a/community/lms/doctype/lms_topic/test_lms_topic.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and Contributors -# See license.txt -from __future__ import unicode_literals - -# import frappe -import unittest - -class TestLMSTopic(unittest.TestCase): - pass diff --git a/community/lms/doctype/lms_topic/section_parser.py b/community/lms/section_parser.py similarity index 100% rename from community/lms/doctype/lms_topic/section_parser.py rename to community/lms/section_parser.py diff --git a/community/lms/widgets/Exercise.html b/community/lms/widgets/Exercise.html index b43410b4..1dbaecfa 100644 --- a/community/lms/widgets/Exercise.html +++ b/community/lms/widgets/Exercise.html @@ -11,7 +11,7 @@ {% set submission = exercise.get_user_submission() %} {{ LiveCodeEditor(exercise.name, - code=exercise.code, + code=submission.solution if submission else exercise.code, reset_code=exercise.code, is_exercise=True, last_submitted=submission and submission.creation) }} diff --git a/community/public/css/style.css b/community/public/css/style.css index 8c3fb588..e68467d2 100644 --- a/community/public/css/style.css +++ b/community/public/css/style.css @@ -23,8 +23,6 @@ --cta-color: var(--c4); --send-message: var(--c7); --received-message: var(--c8); - - --primary-color: #08B74F !important; } body { diff --git a/community/public/css/style.less b/community/public/css/style.less index e92d02ef..8e17ee6c 100644 --- a/community/public/css/style.less +++ b/community/public/css/style.less @@ -1,5 +1,3 @@ -@primary-color: #08B74F; - h2 { margin: 20px 0px; color: black; @@ -312,3 +310,28 @@ section.lightgray { border: 1px solid #ddd; margin-bottom: 20px; } + +.svg-200 svg { + width: 200px; + height: 200px; +} + +.livecode-editor-small .livecode-editor { + .CodeMirror-scroll { + max-height: 160px; + min-height: 160px; + } + + canvas { + width: 150px; + height: 150px; + } +} + +.mentor-dashboard { + margin-top: 20px; + + .submission { + margin: 40px 0px 0px 20px; + } +} diff --git a/community/public/css/vars.css b/community/public/css/vars.css index b04975fd..b499df29 100644 --- a/community/public/css/vars.css +++ b/community/public/css/vars.css @@ -1,6 +1,5 @@ /* Define all your css variables here. */ :root { - --primary-color: #08B74F; --tag-color: #737373; --sidebar-bg: #F6F6F6; --sidebar-border: #C4C4C4; diff --git a/community/lms/doctype/lms_topic/__init__.py b/community/www/batch/__init__.py similarity index 100% rename from community/lms/doctype/lms_topic/__init__.py rename to community/www/batch/__init__.py diff --git a/community/www/courses/about/index.html b/community/www/batch/about.html similarity index 97% rename from community/www/courses/about/index.html rename to community/www/batch/about.html index 46bf0e13..4edabaef 100644 --- a/community/www/courses/about/index.html +++ b/community/www/batch/about.html @@ -11,7 +11,8 @@ {% endblock %} {% block content %} -{{ Sidebar(course.name, batch.name) }} +{{ Sidebar(course, batch) }} +
{{ CourseBasicDetail(course)}} {{ InstructorsSection(course.get_instructor()) }} diff --git a/community/www/batch/about.py b/community/www/batch/about.py new file mode 100644 index 00000000..b847d8c8 --- /dev/null +++ b/community/www/batch/about.py @@ -0,0 +1,7 @@ +import frappe +from . import utils + +def get_context(context): + utils.get_common_context(context) + + print("context", context) diff --git a/community/www/courses/discuss/index.html b/community/www/batch/discuss.html similarity index 93% rename from community/www/courses/discuss/index.html rename to community/www/batch/discuss.html index 73270d8e..31cf1813 100644 --- a/community/www/courses/discuss/index.html +++ b/community/www/batch/discuss.html @@ -11,10 +11,11 @@ {% endblock %} {% block content %} -{{ Sidebar(course_slug, batch_code) }} +{{ Sidebar(course, batch) }} +
- {{ BatchHearder(course.name, member_count) }} + {{ BatchHearder(course.title, member_count) }}
diff --git a/community/www/courses/discuss/index.js b/community/www/batch/discuss.js similarity index 100% rename from community/www/courses/discuss/index.js rename to community/www/batch/discuss.js diff --git a/community/www/batch/discuss.py b/community/www/batch/discuss.py new file mode 100644 index 00000000..fcd5ebda --- /dev/null +++ b/community/www/batch/discuss.py @@ -0,0 +1,9 @@ +import frappe +from . import utils +from community.lms.doctype.lms_batch.lms_batch import get_messages + +def get_context(context): + utils.get_common_context(context) + + context.members = utils.get_batch_members(context.batch.name) + context.member_count = len(context.members) diff --git a/community/www/courses/learn/index.html b/community/www/batch/learn.html similarity index 99% rename from community/www/courses/learn/index.html rename to community/www/batch/learn.html index db3a4549..31750946 100644 --- a/community/www/courses/learn/index.html +++ b/community/www/batch/learn.html @@ -23,7 +23,7 @@ {% block content %} -{{ Sidebar(course.name, batch.name) }} +{{ Sidebar(course, batch) }}
diff --git a/community/www/courses/learn/index.py b/community/www/batch/learn.py similarity index 54% rename from community/www/courses/learn/index.py rename to community/www/batch/learn.py index 4aea3388..983ea8be 100644 --- a/community/www/courses/learn/index.py +++ b/community/www/batch/learn.py @@ -1,37 +1,25 @@ import frappe -from community.lms.models import Course +from . import utils def get_context(context): - context.no_cache = 1 + utils.get_common_context(context) - course_name = frappe.form_dict["course"] - batch_name = frappe.form_dict["batch"] chapter_index = frappe.form_dict.get("chapter") lesson_index = frappe.form_dict.get("lesson") lesson_number = f"{chapter_index}.{lesson_index}" - course = Course.find(course_name) - if not course: - context.template = "www/404.html" - return - - batch = course.get_batch(batch_name) - if not batch: - frappe.local.flags.redirect_location = "/courses/" + course_name - raise frappe.Redirect + 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" raise frappe.Redirect - context.course = course - context.batch = batch - context.lesson = course.get_lesson(chapter_index, lesson_index) + context.lesson = context.course.get_lesson(chapter_index, lesson_index) context.lesson_index = lesson_index context.chapter_index = chapter_index - context.livecode_url = get_livecode_url() - outline = course.get_outline() + outline = context.course.get_outline() next_ = outline.get_next(lesson_number) prev_ = outline.get_prev(lesson_number) context.next_url = get_learn_url(course_name, batch_name, next_) @@ -41,6 +29,3 @@ 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_livecode_url(): - return frappe.db.get_single_value("LMS Settings", "livecode_url") diff --git a/community/www/courses/members/index.html b/community/www/batch/members.html similarity index 90% rename from community/www/courses/members/index.html rename to community/www/batch/members.html index bc7ce6f1..ac092403 100644 --- a/community/www/courses/members/index.html +++ b/community/www/batch/members.html @@ -11,9 +11,10 @@ {% endblock %} {% block content %} -{{ Sidebar(course_slug, batch_code) }} +{{ Sidebar(course, batch) }} +
- {{ BatchHearder(course.name, member_count)}} + {{ BatchHearder(course.title, member_count)}} {{ MembersList(members)}}
{% endblock %} @@ -36,4 +37,4 @@
{% endfor %}
-{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/community/www/batch/members.py b/community/www/batch/members.py new file mode 100644 index 00000000..1d04ac15 --- /dev/null +++ b/community/www/batch/members.py @@ -0,0 +1,8 @@ +import frappe +from . import utils + +def get_context(context): + utils.get_common_context(context) + + context.members = utils.get_batch_members(context.batch.name) + context.member_count = len(context.members) diff --git a/community/www/batch/progress.html b/community/www/batch/progress.html new file mode 100644 index 00000000..ebfde54f --- /dev/null +++ b/community/www/batch/progress.html @@ -0,0 +1,52 @@ +{% extends "templates/base.html" %} +{% from "www/macros/sidebar.html" import Sidebar %} +{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %} +{% block title %}{{ course.title }} - Batch Dashboard{% endblock %} + +{% block head_include %} + + + + + + + + + + + + + + +{% endblock %} + + +{% block content %} +{{ Sidebar(course, batch) }} + +
+
+

Batch Progress

+ {% for exercise in report.exercises %} +
+

{{exercise.title}}

+ {% for s in report.get_submissions_of_exercise(exercise.name) %} +
+

{{s.owner.full_name}}

+
+ {{ LiveCodeEditor(name=s.name, code=s.solution, reset_code=s.solution) }} +
+
+ {% endfor %} +
+ {% endfor %} +
+
+{% endblock %} + + +{%- block script %} + {{ super() }} + {{ LiveCodeEditorJS() }} +{% endblock %} diff --git a/community/www/batch/progress.py b/community/www/batch/progress.py new file mode 100644 index 00000000..628b6233 --- /dev/null +++ b/community/www/batch/progress.py @@ -0,0 +1,64 @@ +import frappe +from community.lms.models import Course +from collections import defaultdict +from . import utils + +def get_context(context): + utils.get_common_context(context) + + exercise_name = frappe.form_dict.get("exercise") + if exercise_name: + exercise = frappe.get_doc("Exercise", exercise_name) + else: + exercise = None + + context.exercise = exercise + context.report = BatchReport(context.course, context.batch) + +class BatchReport: + def __init__(self, course, batch): + self.submissions = get_submissions(batch) + self.exercises = self.get_exercises(course.name) + + self.submissions_by_exercise = defaultdict(list) + for s in self.submissions: + self.submissions_by_exercise[s.exercise].append(s) + + def get_exercises(self, course_name): + return frappe.get_all("Exercise", {"course": course_name}, ["name", "title"]) + + def get_submissions_of_exercise(self, exercise_name): + return self.submissions_by_exercise[exercise_name] + +def get_submissions(batch): + students = batch.get_students() + students_map = {s['email']: s for s in students} + + names, values = nparams("s", students_map.keys()) + + sql = """ + select owner, exercise, name, solution, creation, image + from ( + select owner, exercise, name, solution, creation, image, + row_number() over (partition by owner, exercise order by creation desc) as ix + from `tabExercise Submission`) as t + where t.ix=1 and owner IN {} + """.format(names) + + data = frappe.db.sql(sql, values=values, as_dict=True) + + for row in data: + row['owner'] = students_map[row['owner']] + return data + +def nparams(name, values): + """Creates n paramters from a list of values for a db query. + + >>> nparams("name", ["a", "b]) + ("(%(name_1)s, %(name_2)s)", {"name_1": "a", "name_2": "b"}) + """ + keys = [f"{name}_{i}" for i, _ in enumerate(values, start=1)] + param_names = [f"%({k})s" for k in keys] + param_values = dict(zip(keys, values)) + joined_names = "(" + ", ".join(param_names) + ")" + return joined_names, param_values diff --git a/community/www/courses/schedule/index.html b/community/www/batch/schedule.html similarity index 91% rename from community/www/courses/schedule/index.html rename to community/www/batch/schedule.html index f78a9397..07aa84d4 100644 --- a/community/www/courses/schedule/index.html +++ b/community/www/batch/schedule.html @@ -8,7 +8,7 @@ {% endblock %} {% block content %} -{{ Sidebar(course, batch_code) }} +{{ Sidebar(course, batch) }}
{% endblock %} diff --git a/community/www/courses/about/index.py b/community/www/batch/schedule.py similarity index 99% rename from community/www/courses/about/index.py rename to community/www/batch/schedule.py index 83b3df0e..65d68fc3 100644 --- a/community/www/courses/about/index.py +++ b/community/www/batch/schedule.py @@ -3,7 +3,6 @@ from community.lms.models import Course def get_context(context): context.no_cache = 1 - course_name = frappe.form_dict["course"] batch_name = frappe.form_dict["batch"] diff --git a/community/www/batch/utils.py b/community/www/batch/utils.py new file mode 100644 index 00000000..51e77eba --- /dev/null +++ b/community/www/batch/utils.py @@ -0,0 +1,43 @@ +import frappe +from community.lms.models import Course + +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 = course.get_batch(batch_name) + if not batch: + frappe.local.flags.redirect_location = "/courses/" + course_name + raise frappe.Redirect + + context.course = course + context.batch = batch + context.livecode_url = get_livecode_url() + +def get_livecode_url(): + return frappe.db.get_single_value("LMS Settings", "livecode_url") + +def get_batch_members(batch_name): + members = [] + memberships = frappe.get_all("LMS Batch Membership", {"batch": batch_name}, ["member", "member_type"]) + + for membership in memberships: + member = get_member_with_name(membership.member) + if membership.member_type == "Mentor": + member.is_mentor = True + members.append(member) + return members + +def get_member_with_name(name): + try: + return frappe.get_doc("Community Member", name) + except frappe.DoesNotExistError: + return + diff --git a/community/www/courses/discuss/index.py b/community/www/courses/discuss/index.py deleted file mode 100644 index 7c34761a..00000000 --- a/community/www/courses/discuss/index.py +++ /dev/null @@ -1,15 +0,0 @@ -import frappe -from community.www.courses.utils import redirect_if_not_a_member, get_course, get_batch_members, get_batch -from community.lms.doctype.lms_batch.lms_batch import get_messages - -def get_context(context): - context.no_cache = 1 - context.course_slug = frappe.form_dict["course"] - context.course = get_course(context.course_slug) - context.batch_code = frappe.form_dict["batch"] - redirect_if_not_a_member(context.course_slug, context.batch_code) - - context.batch = get_batch(context.batch_code) - context.members = get_batch_members(context.batch.name) - context.member_count = len(context.members) - context.messages = get_messages(context.batch.name) \ No newline at end of file diff --git a/community/www/courses/members/index.py b/community/www/courses/members/index.py deleted file mode 100644 index 7e9bf36a..00000000 --- a/community/www/courses/members/index.py +++ /dev/null @@ -1,12 +0,0 @@ -import frappe -from community.www.courses.utils import redirect_if_not_a_member, get_batch, get_member_with_name, get_course, get_batch_members - -def get_context(context): - context.no_cache = 1 - context.course_slug = frappe.form_dict["course"] - context.course = get_course(context.course_slug) - context.batch_code = frappe.form_dict["batch"] - redirect_if_not_a_member(context.course_slug, context.batch_code) - context.batch = get_batch(context.batch_code) - context.members = get_batch_members(context.batch.name) - context.member_count = len(context.members) \ No newline at end of file diff --git a/community/www/courses/schedule/index.py b/community/www/courses/schedule/index.py deleted file mode 100644 index 03180785..00000000 --- a/community/www/courses/schedule/index.py +++ /dev/null @@ -1,8 +0,0 @@ -import frappe -from community.www.courses.utils import redirect_if_not_a_member - -def get_context(context): - context.no_cache = 1 - context.course = frappe.form_dict["course"] - context.batch_code = frappe.form_dict["batch"] - redirect_if_not_a_member(context.course, context.batch_code) \ No newline at end of file diff --git a/community/www/courses/topic.html b/community/www/courses/topic.html deleted file mode 100644 index e9ec070c..00000000 --- a/community/www/courses/topic.html +++ /dev/null @@ -1,108 +0,0 @@ -{% extends "templates/base.html" %} -{% from "www/macros/livecode.html" import LiveCodeEditor with context %} -{% block title %}{{topic.title}} ({{course.title}}){% endblock %} -{% block head_include %} - - - - - - - - - - - - - -{% endblock %} - -{% block content %} -
-
- - -

{{ topic.title }}

- - {% for s in topic.get_sections() %} -
- {{ render_section(s) }} -
- {% endfor %} - -
-
-{% endblock %} - -{% macro render_section(s) %} - {% if s.type == "text" %} - {{ render_section_text(s) }} - {% elif s.type == "example" or s.type == "code" %} - {{ LiveCodeEditor(s.name, s.get_latest_code_for_user()) }} - {% else %} -
Unknown section type: {{s.type}}
- {% endif %} -{% endmacro %} - -{% macro render_section_text(s) %} -
-
- {{ frappe.utils.md_to_html(s.contents) }} -
-
-{% endmacro %} - -{%- block script %} - {{ super() }} - - -{%- endblock %} diff --git a/community/www/courses/topic.py b/community/www/courses/topic.py deleted file mode 100644 index 7abaabcb..00000000 --- a/community/www/courses/topic.py +++ /dev/null @@ -1,33 +0,0 @@ -import frappe - -def get_context(context): - context.no_cache = 1 - - try: - course_slug = frappe.form_dict['course'] - topic_slug = frappe.form_dict['topic'] - except KeyError: - context.template = 'www/404.html' - return - - course = get_course(course_slug) - topic = course and course.get_topic(topic_slug) - - if not topic: - context.template = 'www/404.html' - return - - context.course = course - context.topic = topic - context.livecode_url = get_livecode_url() - -def notfound(context): - context.template = 'www/404.html' - -def get_livecode_url(): - doc = frappe.get_doc("LMS Settings") - return doc.livecode_url - -def get_course(slug): - course = frappe.db.get_value('LMS Course', {"slug": slug}, ["name"], as_dict=1) - return course and frappe.get_doc('LMS Course', course['name']) diff --git a/community/www/macros/sidebar.html b/community/www/macros/sidebar.html index c36ab8ee..5237544a 100644 --- a/community/www/macros/sidebar.html +++ b/community/www/macros/sidebar.html @@ -1,12 +1,14 @@ -{% macro Sidebar(course, batch_code) %} +{% macro Sidebar(course, batch, is_mentor=False) %} {% endmacro %}