Skip to content

Commit

Permalink
Fixed broken final_score and late penalty
Browse files Browse the repository at this point in the history
  • Loading branch information
KesterTan committed Jan 28, 2025
1 parent b514a64 commit 61a546c
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 32 deletions.
7 changes: 5 additions & 2 deletions app/assets/javascripts/manage_submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ $(document).ready(function() {
var selectedSubmissions = [];

var table = $('#submissions').DataTable({
'dom': 'f<"selected-buttons">rt', // show buttons, search, table
'paging': false,
'dom': 'f<"selected-buttons"p>Brt', // show buttons, search, table
'paging': true,
'createdRow': completeRow,
'sPaginationType': 'full_numbers',
'iDisplayLength': 10,
"lengthMenu": [10, 25, 50, 75, 100],
});

// Check if the table is empty
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $autolab-green: #3a862d;
$autolab-light-green: #ebffd2;
$autolab-white: #fff;
$autolab-medium-gray: #6f6f6f;
$autolab-submissions-background: #EBEBEA;
$autolab-submissions-background: #F2F2F2;
$autolab-excused-popover-background: #00000040;
$autolab-black: #000000;
$autolab-light-grey: #ebebeb;
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/datatable.adapter.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ div.dataTables_filter {
float: left;
}

div.dataTables_paginate,
div.dataTables_filter {
padding: 6px 0px;
margin-right: 20px;
Expand Down Expand Up @@ -64,3 +65,9 @@ th {
.dt-button i {
margin: 0 6px 0 4px;
}

div.dataTables_paginate {
float: right;
padding: 6px 0;
margin-right: 20px;
}
28 changes: 0 additions & 28 deletions app/assets/stylesheets/manage_submissions.css

This file was deleted.

76 changes: 76 additions & 0 deletions app/assets/stylesheets/manage_submissions.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@import 'variables';

#modal-close {
font-size: 2rem;
position: absolute;
top: -35%;
right: 0;
padding: 0;
}

.modal-header {
float: right;
margin-bottom: 0;
padding-bottom: 0;
}

.score-details {
cursor: pointer;
}

#score-details-modal{
width: 90%;
height: auto;
}

/* Table Header */

#score-details-header {
position: relative;
margin-top: 0;
}

.score-styling {
font-weight: normal;
font-style: italic;
text-transform: none;
}

.sorting-th {
display: flex;
align-items: center;
}

/* Table Styling */

.submissions-problem-bg {
background-color: $autolab-submissions-background !important;
}

table.prettyBorder tr:hover {
background-color: white;
}

.submissions-td {
padding-left: 0.6rem !important;
}

.tweak-button:hover {
cursor: pointer;
}

.tweak-button {
display: flex;
align-content: center;
}


/* Icons */

.material-icons {
margin-left: 3px;
}

.i-no-margin {
margin-left: 0;
}
6 changes: 6 additions & 0 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "tempfile"

class SubmissionsController < ApplicationController
include ApplicationHelper
# inherited from ApplicationController
before_action :set_assessment
before_action :set_assessment_breadcrumb
Expand Down Expand Up @@ -39,6 +40,7 @@ def index
action_auth_level :score_details, :instructor
def score_details
cuid = params[:cuid]
cud = CourseUserDatum.find(cuid)
submissions = @assessment.submissions.where(course_user_datum_id: cuid).order("created_at DESC")
scores = submissions.map(&:scores).flatten

Expand All @@ -60,6 +62,10 @@ def score_details
submission_info[index]["scores"] = Score.where(submission_id: submission.id)
submission_info[index]["tweak_total"] =
submission.global_annotations.empty? ? nil : submission.global_annotations.sum(:value)
total = computed_score { submission.final_score(cud) }
submission_info[index]["total"] =
submission.global_annotations.empty? ? total : total + submission_info[index]["tweak_total"]
submission_info[index]["late_penalty"] = computed_score { submission.late_penalty(cud) }
end

submissions.as_json(seen_by: @cud)
Expand Down
2 changes: 1 addition & 1 deletion app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def reload_config_file
# force load config file (see http://www.ruby-doc.org/core-2.0.0/Kernel.html#method-i-load)
load unique_config_file_path

# updated last lozaaded time
# updated last loaded time
@@CONFIG_FILE_LAST_LOADED[unique_config_file_path] = Time.current

logger.info "Reloaded #{unique_config_file_path}"
Expand Down

0 comments on commit 61a546c

Please sign in to comment.