chore: resolved conflicts

This commit is contained in:
Jannat Patel
2023-08-17 21:25:52 +05:30
29 changed files with 623 additions and 330 deletions

View File

@@ -15,7 +15,7 @@
{{ Description(course) }}
{{ widgets.CourseOutline(course=course, membership=membership, is_user_interested=is_user_interested) }}
{% if course.status == "Approved" and not frappe.utils.cint(course.upcoming) %}
{% include "lms/templates/reviews.html" %}
{% include "lms/templates/reviews.html" %}
{% endif %}
</div>
</div>
@@ -122,6 +122,10 @@
{{ Notes(course) }}
<div class="vertically-center mb-3 bold-heading">
{{ frappe.utils.fmt_money(course.course_price, 0, course.currency) }}
</div>
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use class="" href="#icon-users">
@@ -136,18 +140,8 @@
{{ get_lessons(course.name, None, False) }} {{ _("Lessons") }}
</div>
{% if course.enable_certification %}
<div class="vertically-center mb-3">
<svg class="icon icon-md mr-1">
<use href="#icon-badge"></use>
</svg>
{{ _("Get Certified") }}
</div>
{% endif %}
</div>
</div>
{{ SlotModal(course) }}
{% endmacro %}
@@ -204,18 +198,18 @@
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
<div class="all-cta">
{% if is_instructor(course.name) and not course.published and course.status != "Under Review" %}
{% if is_instructor and not course.published and course.status != "Under Review" %}
<div class="btn btn-primary wide-button" id="submit-for-review" data-course="{{ course.name | urlencode }}">
{{ _("Submit for Review") }}
</div>
{% elif is_instructor(course.name) and lesson_index %}
{% elif is_instructor and lesson_index %}
<a class="btn btn-primary wide-button" id="continue-learning"
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
{{ _("Checkout Course") }}
</a>
{% elif course.upcoming and not is_user_interested and not is_instructor(course.name) %}
{% elif course.upcoming and not is_user_interested and not is_instructor %}
<div class="btn btn-secondary wide-button notify-me" data-course="{{course.name | urlencode}}">
{{ _("Notify me when available") }}
</div>
@@ -231,8 +225,13 @@
{{ _("Continue Learning") }}
</a>
{% elif course.paid_course and not is_instructor %}
<a class="btn btn-primary wide-button" href="/billing/{{ course.name | urlencode }}">
{{ _("Buy This Course") }}
</a>
{% elif show_start_learing_cta(course, membership) %}
<div class="btn btn-primary wide-button join-batch" data-course="{{ course.name | urlencode }}">
<div class="btn btn-primary wide-button enroll-in-course" data-course="{{ course.name | urlencode }}">
{{ _("Start Learning") }}
</div>
{% endif %}
@@ -245,11 +244,6 @@
{{ _("Get Certificate") }}
</a>
{% elif eligible_for_evaluation %}
<a class="btn btn-secondary wide-button mt-2" id="apply-certificate" data-course="{{ course.name }}">
{{ _("Apply for Certificate") }}
</a>
{% elif course.grant_certificate_after == "Completion" and progress == 100 %}
<div class="btn btn-secondary wide-button mt-2" id="certification" data-course="{{ course.name }}">
{{ _("Get Certificate") }}
@@ -257,7 +251,7 @@
{% endif %}
{% endif %}
{% if is_instructor(course.name) or has_course_moderator_role() %}
{% if is_instructor or has_course_moderator_role() %}
<a class="btn btn-secondary wide-button mt-2" title="Edit Course" href="/courses/{{ course.name }}/edit">
<!-- <svg class="icon icon-md">
<use href="#icon-edit"></use>
@@ -267,9 +261,6 @@
{% endif %}
</div>
{% endmacro %}
@@ -279,17 +270,7 @@
{{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
</div>
{% if certificate_request and not certificate %}
<p class="mb-2">
<b>
{{ _("Evaluation On: ") }}
</b>
{{ _("{0} at {1}").format(frappe.utils.format_date(certificate_request.date, "medium"),
frappe.utils.format_time(certificate_request.start_time, "short")) }}
</p>
{% endif %}
{% if course.status == "Under Review" and is_instructor(course.name) %}
{% if course.status == "Under Review" and is_instructor %}
<div class="mb-4">
{{ _("This course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
</div>
@@ -300,55 +281,4 @@
{{ _("You have exceeded the maximum number of attempts allowed to appear for evaluations of this course.") }}
</p>
{% endif %}
{% endmacro %}
<!-- Modal for Slots -->
{% macro SlotModal(course) %}
<div class="modal fade" id="slot-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title">{{ _("Pick a Slot") }}</div>
</div>
<div class="modal-body">
<form id="slot-form">
<p class="">{{ _("This course requires you to complete an evaluation to get certified. Please pick a slot based on your convenience for the evaluations. ") }}</p>
<div class="form-group">
<div class="clearfix">
<label class="control-label reqd" style="padding-right: 0px;">{{ _("Date") }}</label>
</div>
<div class="control-input-wrapper">
<div class="control-input">
<input type="date" class="input-with-feedback form-control bold" data-fieldtype="Date" data-course="{{ course.name | urlencode }}"
id="slot-date" min="{{ frappe.utils.format_date(frappe.utils.add_days(frappe.utils.getdate(), 1), 'yyyy-mm-dd') }}">
</div>
</div>
</div>
<div class="form-group">
<div class="clearfix">
<label class="control-label reqd slot-label hide" style="padding-right: 0px;">{{ _("Slots") }}</label>
</div>
<div class="control-input-wrapper">
<div class="control-input">
<div class="slots"></div>
</div>
</div>
</div>
<p id="no-slots-message" class="small text-danger hide"> {{ _("There are no slots available on this day.") }} </p>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-secondary btn-sm pull-right mr-2 close-slot-modal" data-dismiss="modal" aria-label="Close">
{{ _("Discard") }}
</button>
<button class="btn btn-primary btn-sm pull-right" data-course="{{ course.name | urlencode}}" id="submit-slot">
{{ _("Submit") }}
</button>
</div>
</div>
</div>
</div>
{% endmacro %}
{% endmacro %}

View File

@@ -20,26 +20,6 @@ frappe.ready(() => {
$("#submit-for-review").click((e) => {
submit_for_review(e);
});
$("#apply-certificate").click((e) => {
apply_cetificate(e);
});
$("#slot-date").on("change", (e) => {
display_slots(e);
});
$("#submit-slot").click((e) => {
submit_slot(e);
});
$(".close-slot-modal").click((e) => {
close_slot_modal(e);
});
$(document).on("click", ".slot", (e) => {
select_slot(e);
});
});
const hide_wrapped_mentor_cards = () => {
@@ -162,99 +142,3 @@ const submit_for_review = (e) => {
},
});
};
const apply_cetificate = (e) => {
$("#slot-modal").modal("show");
};
const submit_slot = (e) => {
e.preventDefault();
const slot = window.selected_slot;
frappe.call({
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_certificate_request",
args: {
course: slot.data("course"),
date: $("#slot-date").val(),
day: slot.data("day"),
start_time: slot.data("start"),
end_time: slot.data("end"),
},
callback: (data) => {
$("#slot-modal").modal("hide");
frappe.show_alert(
{
message: __(
"Your slot has been booked. Prepare well for the evaluations."
),
indicator: "green",
},
3
);
setTimeout(() => {
window.location.reload();
}, 3000);
},
});
};
const display_slots = (e) => {
frappe.call({
method: "lms.lms.doctype.course_evaluator.course_evaluator.get_schedule",
args: {
course: $(e.currentTarget).data("course"),
date: $(e.currentTarget).val(),
},
callback: (data) => {
let options = "";
data.message.forEach((obj) => {
options += `<button type="button" class="btn btn-sm btn-secondary mb-3 mr-3 slot hide"
data-course="${$(e.currentTarget).data("course")}"
data-day="${obj.day}" data-start="${
obj.start_time
}" data-end="${obj.end_time}">
${format_time(obj.start_time)} - ${format_time(
obj.end_time
)}</button>`;
});
e.preventDefault();
$("#slot-modal .slots").html(options);
const weekday = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
const day = weekday[new Date($(e.currentTarget).val()).getDay()];
$(".slot").addClass("hide");
$(".slot-label").addClass("hide");
if ($(`[data-day='${day}']`).length) {
$(".slot-label").removeClass("hide");
$(`[data-day='${day}']`).removeClass("hide");
$("#no-slots-message").addClass("hide");
} else {
$("#no-slots-message").removeClass("hide");
}
},
});
};
const select_slot = (e) => {
$(".slot").removeClass("btn-outline-primary");
$(e.currentTarget).addClass("btn-outline-primary");
window.selected_slot = $(e.currentTarget);
};
const format_time = (time) => {
let date = moment(new Date()).format("ddd MMM DD YYYY");
return moment(`${date} ${time}`).format("HH:mm a");
};
const close_slot_modal = (e) => {
$("#slot-date").val("");
$(".slot-label").addClass("hide");
};

View File

@@ -52,13 +52,10 @@ def set_course_context(context, course_name):
"disable_self_learning",
"status",
"video_link",
"enable_certification",
"grant_certificate_after",
"paid_certificate",
"price_certificate",
"paid_course",
"course_price",
"currency",
"max_attempts",
"duration",
"grant_certificate_after",
],
as_dict=True,
)
@@ -79,7 +76,7 @@ def set_course_context(context, course_name):
frappe.db.get_value(
"LMS Course",
csr.course,
["name", "upcoming", "title", "image", "enable_certification"],
["name", "upcoming", "title", "image"],
as_dict=True,
)
)
@@ -91,10 +88,10 @@ def set_course_context(context, course_name):
"?batch=" + membership.batch if membership and membership.batch else ""
)
context.membership = membership
context.is_instructor = is_instructor(course.name)
context.certificate = is_certified(course.name)
eval_details = get_evaluation_details(course.name)
context.eligible_for_evaluation = eval_details.eligible
context.certificate_request = eval_details.request
context.no_of_attempts = eval_details.no_of_attempts
if context.course.upcoming:
context.is_user_interested = get_user_interest(context.course.name)

