The current lesson is maintained in the LMS Batch Membership and that is updated everytime a lesson page is visited.
100 lines
2.7 KiB
HTML
100 lines
2.7 KiB
HTML
{% extends "templates/base.html" %}
|
|
{% from "www/macros/sidebar.html" import Sidebar %}
|
|
{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %}
|
|
{% block title %}{{ lesson.title }}{% endblock %}
|
|
|
|
{% block head_include %}
|
|
<meta name="description" content="{{lesson.title}} - {{course.title}}" />
|
|
<meta name="keywords" content="{{lesson.title}} - {{course.title}}" />
|
|
<style>
|
|
</style>
|
|
|
|
<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">
|
|
|
|
<script src="{{ livecode_url }}/static/codemirror/lib/codemirror.js"></script>
|
|
<script src="{{ livecode_url }}/static/codemirror/mode/python/python.js"></script>
|
|
<script src="{{ livecode_url }}/static/codemirror/keymap/sublime.js"></script>
|
|
|
|
<script src="{{ livecode_url }}/static/codemirror/addon/edit/matchbrackets.js"></script>
|
|
<script src="{{ livecode_url }}/static/codemirror/addon/comment/comment.js"></script>
|
|
{% endblock %}
|
|
|
|
|
|
{% block content %}
|
|
{{ Sidebar(course, batch) }}
|
|
|
|
<div class="container">
|
|
<div class="lesson-page">
|
|
{{ pagination(prev_url, next_url) }}
|
|
|
|
<h2>{{ lesson.title }}</h2>
|
|
|
|
{% for s in lesson.get_sections() %}
|
|
<div class="section section-{{ s.type }}">
|
|
{{ render_section(s) }}
|
|
</div>
|
|
{% endfor %}
|
|
|
|
{{ pagination(prev_url, next_url) }}
|
|
|
|
</div>
|
|
</div>
|
|
{% 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_url, next_url) %}
|
|
<div class="lesson-pagination">
|
|
{% if prev_url %}
|
|
<a href="{{prev_url}}" class="btn">← Prev</a>
|
|
{% endif %}
|
|
{% if next_url %}
|
|
<a href="{{next_url}}" class="btn pull-right">Next →</a>
|
|
{% endif %}
|
|
<div style="clear: both;"></div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{%- block script %}
|
|
{{ super() }}
|
|
{{ LiveCodeEditorJS() }}
|
|
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
var batch_name = "{{ batch.name }}";
|
|
var lesson_name = "{{ lesson.name }}";
|
|
|
|
frappe.call("community.lms.api.save_current_lesson", {
|
|
"batch_name": batch_name,
|
|
"lesson_name": lesson_name
|
|
})
|
|
})
|
|
</script>
|
|
|
|
{%- endblock %}
|