fix: conflicts

This commit is contained in:
Jannat Patel
2022-02-22 11:18:57 +05:30
7 changed files with 111 additions and 67 deletions

View File

@@ -184,7 +184,8 @@ jinja = {
"school.lms.utils.is_eligible_to_review",
"school.lms.utils.get_initial_members",
"school.lms.utils.get_sorted_reviews",
"school.lms.utils.is_instructor"
"school.lms.utils.is_instructor",
"school.lms.utils.convert_number_to_character"
],
"filters": []
}

View File

@@ -2,6 +2,7 @@ import re
import frappe
from frappe.utils import flt, cint, cstr
from school.lms.md import markdown_to_html
import string
RE_SLUG_NOTALLOWED = re.compile("[^a-z0-9]+")
@@ -292,3 +293,6 @@ def get_initial_members(course):
def is_instructor(course):
return len(list(filter(lambda x: x.name == frappe.session.user, get_instructors(course)))) > 0
def convert_number_to_character(number):
return string.ascii_uppercase[number]

View File

@@ -57,7 +57,7 @@
</div>
<div>
<a class="button-links" href="{{get_profile_url(review.owner_details.username) }}">
<span class="review-author">
<span class="bold-heading">
{{ review.owner_details.full_name }}
</span>
</a>

View File