View File

@@ -157,6 +157,43 @@
<img {% if course.image %} class="image-preview" src="{{ course.image }}" {% endif %}>
</div>
<div class="field-group">
<label for="paid_course" class="vertically-center mb-0">
<input type="checkbox" id="paid-course" {% if course.paid_course %} checked {% endif %}>
{{ _("Paid Course") }}
</label>
</div>
<div class="field-group price-field {% if not course.paid_course %} hide {% endif %}">
<div class="field-label {% if course.paid_course %} reqd {% endif %}">
{{ _("Course Price") }}
</div>
<div class="field-description">
{{ _("The price of this course.") }}
</div>
<div class="">
<input id="course-price" type="number" class="field-input" {% if course.course_price %} value="{{ course.course_price }}" {% endif %}>
</div>
</div>
<div class="field-group price-field {% if not course.paid_course %} hide {% endif %}">
<div class="field-label {% if course.paid_course %} reqd {% endif %}">
{{ _("Currency") }}
</div>
<div class="field-description">
{{ _("The currency in which users will pay for this course.") }}
</div>
<select class="field-input" id="currency">
<option></option>
{% for currency in currencies %}
<option value="{{ currency }}" {% if currency == course.currency %} selected {% endif %}>
{{ currency}}
</option>
{% endfor %}
</select>
</div>
<div class="field-group">
<div class="field-label">
{{ _("Instructor") }}

