feat: quiz listing

This commit is contained in:
Jannat Patel
2022-08-16 17:08:43 +05:30
parent 5d6dc16a19
commit eb50f6fd8f
9 changed files with 193 additions and 98 deletions

View File

@@ -137,6 +137,8 @@ website_route_rules = [
{"from_route": "/courses/<course>/<certificate>", "to_route": "courses/certificate"},
{"from_route": "/courses/<course>/learn", "to_route": "batch/learn"},
{"from_route": "/courses/<course>/learn/<int:chapter>.<int:lesson>", "to_route": "batch/learn"},
{"from_route": "/courses/quiz-list", "to_route": "batch/quiz_list"},
{"from_route": "/courses/quiz/<quiz-name>", "to_route": "batch/quiz"},
{"from_route": "/courses/<course>/progress", "to_route": "batch/progress"},
{"from_route": "/courses/<course>/join", "to_route": "batch/join"},
{"from_route": "/courses/<course>/manage", "to_route": "cohorts"},

View File

@@ -2,103 +2,103 @@
// For license information, please see license.txt
frappe.ui.form.on('Course Lesson', {
setup: function (frm) {
frm.trigger('setup_help');
},
setup_help(frm) {
frm.get_field('help').html(`
<p>You can add some more additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.</p>
<div class="row font-weight-bold mb-3">
<div class="col-sm-8">
Content Type
</div>
<div class="col-sm-4">
Syntax
</div>
</div>
setup: function (frm) {
frm.trigger('setup_help');
},
setup_help(frm) {
frm.get_field('help').html(`
<p>${__("You can add some more additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.")}</p>
<div class="row font-weight-bold mb-3">
<div class="col-sm-8">
${__("Content Type")}
</div>
<div class="col-sm-4">
${__("Syntax")}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
Video
</div>
<div class="col-sm-4">
{{ Video("url_of_source") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
${__("Video")}
</div>
<div class="col-sm-4">
{{ Video("url_of_source") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
YouTube Video
</div>
<div class="col-sm-4">
{{ YouTubeVideo("unique_embed_id") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
${__("YouTube Video")}
</div>
<div class="col-sm-4">
{{ YouTubeVideo("unique_embed_id") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
Exercise
</div>
<div class="col-sm-4">
{{ Exercise("exercise_name") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
${"Exercise"}
</div>
<div class="col-sm-4">
{{ Exercise("exercise_name") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
Quiz
</div>
<div class="col-sm-4">
{{ Quiz("lms_quiz_name") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
${__("Quiz")}
</div>
<div class="col-sm-4">
{{ Quiz("lms_quiz_name") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
Assignment
</div>
<div class="col-sm-4">
{{ Assignment("id-filetype") }}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
${__("Assignment")}
</div>
<div class="col-sm-4">
{{ Assignment("id-filetype") }}
</div>
</div>
<hr>
<hr>
<div class="row font-weight-bold mb-3">
<div class="col-sm-8">
Supported File Types for Assignment
</div>
<div class="col-sm-4">
Syntax
</div>
</div>
<div class="row font-weight-bold mb-3">
<div class="col-sm-8">
${__("Supported File Types for Assignment")}
</div>
<div class="col-sm-4">
${__("Syntax")}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
.doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document
</div>
<div class="col-sm-4">
Document
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
.doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document
</div>
<div class="col-sm-4">
${__("Document")}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
.pdf
</div>
<div class="col-sm-4">
PDF
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
.pdf
</div>
<div class="col-sm-4">
${__("PDF")}
</div>
</div>
<div class="row mb-3">
<div class="col-sm-8">
.png, .jpg, .jpeg
</div>
<div class="col-sm-4">
Image
</div>
</div>
`);
}
<div class="row mb-3">
<div class="col-sm-8">
.png, .jpg, .jpeg
</div>
<div class="col-sm-4">
${__("Image")}
</div>
</div>
`);
}
});

View File

@@ -1557,7 +1557,7 @@ li {
margin-top: 0.25rem;
background-color: var(--bg-light-gray);
border-radius: var(--border-radius);
border: 1px dashed var(--gray-400);
border: 1px dashed var(--gray-600);
padding: 0.5rem 0.75rem;
width: fit-content;
}
@@ -1595,3 +1595,7 @@ li {
align-items: center;
font-size: var(--text-md);
}
.table {
margin-bottom: 0;
}

View File

@@ -120,7 +120,7 @@
{% else %}
<div class="">
<div class="button is-primary pull-right join-batch" data-course="{{ course.name | urlencode }}"> {{ _("Start Learning") }} </div>
<div class="btn btn-primary pull-right join-batch" data-course="{{ course.name | urlencode }}"> {{ _("Start Learning") }} </div>
<div class=""> {{ _("This lesson is not available for preview. Please join the course to access it.") }} </div>
</div>
{% endif %}
@@ -133,11 +133,13 @@
</div>
{% endmacro %}
<!-- Pagination -->
{% macro pagination(prev_url, next_url) %}
<div class="lesson-pagination">
<div>
{% if prev_url %}
<a class="button is-secondary dark-links prev" href="{{ prev_url }}">
<a class="btn btn-secondary dark-links prev" href="{{ prev_url }}">
<img class="mr-2" src="/assets/lms/icons/left-arrow.svg">
{{ _("Prev") }}
</a>
@@ -154,14 +156,14 @@
</label>
</div>
<div class="button is-secondary mark-progress {{ progress }} {% if progress == 'Incomplete' or progress == None %} hide {% endif %}"
<div class="btn btn-default mark-progress {{ progress }} {% if progress == 'Incomplete' or progress == None %} hide {% endif %}"
data-progress="Incomplete">
{{ _("Mark as Incomplete") }}
</div>
{% endif %}
<div>
<a class="button is-primary next {% if membership.progress|int == 100 and not next_url %} hide {% endif %}"
<a class="btn btn-primary next {% if membership.progress|int == 100 and not next_url %} hide {% endif %}"
{% if next_url %} data-href="{{ next_url }}" {% endif %} href="">
{% if next_url %} {{ _("Next") }} {% else %} {{ _("Mark as Complete") }} {% endif %}
<img class="ml-2" src="/assets/lms/icons/side-arrow-white.svg">
@@ -171,6 +173,8 @@
</div>
{% endmacro %}
<!-- Edit Lesson -->
{% macro EditLesson(lesson) %}
<div id="body" {% if lesson.body %} data-body="{{ lesson.body }}" {% endif %}></div>
@@ -180,8 +184,9 @@
</label>
<div class="mt-4">
<button class="btn btn-primary btn-md btn-lesson pull-right ml-2"> {{ _("Save") }} </button>
<button class="btn btn-secondary btn-md pull-right btn-back"> {{ _("Back to Lesson") }} </button>
<button class="btn btn-primary btn-sm btn-lesson pull-right ml-2"> {{ _("Save") }} </button>
<button class="btn btn-secondary btn-sm pull-right btn-back ml-2"> {{ _("Back to Lesson") }} </button>
<a class="btn btn-secondary btn-sm pull-right" href="/courses/quiz-list"> {{ _("Create a Quiz") }} </a>
<div class="attachments-parent">
<div class="attachment-controls">
@@ -192,7 +197,7 @@
<span class="attachment-count" data-count="0">0 {{ _("attachments") }}</span>
</div>
<div class="add-attachment">
<span class="btn btn-md btn-secondary">
<span class="btn btn-sm btn-secondary">
<svg class="icon icon-sm">
<use class="" href="#icon-upload">
</svg>
@@ -203,6 +208,51 @@
<table class="attachments common-card-style collapse hide" id="collapse-attachments"></table>
</div>
</div>
{{ HelpArticle() }}
{% endmacro %}
<!-- Help Article -->
{% macro HelpArticle() %}
<div>
<h3> {{ _("Help Article") }} </h3>
<p>
{{ _("You can add additional content to the lesson using a special syntax.The table below
mentions all types of dynamic content that you can add to the lessons and the syntax for the
same.") }}
</p>
<table class="table w-100">
<tr>
<th class="w-50"> {{ _("Content Type") }} </th>
<th> {{ _("Syntax") }} </th>
</tr>
<tr>
<td>
{{ _("Video") }}
</td>
<td>
{% raw %} {{ Video("url_of_source") }} {% endraw %}
</td>
</tr>
<tr>
<td>
{{ _("YouTube Video") }}
</td>
<td>
{% raw %} {{ YouTubeVideo("unique_embed_id") }} {% endraw %}
</td>
</tr>
<tr>
<td>
{{ _("Quiz") }}
</td>
<td>
{% raw %} {{ Quiz("lms_quiz_name") }} {% endraw %}
</td>
</tr>
</table>
</div>
{% endmacro %}

View File

@@ -56,7 +56,6 @@ def get_current_lesson_details(lesson_number, context):
redirect_to_lesson(context.course)
lesson_info = details_list[0]
lesson_info.body = lesson_info.body.replace("\"", "'")
print(lesson_info)
return lesson_info

0
lms/www/batch/quiz.html Normal file
View File

0
lms/www/batch/quiz.py Normal file
View File

View File

@@ -0,0 +1,36 @@
{% extends "templates/base.html" %}
{% block title %}
{{ _("Quiz List") }}
{% endblock %}
{% block head_include %}
{% include "public/icons/symbol-defs.svg" %}
{% endblock %}
{% block content %}
<div class="common-page-style">
<div class="container">
<a class="btn btn-primary btn-sm pull-right"> {{ _("Add Quiz") }} </a>
<div class="course-home-headings"> {{ _("Quiz List") }} </div>
<div class="common-card-style">
<table class="table">
<tr>
<td style="width: 5%;"> {{ _("No.") }} </td>
<td> {{ _("Quiz") }} </td>
</tr>
{% for quiz in quiz_list %}
<tr style="position: relative; color: var(--text-color);">
<td> {{ loop.index }} </td>
<td>
<a class="button-links" href="/courses/quiz/{{ quiz.name }}">{{ quiz.name }}</a>
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,4 @@
import frappe
def get_context(context):
context.quiz_list = frappe.get_all("LMS Quiz", {"owner": frappe.session.user}, ["name", "title"])