Templates: modified routing logic, added data attributes in template

Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
scmmishra 2018-10-12 15:22:16 +05:30 committed by Aditya Hase
parent 9335593b56
commit 38c1baf719
8 changed files with 93 additions and 61 deletions

View File

@ -8,11 +8,12 @@
<meta name="keywords" content="ERP Software, Cloud ERP, Open Source ERP, Accounting Software, Online ERP, Online Accounting, ERP for small business, Learn ERP, ERPNext Academy, Learn ERPNext, Learn Accounting" /> <meta name="keywords" content="ERP Software, Cloud ERP, Open Source ERP, Accounting Software, Online ERP, Online Accounting, ERP for small business, Learn ERP, ERPNext Academy, Learn ERPNext, Learn Accounting" />
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% with current_content = current_content %} <div id="content-holder" data-type="{{current_content.content_type}}" data-content="{{ current_content.name }}" data-course="{{ current_course.name }}" data-program="{{ current_program }}">
{% with current_content = current_content, next_content = next_content, course_name = current_course.name, program=current_program%}
{% include "www/lms/templates/includes/" + current_content.content_type.lower() + ".html" %} {% include "www/lms/templates/includes/" + current_content.content_type.lower() + ".html" %}
{% endwith %} {% endwith %}
</div>
<style> <style>
.footer-message { .footer-message {
display: none; display: none;
@ -35,6 +36,10 @@
.article-content-section { .article-content-section {
padding-top: 0em !important; padding-top: 0em !important;
} }
.quiz-section {
padding-top: 0rem !important;
}
</style> </style>
{% endblock %} {% endblock %}

View File

@ -3,6 +3,17 @@ import frappe
def get_context(context): def get_context(context):
if frappe.form_dict['course']:
context.current_course = frappe.get_doc("Course", frappe.form_dict["course"]) context.current_course = frappe.get_doc("Course", frappe.form_dict["course"])
context.current_content = frappe.get_doc("Content", frappe.form_dict["content"]) context.current_content = frappe.get_doc("Content", frappe.form_dict["content"])
next_content = get_next_content() context.current_program = frappe.form_dict["program"]
context.next_content = get_next_content(context)
def get_next_content(context):
if context.current_course:
course_data = [content_item.content for content_item in context.current_course.course_content]
try:
return course_data[course_data.index(context.current_content.name) + 1]
except IndexError:
return None

View File

@ -13,7 +13,7 @@
<div class="card"> <div class="card">
<img src="{{ hero_image }}" style='height: 150px'> <img src="{{ hero_image }}" style='height: 150px'>
<div class='card-body'> <div class='card-body'>
<a href="/lms/program?code={{ code }}"> <a href="/lms/program?program={{ code }}">
<h5 class='card-title'>{{ program_name }}</h5> <h5 class='card-title'>{{ program_name }}</h5>
</a> </a>
<div>{{ description }}</div> <div>{{ description }}</div>

View File

@ -22,7 +22,7 @@
</span> </span>
</div> </div>
<div class='text-center col-xs-4 col-sm-3 col-md-2'> <div class='text-center col-xs-4 col-sm-3 col-md-2'>
<a class='btn btn-primary btn-sm btn-block' href="/lms/course?course={{ name }}&content=ERPNext Introduction">Start Course</a> <a class='btn btn-primary btn-sm btn-block' href="/lms/course?program={{ program.program_code }}&course={{ name }}&content={{ course_data[name][0] }}">Start Course</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,9 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from erpnext.education.utils import get_student_name
import frappe import frappe
def get_context(context): def get_context(context):
context.program = frappe.get_doc("Program", frappe.form_dict["code"]) print(get_student_name(frappe.session.user))
context.program = frappe.get_doc("Program", frappe.form_dict["program"])
context.course_list, context.course_data = get_courses(context) context.course_list, context.course_data = get_courses(context)
def get_courses(context): def get_courses(context):

View File

@ -10,7 +10,11 @@
</div> </div>
<div class="col-md-4 text-right"> <div class="col-md-4 text-right">
<a class='btn btn-outline-secondary' href="#">Previous</a> <a class='btn btn-outline-secondary' href="#">Previous</a>
<a class='btn btn-primary' href="#s">Next</a> {% if next_content != None %}
<a class='btn btn-primary' onclick="addActivity()" href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
{% else %}
<a class='btn btn-primary' onclick="addActivity()" href="/lms/program?program={{ program }}">Finish Course</a>
{% endif %}
</div> </div>
</div> </div>
<hr> <hr>
@ -23,7 +27,7 @@
</div> </div>
<div class="text-right hidden"> <div class="text-right hidden">
<a class='btn btn-outline-secondary' href="/classrooms/module">Previous</a> <a class='btn btn-outline-secondary' href="/classrooms/module">Previous</a>
<a class='btn btn-primary' href="/classrooms/module">Next</a> <a class='btn btn-primary' href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
</div> </div>
<div class="mt-3 text-right"> <div class="mt-3 text-right">
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a <a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a

View File

@ -1,56 +1,62 @@
{% macro quiz(question, opt1, opt2, opt3, opt4) %} {% macro quiz(loop_index, question_id, question, options) %}
<div class="question mt-4"> <div class="question mt-4" id="question" data-question="{{ question_id }}">
<h5>{{ question }}</h5> <h5>{{ loop_index }}{{ question }}</h5>
<div class="options ml-2"> <div class="options ml-2">
<div class="form-check pb-1 hidden">
<input class="form-check-input" type="radio" name="{{ question_id }}" value="0" checked>
</div>
{% for option in options %}
<div class="form-check pb-1"> <div class="form-check pb-1">
<input class="form-check-input" type="radio" name="{{ question }}" id="{{ opt1 }}" value="{{ opt1 }}"> <input class="form-check-input" type="radio" name="{{ question_id }}" id="{{loop_index}}-{{ option }}" value="{{ loop.index|str }}">
<label class="form-check-label" for="{{ opt1 }}"> <label class="form-check-label" for="{{loop_index}}-{{ option }}">
{{ opt1 }} {{ option }}
</label> </label>
</div> </div>
<div class="form-check pb-1"> {% endfor %}
<input class="form-check-input" type="radio" name="{{ question }}" id="{{ opt2 }}" value="{{ opt2 }}">
<label class="form-check-label" for="{{ opt2 }}">
{{ opt2 }}
</label>
</div>
<div class="form-check pb-1">
<input class="form-check-input" type="radio" name="{{ question }}" id="{{ opt3 }}" value="{{ opt3 }}">
<label class="form-check-label" for="{{ opt3 }}">
{{ opt3 }}
</label>
</div>
<div class="form-check pb-1">
<input class="form-check-input" type="radio" name="{{ question }}" id="{{ opt3 }}" value="{{ opt4 }}">
<label class="form-check-label" for="{{ opt3 }}">
{{ opt4 }}
</label>
</div>
</div>
</div> </div>
</div>
{% endmacro %} {% endmacro %}
<section class="article-section"> <section class="quiz-section">
<div class='container'> <div class='container'>
<div class="mt-3 row"> <div class="mt-3 row">
<div class="col-md-8"> <div class="col-md-8">
<h2>Quiz &mdash; Accounting with ERPNext</h2> <h2>Quiz: {{ current_content.name }}</h2>
</div> </div>
</div> </div>
<div class="content"> <div class="content">
<hr> <hr>
<form> <form id="quiz" name="{{ current_content.name }}">
{{ quiz('1. What is a Sales Invoice?','The bills that you raise to your Customers for the products or services you provide.','Bills that your Suppliers give you for their products or services.','The bills for accounting entries, like payments, credit and other types.','The bills that were recovered from an oblivion of files and folders stacked in a old and rusty closet.') }} <div id="quiz-body">
{{ quiz('2. How to create a Sales Invoice?','Accounts > Billing > Sales Invoice > New Sales Invoice','Accounts > Buying > New Sales Invoice','Accounts > CRM > New Sales Invoice','Accounts > Purchases > New Sales Invoice') }} {% for quiz_item in current_content.quiz %}
{{ quiz('3. The long term assets that have no physical existence but are rights that have value is known as','Current Assets','Fixed Assets','Intangible Assets','Investments') }} {{ quiz(loop.index|str +". ", quiz_item.name, quiz_item.question, [ quiz_item.option_1, quiz_item.option_2,
<div class="text-right"> quiz_item.option_3, quiz_item.option_4]) }}
{% endfor %}
</div>
<div class="mt-3">
<div id="quiz-actions" class="text-right">
<button class='btn btn-outline-secondary' type="reset">Reset</button> <button class='btn btn-outline-secondary' type="reset">Reset</button>
<button class='btn btn-primary' type="submit">Submit</button> <button class='btn btn-primary' type="button" onclick="submitQuiz()">Submit</button>
</div>
<div id="post-quiz-actions" class="row" hidden="hidden">
<div class="col-md-8 text-left">
<h3>Your Score: <span id="result"></span></h3>
</div>
<div class="col-md-4 text-right">
<a class='btn btn-outline-secondary' href="#">Previous</a>
{% if next_content != None %}
<a class='btn btn-primary' href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
{% else %}
<a class='btn btn-primary' href="/lms/program?program={{ program }}">Finish Course</a>
{% endif %}
</div>
</div>
</div> </div>
</form> </form>
</div> </div>
<div class="mt-3 text-right"> <div class="mt-3 text-right">
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a Mistake</a> <a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a
Mistake</a>
</div> </div>
</div> </div>
</section> </section>

View File

@ -13,7 +13,11 @@
</div> </div>
<div class="col-md-4 text-right"> <div class="col-md-4 text-right">
<a class='btn btn-outline-secondary' href="#">Previous</a> <a class='btn btn-outline-secondary' href="#">Previous</a>
<a class='btn btn-primary' href="#s">Next</a> {% if next_content != None %}
<a class='btn btn-primary' onclick="addActivity()" href="/lms/course?program={{ program }}&course={{ course_name }}&content={{ next_content }}">Next</a>
{% else %}
<a class='btn btn-primary' onclick="addActivity()" href="/lms/program?program={{ program }}">Finish Course</a>
{% endif %}
</div> </div>
</div> </div>
<hr> <hr>