View File

@@ -41,6 +41,10 @@ frappe.ready(() => {
$(".btn-upload").click((e) => {
upload_file(e);
});
$("#paid-course").click((e) => {
setup_paid_course(e);
});
});
const create_tag = (e) => {
@@ -79,6 +83,9 @@ const save_course = (e) => {
: "",
published: $("#published").prop("checked") ? 1 : 0,
upcoming: $("#upcoming").prop("checked") ? 1 : 0,
paid_course: $("#paid-course").prop("checked") ? 1 : 0,
course_price: $("#course-price").val(),
currency: $("#currency").val(),
},
callback: (data) => {
frappe.show_alert({
@@ -167,3 +174,13 @@ const upload_file = (e) => {
},
});
};
const setup_paid_course = (e) => {
if ($(e.target).prop("checked")) {
$(".price-field").removeClass("hide");
$(".price-field").find(".field-label").addClass("reqd");
} else {
$(".price-field").addClass("hide");
$(".price-field").find(".field-label").removeClass("reqd");
}
};

View File

@@ -35,6 +35,7 @@ def get_context(context):
context.member = frappe.db.get_value(
"User", frappe.session.user, ["full_name", "username"], as_dict=True
)
context.currencies = frappe.get_all("Currency", {"enabled": 1}, pluck="currency_name")
def set_course_context(context, course_name):
@@ -51,8 +52,8 @@ def set_course_context(context, course_name):
"video_link",
"enable_certification",
"grant_certificate_after",
"paid_certificate",
"price_certificate",
"paid_course",
"course_price",
"currency",
"max_attempts",
]

View File

@@ -46,9 +46,8 @@ def get_courses():
"title",
"short_introduction",
"image",
"enable_certification",
"paid_certificate",
"price_certificate",
"paid_course",
"course_price",
"currency",
"creation",
],