feat: added program and course pages

This commit is contained in:
Shivam Mishra 2019-05-20 11:55:17 +05:30
parent 823c79588b
commit d7e8298a5f
3 changed files with 99 additions and 14 deletions

View File

@ -0,0 +1,77 @@
{% extends "templates/base.html" %}
{% block title %}{{ course.course_name }}{% endblock %}
{% block head_include %}
<style>
div.card-hero-img {
height: 220px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-color: rgb(250, 251, 252);
}
.card-image-wrapper {
display: flex;
overflow: hidden;
height: 220px;
background-color: rgb(250, 251, 252);
justify-content: center;
}
.image-body {
align-self: center;
color: #d1d8dd;
font-size: 24px;
font-weight: 600;
line-height: 1;
padding: 20px;
}
</style>
{% endblock %}
{% macro card(topic, index, length) %}
<div class="col-sm-{{ 12 if length%3 == 1 and index == 1 else 6 if length%3 == 2 and index in [1,2] else 4}} mb-4 text-left">
<div class="card h-100">
<a href="/lms/content?topic={{ topic.name }}&type=Content" class="no-decoration no-underline">
{% if topic.hero_image %}
<div class="card-hero-img" style="background-image: url({{ topic.hero_image }})"></div>
{% else %}
<div class="card-image-wrapper text-center">
<div class="image-body">{{ topic.topic_name }}</div>
</div>
{% endif %}
<div class='card-body'>
<h5 class='card-title'>{{ topic.topic_name }}</h5>
<div>
<ol class="list-unstyled">
{% for content in topic.topic_content %}
<li><a class="text-muted" href="/lms/content?topic={{ topic.name }}&type={{ content.content_type }}&content={{ content.content }}">{{ content.content }}</li></a>
{% endfor %}
</ol>
</div>
</div>
</a>
</div>
</div>
{% endmacro %}
{% block content %}
<section class="top-section ">
<div class='container pb-5'>
<h1>{{ course.course_name }}</h1>
<p class='lead'>{{ course.course_intro }}</p>
<p class="mt-4">
<a class="btn btn-primary btn-lg" style="width: 170px;" href="/login#signup">Sign Up</a>
</p>
</div>
<div class='container'>
<div class="row mt-5">
{% for topic in topics %}
{{ card(topic.as_dict(), loop.index, topics|length) }}
{% endfor %}
</div>
</div>
</section>
{% endblock %}

11
erpnext/www/lms/course.py Normal file
View File

@ -0,0 +1,11 @@
from __future__ import unicode_literals
import erpnext.education.utils as utils
import frappe
no_cache = 1
def get_context(context):
context.education_settings = frappe.get_single("Education Settings")
course = frappe.get_doc('Course', frappe.form_dict['name'])
context.course = course
context.topics = course.get_topics()

View File

@ -31,23 +31,20 @@
{% endblock %}
{% macro card(program, is_enrolled) %}
<div class="col-sm mb-4 text-left">
<div class="card">
<a href="/lms/program?name={{ program.name }}" class="no-decoration no-underline">
{% if program.hero_image %}
<div class="card-hero-img" style="background-image: url({{ program.hero_image }})"></div>
{% macro card(course, index, length) %}
<div class="col-sm-{{ 12 if length%3 == 1 and index == 1 else 6 if length%3 == 2 and index in [1,2] else 4}} mb-4 text-left">
<div class="card h-100">
<a href="/lms/course?name={{ course.name }}" class="no-decoration no-underline">
{% if course.hero_image %}
<div class="card-hero-img" style="background-image: url({{ course.hero_image }})"></div>
{% else %}
<div class="card-image-wrapper text-center">
<div class="image-body">{{ program.program_name }}</div>
<div class="image-body">{{ course.course_name }}</div>
</div>
{% endif %}
<div class='card-body'>
<h5 class='card-title'>{{ program.program_name }}</h5>
<div>{{ program.description }}</div>
</div>
<div class='card-footer'>
<a href='#' class='small'>Watch Intro</a>
<h5 class='card-title'>{{ course.course_name }}</h5>
<div>{{ course.course_intro }}</div>
</div>
</a>
</div>
@ -65,8 +62,8 @@
</div>
<div class='container'>
<div class="row mt-5">
{% for program in all_programs %}
{{ card(program.program, program.is_enrolled) }}
{% for course in program.courses %}
{{ card(frappe.get_doc("Course", course.course), loop.index, program.courses|length) }}
{% endfor %}
</div>
</div>