NDOJ/templates/course/grades.html

162 lines
5.3 KiB
HTML
Raw Normal View History

2024-02-19 23:00:44 +00:00
{% extends "course/base.html" %}
{% block two_col_media %}
<style type="text/css">
table {
font-size: 15px;
}
td {
height: 2.5em;
}
.user-name {
padding-left: 1em !important;
}
#search-input {
float: right;
margin-bottom: 1em;
}
</style>
{% endblock %}
2024-06-24 19:56:00 +00:00
{% block js_media %}
2024-02-19 23:00:44 +00:00
<script>
$(document).ready(function(){
var $searchInput = $("#search-input");
var $usersTable = $("#users-table");
var tableBorderColor = $('#users-table td').css('border-bottom-color');
$searchInput.on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#users-table tbody tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
if(value) {
$('#users-table').css('border-bottom', '1px solid ' + tableBorderColor);
} else {
$('#users-table').css('border-bottom', '');
}
});
$('#sortSelect').select2({
minimumResultsForSearch: -1,
width: "10em",
});
$('#sortSelect').on('change', function() {
var rows = $('#users-table tbody tr').get();
var sortBy = $(this).val();
rows.sort(function(a, b) {
2024-10-03 01:27:49 +00:00
var keyA = $(a).find(sortBy === 'username' ? '.user-name' : '.total-score').text().trim();
var keyB = $(b).find(sortBy === 'username' ? '.user-name' : '.total-score').text().trim();
2024-02-19 23:00:44 +00:00
if(sortBy === 'total') {
// Convert percentage string to number for comparison
keyA = -parseFloat(keyA.replace('%', ''));
keyB = -parseFloat(keyB.replace('%', ''));
}
else {
keyA = keyA.toLowerCase();
keyB = keyB.toLowerCase();
}
if(keyA < keyB) return -1;
if(keyA > keyB) return 1;
return 0;
});
$.each(rows, function(index, row) {
$('#users-table tbody').append(row);
});
});
});
</script>
{% endblock %}
{% block middle_content %}
<center><h2>{{content_title}}</h2></center>
2024-10-03 06:50:21 +00:00
<div style="margin-top: 0.5em;">
{{_("Sort by")}}:
<div style="margin-top: 0.5em;">
<select id="sortSelect">
<option value="username">{{_("Username")}}</option>
<option value="total">{{_("Score")}}</option>
</select>
<input type="text" id="search-input" placeholder="{{_('Search')}}" autofocus>
</div>
2024-10-03 01:27:49 +00:00
</div>
2024-10-03 06:50:21 +00:00
<div style="overflow-x: auto; margin-top: 1em; clear: both;">
2024-10-02 20:06:33 +00:00
<table class="table striped" id="users-table">
<thead>
<tr>
<th>{{_('Student')}}</th>
<th>{{_('Total')}}</th>
2024-02-19 23:00:44 +00:00
{% for lesson in lessons %}
2024-10-02 20:06:33 +00:00
<th class="points" title="{{lesson.title}}">
<a href="{{url('course_grades_lesson', course.slug, lesson.id)}}">
2024-10-02 20:06:33 +00:00
L{{ loop.index0 + 1 }}
2024-02-19 23:00:44 +00:00
<div class="point-denominator">{{lesson.points}}</div>
</a>
</th>
{% endfor %}
2024-10-02 20:06:33 +00:00
{% for course_contest in course_contests %}
<th class="points" title="{{course_contest.contest.name}}">
<a href="{{url('contest_ranking', course_contest.contest.key)}}">
C{{ loop.index0 + 1 }}
<div class="point-denominator">{{course_contest.points}}</div>
2024-02-19 23:00:44 +00:00
</a>
2024-10-02 20:06:33 +00:00
</th>
2024-02-19 23:00:44 +00:00
{% endfor %}
</tr>
2024-10-02 20:06:33 +00:00
</thead>
<tbody>
{% for student in grade_total.keys() %}
{% set grade_lessons_student = grade_lessons.get(student) %}
{% set grade_contests_student = grade_contests.get(student) %}
{% set grade_total_student = grade_total.get(student) %}
<tr>
<td class="user-name">
<div>
{{link_user(student)}}
</div>
<div>
{{student.first_name}}
</div>
</td>
2024-10-03 01:27:49 +00:00
<td class="total-score" style="font-weight: bold">
2024-10-02 20:06:33 +00:00
{% if grade_total_student %}
{{ grade_total_student['percentage'] | floatformat(0) }}%
{% else %}
0
{% endif %}
</td>
{% for lesson in lessons %}
{% set val = grade_lessons_student.get(lesson.id) %}
<td class="partial-score">
<a href="{{url('course_lesson_detail', course.slug, lesson.id)}}?user={{student.username}}">
{% if val and val['total_points'] %}
{{ (val['achieved_points'] / val['total_points'] * lesson.points) | floatformat(0) }}
{% else %}
0
{% endif %}
</a>
</td>
{% endfor %}
{% for course_contest in course_contests %}
{% set val = grade_contests_student.get(course_contest.id) %}
<td class="partial-score">
<a href="{{url('contest_ranking', course_contest.contest.key)}}#!{{student.username}}">
{% if val and val['total_points'] %}
{{ (val['achieved_points'] / val['total_points'] * course_contest.points) | floatformat(0) }}
{% else %}
0
{% endif %}
</a>
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
2024-02-19 23:00:44 +00:00
{% endblock %}