@@ -308,11 +308,6 @@ input[type=checkbox] {
width: 100px;
}
.custom-checkbox {
display: flex;
align-items: center;
}
.custom-checkbox>label>input {
visibility: hidden;
}
@@ -324,6 +319,10 @@ input[type=checkbox] {
border-radius: var(--border-radius-md);
}
.empty-checkbox {
margin-right: 0.5rem;
}
.custom-checkbox>label>input:checked+.empty-checkbox {
background: url(/assets/school/icons/tick.svg);
background-repeat: no-repeat;
@@ -331,6 +330,8 @@ input[type=checkbox] {
}
.quiz-label {
display: flex;
align-items: center;
margin-bottom: 0;
cursor: pointer;
}
@@ -815,12 +816,16 @@ input[type=checkbox] {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 5rem;
}
.question {
flex-direction: column;
width: 85%;
margin: 0 auto;
}
.question-card {
flex-direction: column;
padding: 1.25rem;
}
.question p {
@@ -879,6 +884,7 @@ input[type=checkbox] {
.lesson-pagination {
display: flex;
justify-content: space-between;
align-items: center;
margin: 24px 0px 0px;
}
@@ -1678,7 +1684,7 @@ pre {
}
}
.review-author {
.bold-heading {
font-size: var(--text-lg);
color: var(--gray-900);
font-weight: 600;
@@ -1714,3 +1720,36 @@ pre {
.course-home-top-container {
position: relative;
}
.question-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 2rem;
}
.question-number {
padding: 0.25rem 0.75rem;
border-radius: 50%;
box-shadow: var(--shadow-sm);
}
.option-text {
padding: 0.75rem;
box-shadow: var(--shadow-sm);
border-radius: var(--border-radius-md);
flex: 1;
}
.active-option .option-text {
background-color: var(--blue-50);
border: 1px solid var(--blue-500);
}
.question-text {
font-size: var(--text-lg);
color: var(--gray-900);
font-weight: 600;
flex-grow: 1;
margin-left: 1rem;
}

View File

@@ -2,43 +2,40 @@
<div class="card-divider"></div>
<div class="mt-5">
<div class="common-card-style question-card">
<form id="quiz-form">
<div class="questions">
{% for question in quiz.questions %}
{% set instruction = _("Choose all answers that apply") if question.multiple else _("Choose 1 answer") %}
<div class="question {% if loop.index == 1 %} active-question {% else %} hide {% endif %}"
data-question="{{ question.question }}" data-multi="{{ question.multiple}}" data-qt-index="{{ loop.index }}">
<p>{{ frappe.utils.md_to_html(question.question) }}</p>
{% if question.multiple %}
<small class="font-weight-bold">{{ _("Choose all answers that apply:") }}</small>
{% else %}
<small class="font-weight-bold">{{ _("Choose 1 answer:") }}</small>
{% endif %}
<div class="card-divider"></div>
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
{% for option in options %}
{% if option %}
<div class="custom-checkbox">
<label class="quiz-label">
<input class="option" value="{{ option | urlencode }}"
data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
<img class="empty-checkbox mr-3" />
<span class="label-area">{{ frappe.utils.md_to_html(option) }}</span>
</label>
<div class="question-header">
<div class="question-number">{{ loop.index }}</div>
<div class="question-text">
<div class="course-meta pull-right ml-2"> {{ instruction }} </div>
{{ frappe.utils.md_to_html(question.question) }}
</div>
</div>
{% set explanation = question['explanation_' + loop.index | string] %}
{% if explanation %}
<small class="explanation muted-text hide">{{ explanation }}</small>
{% endif %}
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
{% for option in options %}
{% if option %}
<div class="mb-2">
<div class="custom-checkbox">
<label class="quiz-label">
<div class="course-meta font-weight-bold ml-3"> {{ convert_number_to_character(loop.index - 1) }}</div>
<input class="option" value="{{ option | urlencode }}"
data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
<div class="option-text">{{ frappe.utils.md_to_html(option) }}</div>
</label>
</div>
<div class="card-divider"></div>
{% set explanation = question['explanation_' + loop.index | string] %}
{% if explanation %}
<small class="explanation ml-3 hide">{{ explanation }}</small>
{% endif %}
</div>
{% endif %}
{% endfor %}
@@ -50,9 +47,9 @@
<button class="button pull-right is-default" id="check" disabled>{{ _("Check") }}</button>
<div class="button is-secondary hide" id="next">{{ _("Next Question") }}</div>
<div class="button is-secondary is-default hide" id="summary">{{ _("Summary") }}</div>
<small id="submission-message" class="font-weight-bold hide"> {{ _("Please join the course to submit the Quiz.") }}</small>
<small id="submission-message" class="font-weight-bold hide"> {{ _("Please join the course to submit the Quiz.") }} </small>
<div class="button is-secondary hide" id="try-again">{{ _("Try Again") }}</div>
</div>
<div class="button is-secondary pull-right hide" id="try-again">{{ _("Try Again") }}</div>
<h4 class="success-message"></h4>
<h5 class="score text-muted"></h5>
</form>

View File

@@ -108,7 +108,7 @@
{% set progress = get_progress(course.name, lesson.name) %}
<div class="custom-checkbox {% if progress == 'Complete' %} hide {% endif %}">
<label class="quiz-label">
<input class="option mark-progress" type="checkbox" checked>
<input class="mark-progress" type="checkbox" checked>
<img class="empty-checkbox" />
<span class="small">{{ _("Mark as complete on moving to the next lesson") }}</span>
</label>

View File

@@ -43,7 +43,7 @@ frappe.ready(() => {
$(".clear-work").click((e) => {
clear_work(e);
})
});
});
@@ -57,8 +57,10 @@ const save_current_lesson = () => {
};
const enable_check = (e) => {
if ($(".option:checked").length && $("#check").attr("disabled")) {
if ($(".option:checked").length) {
$("#check").removeAttr("disabled");
$(".custom-checkbox").removeClass("active-option");
$(".option:checked").closest(".custom-checkbox").addClass("active-option");
}
};
@@ -164,7 +166,7 @@ const quiz_summary = (e) => {
callback: (data) => {
var message = data.message == total_questions ? "Excellent Work" : "You were almost there."
$(".question").addClass("hide");
$(".quiz-footer").addClass("hide");
$("#summary").addClass("hide");
$("#quiz-form").parent().prepend(
`<div class="text-center summary"><h2>${message} 👏 </h2>
<div class="font-weight-bold">${data.message}/${total_questions} correct.</div></div>`);
@@ -222,8 +224,9 @@ const parse_options = () => {
};
const add_icon = (element, icon) => {
var label = $(element).parent().find(".label-area p").text();
$(element).parent().empty().html(`<img class="mr-3" src="/assets/school/icons/${icon}.svg"> ${label}`);
$(element).closest(".custom-checkbox").removeClass("active-option");
var label = $(element).siblings(".option-text").text();
$(element).parent().empty().html(`<div class="option-text"><img class="mr-3" src="/assets/school/icons/${icon}.svg"> ${label}</div>`);
};
const add_to_local_storage = (quiz_name, current_index, answer, is_correct) => {
@@ -354,27 +357,27 @@ const clear_work = (e) => {
parent.addClass("hide");
parent.siblings(".attach-file").removeClass("hide").val(null);
parent.siblings(".submit-work").removeClass("hide");
}
};
const fetch_assignments = () => {
if ($(".attach-file").length > 0) {
frappe.call({
method: "school.lms.doctype.lesson_assignment.lesson_assignment.get_assignment",
args: {
"lesson": $(".title").attr("data-lesson")
},
callback: (data) => {
if (data.message && data.message.length) {
const assignments = data.message;
for (let i in assignments) {
let target = $(`#${assignments[i]["id"]}`);
target.addClass("hide");
target.siblings(".submit-work").addClass("hide");
target.siblings(".preview-work").removeClass("hide");
target.siblings(".preview-work").find("a").attr("href", assignments[i]["assignment"]).text(assignments[i]["file_name"]);
}
if ($(".attach-file").length <= 0)
return;
frappe.call({
method: "school.lms.doctype.lesson_assignment.lesson_assignment.get_assignment",
args: {
"lesson": $(".title").attr("data-lesson")
},
callback: (data) => {
if (data.message && data.message.length) {
const assignments = data.message;
for (let i in assignments) {
let target = $(`#${assignments[i]["id"]}`);
target.addClass("hide");
target.siblings(".submit-work").addClass("hide");
target.siblings(".preview-work").removeClass("hide");
target.siblings(".preview-work").find("a").attr("href", assignments[i]["assignment"]).text(assignments[i]["file_name"]);
}
}
})
}
}
}
});
};