Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bloomstack academy redesign #1494

Merged
Merged
26 changes: 14 additions & 12 deletions erpnext/education/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,14 @@ def has_super_access():

@frappe.whitelist()
def add_activity(course, content_type, content, program):
if has_super_access():
return None

student = get_current_student()
if not student:
return frappe.throw(_("Student with email {0} does not exist".format(frappe.session.user)), frappe.DoesNotExistError)

enrollment = get_or_create_course_enrollment(course, program)
if content_type == 'Quiz':
return
else:
return enrollment.add_activity(content_type, content)
if student:
enrollment = get_or_create_course_enrollment(course, program)
if content_type == 'Quiz':
return
else:
return enrollment.add_activity(content_type, content)

@frappe.whitelist()
def evaluate_quiz(quiz_response, quiz_name, course, program):
Expand Down Expand Up @@ -390,10 +386,16 @@ def get_previous_content(content_list, current_index):
else:
return content_list[current_index - 1]

def get_total_program_progress(topics,course_name):
def get_total_program_progress(topics, course_name, student):
total_article = 0
for topic in topics:
total_article = total_article + len(topic.topic_content)
completed_article = frappe.db.count("Course Activity",{"course": course_name },"content")
completed_article = frappe.db.count("Course Activity", {"course": course_name, "student": student.name}, "content")
total_progress = int((completed_article * 100) / total_article)
return total_progress

@frappe.whitelist(allow_guest=True)
def get_completed_topic_list(course_name):
student = get_current_student()
completed_topic = frappe.get_all("Course Activity", filters={"course": course_name, "student": student.name}, fields=["content", "content_type", "enrollment", "student"])
return completed_topic
134 changes: 134 additions & 0 deletions erpnext/public/css/lms/sidebar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.lms-content {
line-height: 1.8em;
}

.lms-content h1 {
margin-top: 1em;
}

.lms-content h2 {
margin-top: 1em;
}

.lms-content h3 {
margin-top: 0.8em;
}

.lms-content h4 {
margin-top: 0.6em;
}

section.section {
padding: 5rem 0 5rem 0;
}

.plyr--video .plyr__control.plyr__tab-focus,
.plyr--video .plyr__control:hover,
.plyr--video .plyr__control[aria-expanded='true'] {
background: #5e64ff !important;
}

.plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]::before {
background: #5e64ff !important;
}

.plyr__menu__container .plyr__control[role='menuitemradio'][aria-checked='true']::before {
background: #5e64ff;
}

.plyr__control--overlaid:focus,
.plyr__control--overlaid:hover {
background: #5e64ff !important;
}

.plyr--full-ui input[type='range'] {
color: #5e64ff !important;
}

.plyr__control--overlaid {
background: rgba(94, 100, 255, 0.8) !important;
}

.timer_text {
display: block;
font-size: 14px;
text-transform: uppercase;
}

#timer {
font-size: 46px;
color: #8d99a6;
line-height: 1;
text-align: right;
}

* {
scrollbar-width: thin;
scrollbar-color: #ccc #000;
}

*::-webkit-scrollbar {
width: 5px;
}

*::-webkit-scrollbar-track {
background: #ccc;
}

*::-webkit-scrollbar-thumb {
background-color: #000;
border-radius: 20px;
}

section {
padding: 4rem 0 2rem 0;
}

.topic-name {
font-size: 18px;
color: black;
font-weight: bold;
}

.content-name,
.content-name:hover {
color: black;
text-decoration: none;
}

.side-nav,
.side-container {
height: 70vh;
overflow-y: scroll;
padding-top: 1rem;
}

.side-nav li.active-parent {
background-color: lightblue;
}

.side-nav li:not(.completed-parent) a:not(.completed-article) {
pointer-events: none;
color: #8d99a6;
}

.side-nav li:not(.completed-parent) {
cursor: not-allowed;
}

.side-nav li.topic-content {
background-color: lightblue;
cursor: pointer;
}

.side-nav li.topic-content a {
color: black !important;
pointer-events: all !important;
}

.btn-next:not(:disabled):not(.disabled):active,
.btn-next:not(:disabled):not(.disabled).active,
.show>.btn-next.dropdown-toggle {
background-color: #80bd9e;
border-color: #80bd9e;
}
29 changes: 29 additions & 0 deletions erpnext/public/js/education/lms/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
frappe.ready(() => {
var ongoing_topic = decodeURIComponent(getURLParameter(location.href, "content"));
$('.content-name').filter(function () {
return $(this).attr("id") == ongoing_topic;
}).css({
'color': 'black'
}).parent('li').addClass('active-parent');

function getURLParameter(url, name) {
return (RegExp(name + '=' + '(.+?)(&|$)').exec(url) || [, null])[1];
}

var completed_topic = decodeURIComponent(getURLParameter(location.href, "course"));
frappe.call({
method: "erpnext.education.utils.get_completed_topic_list",
args: {
course_name: completed_topic
},
callback: (r) => {
r.message.forEach(e => {
$('.content-name').filter(function () {
return $(this).attr("id") == e.content;
}).css({
'color': 'blue'
}).addClass('completed-article').parent('li').addClass('completed-parent');
});
}
});
});
Loading