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

Add visual confirmation that a score has been saved when grading #3288

Merged
merged 8 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions app/assets/javascripts/feedback/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FeedbackActions from "feedback/actions";
export default class ScoreForm {
private readonly input: HTMLInputElement;
private readonly expectedScore: HTMLInputElement;
private readonly spinner: HTMLElement;
private readonly scoreState: HTMLElement;
private readonly deleteButton: HTMLElement;
private readonly zeroButton: HTMLElement;
private readonly maxButton: HTMLElement;
Expand All @@ -32,7 +32,7 @@ export default class ScoreForm {

this.form = element.querySelector(".score-form") as HTMLFormElement;
this.input = this.form.querySelector("input.score-input");
this.spinner = this.form.querySelector(".dodona-progress");
this.scoreState= this.form.querySelector(".score-state");
jorg-vr marked this conversation as resolved.
Show resolved Hide resolved
this.expectedScore = this.form.querySelector(".score-form input.expected-score");
this.deleteButton = this.form.parentElement.querySelector(".delete-button");
this.zeroButton = this.form.parentElement.querySelector(".single-zero-button");
Expand Down Expand Up @@ -61,8 +61,12 @@ export default class ScoreForm {
});
const delay = createDelayer();
this.input.addEventListener("change", ev => {
// If the score is not valid, don't do anything.
// If the score is not valid, show warning.
if (!this.input.reportValidity()) {
const icon = document.createElement("i");
icon.classList.add("mdi", "mdi-alert-circle-outline", "mdi-18", "colored-wrong");
icon.setAttribute("aria-hidden", "true");
this.scoreState.replaceChildren(icon);
return;
}
// Mark as busy to show we are aware an update should happen.
Expand Down Expand Up @@ -206,7 +210,11 @@ export default class ScoreForm {
private visualiseUpdating(): void {
this.input.classList.add("in-progress");
this.maxText.classList.add("in-progress");
this.spinner.style.visibility = "visible";

const span = document.createElement("span");
span.classList.add("spinner-border", "spinner-border-sm", "colored-warning");
span.setAttribute("aria-hidden", "true");
this.scoreState.replaceChildren(span);
}

public markBusy(): void {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/base.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@import "../../../node_modules/bootstrap/scss/tooltip";
@import "../../../node_modules/bootstrap/scss/popover";
//@import "../../../node_modules/bootstrap/scss/carousel";
//@import "../../../node_modules/bootstrap/scss/spinners";
@import "../../../node_modules/bootstrap/scss/spinners";
//@import "../../../node_modules/bootstrap/scss/offcanvas";
@import "../../../node_modules/bootstrap/scss/helpers";
@import "../../../node_modules/bootstrap/scss/utilities/api";
Expand Down
15 changes: 14 additions & 1 deletion app/assets/stylesheets/components/evaluations.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
color: $text-color;
text-align: center;
background-color: $input-group-addon-bg;
border: 1px solid $input-group-addon-border-color;
border: 1px solid $border-color;
opacity: 1;
cursor: auto;
}
Expand All @@ -85,6 +85,19 @@
border-bottom-right-radius: 0;
}

.score-input{
border-right: none;
border-color: $border-color;
margin-right: -28px;
padding-right: 28px;
}
.score-state{
border-left: none;
width: 28px;
background-color: $input-bg;
padding: 0;
}

.dodona-progress .bar {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
Expand Down
13 changes: 7 additions & 6 deletions app/views/feedbacks/_score_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
<i class="mdi mdi-delete-outline mdi-12" aria-hidden='true'></i>
<% end %>
<%= f.number_field :score,
class: "form-control score-input",
class: "form-control score-input ",
jorg-vr marked this conversation as resolved.
Show resolved Hide resolved
step: 0.25,
tabindex: index + 1,
min: 0,
max: score_item.maximum,
value: format_score(f.object.score, lang='en', numeric_only=true) %>

<%= button_tag class: "btn btn-secondary score-state", disabled: true, type: :button do %>
<% unless score.score.nil? %>
<i class="mdi mdi-check mdi-18 colored-info" aria-hidden='true'></i>
<% end %>
<% end %>
<%= button_tag class: "btn btn-secondary max-text", disabled: true, type: :button, data: { max: format_score(score_item.maximum, lang='en', numeric_only=true) } do %>
/ <%= format_score(score_item.maximum) %>
<% end %>
Expand All @@ -27,11 +33,6 @@
<i class="mdi mdi-thumb-up-outline mdi-12" aria-hidden='true'></i>
<% end %>
</div>
<div class="dodona-progress dodona-progress-indeterminate">
<div class="progressbar bar bar1" style="width: 0;"></div>
<div class="bufferbar bar bar2" style="width: 100%;"></div>
<div class="auxbar bar bar3" style="width: 0;"></div>
</div>
</div>
</div>
<%= f.hidden_field :score_item_id, class: "score-item" %>
Expand Down