Merge branch 'main' into translations

This commit is contained in:
Jannat Patel
2022-06-07 11:28:42 +05:30
committed by GitHub
24 changed files with 184 additions and 81 deletions

View File

@@ -214,7 +214,6 @@ profile_mandatory_fields = [
"bio",
"linkedin",
"education",
"work_experience",
"skill",
"preferred_functions",
"preferred_industries",

View File

@@ -4,9 +4,24 @@
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from frappe import _
from frappe.utils import getdate, format_date, format_time
class LMSCertificateRequest(Document):
pass
def validate(self):
self.validate_if_existing_requests()
def validate_if_existing_requests(self):
existing_requests = frappe.get_all("LMS Certificate Request", {
"member": self.member,
"course": self.course
}, ["date", "start_time", "course"])
for req in existing_requests:
if req.date == getdate(self.date) and getdate() <= getdate(self.date):
course_title = frappe.db.get_value("LMS Course", req.course, "title")
frappe.throw(_(f"You already have an evaluation on {format_date(req.date, 'medium')} at {format_time(req.start_time, 'short')} for the course {course_title}."))
@frappe.whitelist()
def create_certificate_request(course, date, day, start_time, end_time):

View File

View File

@@ -0,0 +1,5 @@
{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %}
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short")) }}</p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -0,0 +1,27 @@
{
"attach_print": 0,
"channel": "Email",
"creation": "2022-06-03 11:02:34.579145",
"days_in_advance": 0,
"docstatus": 0,
"doctype": "Notification",
"document_type": "LMS Certificate Request",
"enabled": 1,
"event": "New",
"idx": 0,
"is_standard": 1,
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n<p> {{ _('Your evaluation for the course ${0} has been scheduled on ${1} at ${2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}</p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
"modified": "2022-06-03 11:49:01.310656",
"modified_by": "Administrator",
"module": "LMS",
"name": "Certificate Request Creation",
"owner": "Administrator",
"recipients": [
{
"receiver_by_document_field": "member"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"subject": "Your evaluation slot has been booked"
}

View File

@@ -0,0 +1 @@
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -0,0 +1,5 @@
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -0,0 +1,5 @@
{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %}
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short")) }}</p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -0,0 +1,28 @@
{
"attach_print": 0,
"channel": "Email",
"creation": "2022-06-03 11:51:02.681803",
"date_changed": "date",
"days_in_advance": 1,
"docstatus": 0,
"doctype": "Notification",
"document_type": "LMS Certificate Request",
"enabled": 1,
"event": "Days Before",
"idx": 0,
"is_standard": 1,
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n<p> {{ _('Your evaluation for the course ${0} has been scheduled on ${1} at ${2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}</p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
"modified": "2022-06-03 11:51:02.681803",
"modified_by": "Administrator",
"module": "LMS",
"name": "Certificate Request Reminder",
"owner": "Administrator",
"recipients": [
{
"receiver_by_document_field": "member"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"subject": "Reminder for Certificate Evaluation"
}

View File

@@ -0,0 +1,3 @@
{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %}
<p> {{ _('Your evaluation for the course ${0} has been scheduled on ${1} at ${2}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short")) }}</p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -0,0 +1,5 @@
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -1,6 +1,9 @@
frappe.ready(function() {
frappe.web_form.after_save = () => {
frappe.msgprint(__("Chapter has been saved successfully. Go back to the course and add this chapter to the chapters table."))
frappe.show_alert({
message:__("Chapter has been saved successfully. Go back to the course and add this chapter to the chapters table."),
indicator:'green'
}, 3);
setTimeout(() => {
window.location.href = `/courses/${frappe.web_form.doc.course}`;
}, 3000);

View File

@@ -49,10 +49,13 @@ const show_upload_modal = () => {
};
const show_success_message = () => {
frappe.msgprint(__(`Lesson has been saved successfully. Go back to the chapter and add this lesson to the lessons table.`));
frappe.show_alert({
message: __(`Lesson has been saved successfully. Go back to the chapter and add this lesson to the lessons table.`),
indicator:'green'
}, 3);
setTimeout(() => {
window.location.href = `/courses/${this.course}`;
}, 2000);
}, 3000);
};
const add_file_upload_component = () => {

View File

@@ -22,7 +22,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2022-02-23 09:32:37.352930",
"modified": "2022-06-06 10:38:37.784113",
"modified_by": "Administrator",
"module": "LMS",
"name": "profile",
@@ -83,7 +83,7 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"reqd": 1,
"show_in_filter": 0
},
{
@@ -244,7 +244,7 @@
"max_value": 0,
"options": "Work Experience",
"read_only": 0,
"reqd": 1,
"reqd": 0,
"show_in_filter": 0
},
{

View File

@@ -29,13 +29,12 @@
{% if membership or lesson.include_in_preview %}
<a class="lesson-links" href="{{ get_lesson_url(course.name, lesson.number) }}{{course.query_parameter}}"
data-course="{{ course.name }}">
<svg class="icon icon-md mr-2">
<svg class="icon icon-sm mr-2">
<use class="" href="#{{ lesson.icon }}">
</svg>
{{ lesson.title }}
<span>{{ lesson.title }}</span>
{% if membership %}
<svg class="icon icon-md lesson-progress-tick {{ get_progress(course.name, lesson.name) != 'Complete' and 'hide' }}">
<svg class="icon icon-sm lesson-progress-tick {{ get_progress(course.name, lesson.name) != 'Complete' and 'hide' }}">
<use class="" href="#icon-green-check">
</svg>
{% endif %}
@@ -48,7 +47,7 @@
href="{{ get_lesson_url(course.name, lesson.number) }}{{course.query_parameter}}"
data-course="{{ course.name }}">
<svg class="icon icon-md">
<svg class="icon icon-sm">
<use class="" href="#icon-lock">
</svg>
<div>{{ lesson.title }}</div>
@@ -57,7 +56,7 @@
{% else %}
<div class="no-preview" title="This lesson is not available for preview" data-course="{{ course.name }}">
<div class="lesson-links">
<svg class="icon icon-md">
<svg class="icon icon-sm">
<use class="" href="#icon-lock-gray">
</svg>
<div>{{ lesson.title }}</div>

View File

@@ -411,20 +411,17 @@ input[type=checkbox] {
display: flex;
align-items: center;
padding: 0.5rem;
color: inherit;
color: var(--gray-900);
font-size: var(--text-base);
}
.lesson-links:hover {
cursor: pointer;
text-decoration: none;
color: inherit;
color: var(--gray-900);
border-radius: var(--border-radius-md);
}
.course-content-parent .lesson-links {
font-size: var(--text-base);
}
.lessons {
margin-left: 2rem;
}
@@ -540,11 +537,6 @@ input[type=checkbox] {
flex-direction: column;
}
.question-card {
flex-direction: column;
padding: 1.25rem;
}
.question p {
margin-bottom: 0;
}
@@ -574,12 +566,13 @@ input[type=checkbox] {
margin-top: 1rem;
}
.lesson-content-card {
margin: 3rem 0;
.lesson-content {
padding: 1.5rem;
flex-direction: column;
}
.lesson-page {
background-color: #FFFFFF;
.lesson-content-card {
margin: 2rem 0 3rem;
}
.lesson-content-card .alert-dismissible .close {
@@ -607,7 +600,6 @@ input[type=checkbox] {
display: flex;
justify-content: space-between;
align-items: center;
margin: 2rem 0 4rem;
}
.lesson-pagination-parent {
@@ -1450,3 +1442,7 @@ li {
.no-preview {
color: var(--gray-600);
}
.discussions-parent .empty-state {
background-color: var(--gray-200);
}

View File

@@ -28,13 +28,13 @@ const join_course = (e) => {
"callback": (data) => {
if (data.message == "OK") {
$(".no-preview-modal").modal("hide");
frappe.msgprint({
"title": __("Successfully Enrolled"),
"message": __("You are now a student of this course.")
});
frappe.show_alert({
message: __("You are now a student of this course."),
indicator:'green'
}, 3);
setTimeout(function () {
window.location.href = `/courses/${course}/learn/1.1`;
}, 2000);
}, 3000);
}
}
})
@@ -55,10 +55,13 @@ const notify_user = (e) => {
},
callback: (data) => {
$(".no-preview-modal").modal("hide");
frappe.msgprint(__("You have opted to be notified for this course. You will receive an email when the course becomes available."));
frappe.show_alert({
message: __("You have opted to be notified for this course. You will receive an email when the course becomes available."),
indicator:'green'
}, 3);
setTimeout(() => {
window.location.reload();
}, 2000);
}, 3000);
}
})
};

View File

@@ -1,5 +1,5 @@
{% if attempts_exceeded %}
<div class="common-card-style text-center p-5" style="flex-direction: column;">
<div class="text-center">
<div class="font-weight-bold mb-4" style="font-size: var(--text-lg);">{{ quiz.title }}</div>
<div> {{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }} </div>
<div> {{ _("Your latest score is {0}.").format(last_attempt_score) }} </div>
@@ -7,7 +7,7 @@
{% else %}
<div id="quiz-title" class="hide" data-max-attempts="{{ quiz.max_attempts }}">{{ quiz.title }}</div>
<div class="common-card-style question-card">
<div class="">
<div id="start-banner" class="text-center">
<div class="font-weight-bold mb-3" style="font-size: var(--text-lg);"> {{ quiz.title }} </div>
<div class="mb-3">{{ _("There are {0} questions in this quiz.").format(quiz.questions | length) }}{% if quiz.max_attempts %}
@@ -70,7 +70,7 @@
<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>
<div class="button is-secondary is-default hide" id="summary">{{ _("Submit") }}</div>
<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>

View File

@@ -22,9 +22,6 @@
</div>
<div class="lesson-pagination-parent">
{{ LessonContent(lesson) }}
{% if membership %}
{{ pagination(prev_url, next_url) }}
{% endif %}
{{ Discussions() }}
</div>
</div>
@@ -45,7 +42,7 @@
{% macro LessonContent(lesson) %}
{% set instructors = get_instructors(course.name) %}
{% set is_instructor = is_instructor(course.name) %}
<div class="lesson-content">
<div class="common-card-style lesson-content">
<div class="lesson-title">
<div class="course-home-headings title mb-0
{% if membership %} is-member {% endif %}
@@ -100,6 +97,8 @@
{% endif %}
</div>
{{ pagination(prev_url, next_url) }}
</div>
{% endmacro %}
@@ -145,11 +144,13 @@
{% endmacro %}
{% macro Discussions() %}
{% set topics_count = frappe.db.count("Discussion Topic",
{"reference_doctype": "Course Lesson", "reference_docname": lesson.name}) %}
{% set is_instructor = frappe.session.user == course.instructor %}
{% set condition = is_instructor if is_instructor else membership %}
{% set doctype, docname = _("Course Lesson"), lesson.name %}
{% set title = _("Questions") %}
{% set cta_title = _("Ask a Question") %}
{% set title = "Questions" if topics_count else "" %}
{% set cta_title = "Ask a Question" %}
{% set button_name = _("Start Learning") %}
{% set redirect_to = "/courses/" + course.name %}
{% set empty_state_title = _("Have a doubt?") %}

View File

@@ -27,12 +27,6 @@ def get_context(context):
context.custom_certificate_template = frappe.db.get_value("Web Template", template_name, "template")
context.custom_template = render_template(context.custom_certificate_template, context)
context.metatags = {
"title": f"{member.full_name} - {course.title}",
"image": course.image,
"keywords": course.title, member.full_name
}
def redirect_to_course_list():
frappe.local.flags.redirect_location = "/courses"
raise frappe.Redirect

View File

@@ -161,22 +161,27 @@ const element_not_in_viewport = (el) => {
};
const submit_for_review = (e) => {
let course = $(e.currentTarget).data("course");
frappe.call({
method: "lms.lms.doctype.lms_course.lms_course.submit_for_review",
args: {
"course": course
},
callback: (data) => {
if (data.message == "No Chp") {
frappe.msgprint(__(`There are no chapters in this course.
Please add chapters and lessons to your course before you submit it for review.`));
} else if (data.message == "OK") {
frappe.msgprint(__("Your course has been submitted for review."))
window.location.reload();
}
}
})
let course = $(e.currentTarget).data("course");
frappe.call({
method: "lms.lms.doctype.lms_course.lms_course.submit_for_review",
args: {
"course": course
},
callback: (data) => {
if (data.message == "No Chp") {
frappe.msgprint(__(`There are no chapters in this course.
Please add chapters and lessons to your course before you submit it for review.`));
} else if (data.message == "OK") {
frappe.show_alert({
message: __("Your course has been submitted for review."),
indicator:'green'
}, 3);
setTimeout(() => {
window.location.reload();
}, 3000);
}
}
});
};
const apply_cetificate = (e) => {
@@ -199,10 +204,13 @@ const submit_slot = (e) => {
},
callback: (data) => {
$("#slot-modal").modal("hide");
frappe.msgprint(__("Your slot has been booked. Prepare well for the evaluations."));
frappe.show_alert({
message: __("Your slot has been booked. Prepare well for the evaluations."),
indicator:'green'
}, 3);
setTimeout(() => {
window.location.reload();
}, 2000);
}, 3000);
}
});
};

View File

@@ -18,15 +18,18 @@ const open_report_dialog = (e) => {
};
const report = (e) => {
frappe.call({
method: "lms.job.doctype.job_opportunity.job_opportunity.report",
args: {
"job": $(e.currentTarget).data("job"),
"reason": $(".report-field").val()
},
callback: (data) => {
$(".report-modal").modal("hide");
frappe.msgprint(__("Thanks for informing us about this post. The admin will look into it and take an appropriate action soon."))
}
})
frappe.call({
method: "lms.job.doctype.job_opportunity.job_opportunity.report",
args: {
"job": $(e.currentTarget).data("job"),
"reason": $(".report-field").val()
},
callback: (data) => {
$(".report-modal").modal("hide");
frappe.show_alert({
message: __("Thanks for informing us about this post. The admin will look into it and take an appropriate action soon."),
indicator:'green'
}, 5);
}
});
}