Skip to content

Commit

Permalink
Merge pull request #515 from pateljannat/class-improvements
Browse files Browse the repository at this point in the history
fix: Class improvements
  • Loading branch information
pateljannat authored May 16, 2023
2 parents 9501207 + 552b0c9 commit 611cc4d
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 197 deletions.
7 changes: 7 additions & 0 deletions lms/lms/doctype/lms_class/lms_class.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"title",
"start_date",
"end_date",
"paid_class",
"column_break_4",
"seat_count",
"start_time",
Expand Down Expand Up @@ -75,6 +76,12 @@
"label": "Custom Component",
"options": "HTML"
},
{
"default": "0",
"fieldname": "paid_class",
"fieldtype": "Check",
"label": "Paid Class"
},
{
"fieldname": "seat_count",
"fieldtype": "Int",
Expand Down
18 changes: 2 additions & 16 deletions lms/lms/doctype/lms_class/lms_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,11 @@ def add_student(email, class_name):
@frappe.whitelist()
def remove_student(student, class_name):
frappe.db.delete("Class Student", {"student": student, "parent": class_name})
return True


@frappe.whitelist()
def update_course(class_name, course, value):
if cint(value):
doc = frappe.get_doc(
{
"doctype": "Class Course",
"parent": class_name,
"course": course,
"parenttype": "LMS Class",
"parentfield": "courses",
}
)
doc.save()
else:
frappe.db.delete("Class Course", {"parent": class_name, "course": course})
return True
def remove_course(course, parent):
frappe.db.delete("Class Course", {"course": course, "parent": parent})


@frappe.whitelist()
Expand Down
65 changes: 13 additions & 52 deletions lms/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ textarea.field-input {
border-bottom: none;
}

.level {
.outline-lesson .level {
justify-content: start;
}

Expand Down Expand Up @@ -526,24 +526,6 @@ input[type=checkbox] {
margin: 0.25rem 0;
}

.button {
border-radius: var(--border-radius);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
padding: 0.25rem 1.25rem;
font-size: var(--text-md);
line-height: 20px;
box-shadow: var(--btn-shadow);
border: none;
width: fit-content;
}

.button:disabled {
cursor: not-allowed;
}

.wide-button {
padding: 0.3rem 4rem;
width: 100%;
Expand All @@ -555,35 +537,6 @@ input[type=checkbox] {
}
}

.is-secondary {
background: #FFFFFF;
color: var(--gray-900);
}

.is-secondary:hover {
text-decoration: none;
color: var(--gray-900);
}

.is-default {
background: var(--gray-100);
color: var(--gray-900);
}

.is-default:disabled {
color: var(--gray-500);
}

.is-primary {
background: var(--primary-color);
color: #FFFFFF;
}

.is-primary:hover {
text-decoration: none;
color: #FFFFFF;
}

.course-home-page .course-home-outline {
padding-bottom: 4rem;
}
Expand Down Expand Up @@ -2144,10 +2097,10 @@ select {
.lms-card {
display: flex;
flex-direction: column;
border-radius: 0.75rem;
/* border: 1px solid var(--gray-200); */
box-shadow: var(--shadow-sm);
padding: 0.5rem;
border-radius: 0.75rem;
border: 1px solid var(--gray-300);
/* box-shadow: var(--shadow-sm); */
padding: 0.5rem;
height: 100%;
position: relative;
}
Expand Down Expand Up @@ -2194,3 +2147,11 @@ select {
background-color: var(--red-50);
}

.list-row {
border-bottom: 1px solid var(--gray-300);
padding: 0.75rem 0;
}

.list-row:last-child {
border-bottom: none;
}
158 changes: 95 additions & 63 deletions lms/www/classes/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
{% macro ClassDetails(class_info) %}
<div class="class-details" data-class="{{ class_info.name }}">

<div class="course-home-headings">
<div class="page-title">
{{ class_info.title }}
</div>
<div class="mt-2">
<div class="mt-1">
<svg class="icon icon-sm">
<use href="#icon-calendar"></use>
</svg>
Expand All @@ -46,7 +46,7 @@
</span>
</div>
{% if class_info.description %}
<div class="">
<div class="mt-1">
{{ class_info.description }}
</div>
{% endif %}
Expand All @@ -62,20 +62,28 @@
{% macro ClassSections(class_info, class_courses, class_students, published_courses) %}
<div class="mt-4">

<button class="btn btn-secondary btn-sm pull-right" id="create-class">
{% if is_moderator %}
<button class="btn btn-default btn-sm pull-right" id="create-class">
{{ _("Edit") }}
</button>
{% endif %}

<ul class="nav lms-nav" id="classes-tab">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#courses">
{{ _("Courses") }}
<span class="course-list-count">
{{ class_courses | length }}
</span>
</a>
</li>

<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#students">
{{ _("Students") }}
<span class="course-list-count">
{{ class_students | length }}
</span>
</a>
</li>

Expand Down Expand Up @@ -112,84 +120,107 @@


{% macro CoursesSection(class_info, class_courses, published_courses) %}
<div class="class-course-list">
{% if published_courses | length %}
{% for course in published_courses %}
{% set checked = course.name in class_courses %}
<label class="class-course" data-course="{{ course.name }}">
<input type="checkbox" {% if checked %} checked {% endif %}
{% if not is_moderator %} disabled {% endif %}>
{{ course.title }}
</label>
{% endfor %}
<article>
<header class="mb-5">
<div class="edit-header">
<div class="bold-heading">
{{ _("Courses") }}
</div>
{% if is_moderator %}
<button class="btn btn-default btn-sm btn-add-course">
{{ _("Add Courses") }}
</button>
{% endif %}
</div>
</header>

{% if class_courses | length %}
<div>
{% for course in class_courses %}
<div class="list-row level">
<div {% if is_moderator %} class="clickable" {% endif %}>
{{ course.title }}
</div>
{% if is_moderator %}
<div type="button" class="btn-remove-course" data-course="{{ course.course }}">
<svg class="icon icon-sm">
<use href="#icon-delete"></use>
</svg>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{% else %}
<div class="">
{{ _("No courses") }}
</div>
{% endif %}
</div>


</article>

{% endmacro %}


{% macro StudentsSection(class_info, class_students) %}
<div class="">
{% if is_moderator %}
{{ AddStudents() }}
{% endif %}

{% if class_students | length %}
<table class="table">
<tr>
<th style="width: 70%">
{{ _("Student") }}
</th>
<th style="width: 20%">
{{ _("Last Active") }}
</th>
<article>
<header>
<div class="edit-header mb-5">
<div class="bold-heading">
{{ _("Students") }}
</div>
{% if is_moderator %}
<th style="width: 10%"></th>
<button class="btn btn-default btn-sm btn-add-student">
{{ _("Add Students") }}
</button>
{% endif %}
</tr>
</div>
</header>

{% if class_students | length %}
<div>
{% for student in class_students %}
{% set last_active = frappe.db.get_value("User", student.student, "last_active") %}
{% set allow_progress = is_moderator or student.student == frappe.session.user or (frappe.db.get_single_value("LMS Settings", "allow_student_progress") and
is_student) %}
<tr>
<td>
<a class="subheading button-links d-block" {% if allow_progress %} href="/classes/{{ class_info.name }}/students/{{ student.username }}" {% endif %}>

<div class="list-row level">
<div>
<a {% if allow_progress %} class="clickable" href="/classes/{{ class_info.name }}/students/{{ student.username }}" {% endif %}>
{{ student.student_name }}
</a>
</td>
<td>
{{ frappe.utils.format_datetime(last_active, "medium") }}
</td>
</div>
{% if is_moderator %}
<td>
<svg class="icon icon-md pull-right remove-student" data-student="{{ student.student }}">
<div type="button" class="btn-remove-student" data-student="{{ student.student }}">
<svg class="icon icon-sm">
<use href="#icon-delete"></use>
</svg>
</td>
</div>
{% endif %}
</tr>
{% endfor %}
</div>

</table>
{% endfor %}
</div>
{% else %}
<p class="text-muted mt-3 ml-5"> {{ _("No Students are added to this class.") }} </p>
<p class="text-muted mt-3"> {{ _("No Students") }} </p>
{% endif %}

</div>
{% endmacro %}


{% macro AddStudents() %}
<div class="mb-10">
<div class="add-students"></div>
<button class="btn btn-primary btn-sm ml-5" id="submit-student">
{{ _("Add") }}
</button>
</div>
</article>
{% endmacro %}


{% macro LiveClassSection(class_info, live_classes) %}
<div>
<article>
<header class="edit-header">
<div class="bold-heading">
{{ _("Live Class") }}
</div>
{% if is_moderator %}
<button class="btn btn-default btn-sm" id="open-class-modal">
{{ _("Create a Live Class") }}
</button>
{% endif %}
</header>
{{ CreateLiveClass(class_info) }}
{{ LiveClassList(class_info, live_classes) }}
</div>
Expand All @@ -199,9 +230,6 @@
{% macro CreateLiveClass(class_info) %}

{% if is_moderator %}
<button class="btn btn-secondary btn-sm" id="open-class-modal">
{{ _("Create a Live Class") }}
</button>

<div class="modal fade live-class-modal" id="live-class-modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
Expand Down Expand Up @@ -234,7 +262,8 @@


{% macro LiveClassList(class_info, live_classes) %}
<div class="lms-card-parent mt-8">
<div class="lms-card-parent mt-5">
{% if live_classes | length %}
{% for class in live_classes %}
<div class="lms-card">

Expand Down Expand Up @@ -280,6 +309,9 @@

</div>
{% endfor %}
{% else %}
<p class=""> {{ _("No Live Classes") }} </p>
{% endif %}
</div>
{% endmacro %}

Expand All @@ -303,4 +335,4 @@
{% endif %}

{{ include_script('controls.bundle.js') }}
{% endblock %}
{% endblock %}
Loading

0 comments on commit 611cc4d

Please sign in to comment.