Skip to content

Commit

Permalink
Merge pull request #5386 from dodona-edu/feat/nudge-users
Browse files Browse the repository at this point in the history
Add tips that nudge users to better use of Dodona
  • Loading branch information
jorg-vr authored Feb 28, 2024
2 parents b1d45ed + 1ffe3ad commit 683c5a6
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/assets/javascripts/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function initSeriesEdit(): void {
new Toast(i18n.t("js.activity-added-success"));
row.querySelector("a.remove-activity").addEventListener("click", removeActivity);
row.classList.remove("pending");
updateActivityCountCallout();
}

function addingActivityFailed(row: HTMLTableRowElement, addButton: HTMLButtonElement): void {
Expand All @@ -128,6 +129,7 @@ function initSeriesEdit(): void {
row.classList.remove("pending");
setTimeout( () => {
row.remove();
updateActivityCountCallout();
}, 500);
new Toast(i18n.t("js.activity-removed-success"));
const addButton = document.querySelector(`a.add-activity[data-activity_id="${(row.querySelector("a.remove-activity") as HTMLElement).dataset.activity_id}"`);
Expand All @@ -142,6 +144,12 @@ function initSeriesEdit(): void {
new Toast(i18n.t("js.activity-removed-failed"));
}

function updateActivityCountCallout(): void {
const count = document.querySelector(".series-activity-list tbody").children.length;
document.getElementById("to-few-activities-info").classList.toggle("d-none", count >= 3);
document.getElementById("to-many-activities-info").classList.toggle("d-none", count <= 10);
}

init();
}

Expand Down
1 change: 1 addition & 0 deletions app/models/judge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# renderer :string(255) not null
# remote :string(255)
# clone_status :integer default("queued"), not null
# deprecated :boolean default(FALSE), not null
#

class Judge < ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/policies/judge_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def hook?

def permitted_attributes
if user&.zeus?
%i[name image renderer remote]
%i[name image renderer remote deprecated]
else
[]
end
Expand Down
12 changes: 12 additions & 0 deletions app/views/activities/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ end %>

<%= render partial: 'draft_notice' %>

<% if @activity.draft? && @activity.exercise? && @activity.judge.deprecated? %>
<div class="callout callout-info">
<h4>
<i class="mdi mdi-lightbulb-outline"></i>
<%= t '.tips.title' %>
</h4>
<p>
<%= t '.tips.deprecated_judge_html', judge: @activity.judge.name %>
</p>
</div>
<% end %>

<div class="row">
<% if @activity.exercise? %>
<div class="col-md-1 p-0">
Expand Down
8 changes: 8 additions & 0 deletions app/views/judges/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@
<div class="col-sm-6"><%= f.select :renderer, FeedbackTableRenderer.renderers.map {|r| r.to_s}, {}, {class: "form-select"} %></div>
<span class="help-block offset-sm-3 col-sm-6"><%= t ".renderer_help" %></span>
</div>
<div class="field form-group row">
<%= f.label :deprecated, :class => "col-sm-3 col-form-label" %>
<div class="col-sm-6 mt-2">
<div class="form-check">
<%= f.check_box :deprecated, class: "form-check-input " %>
</div>
</div>
</div>
<% end %>
20 changes: 20 additions & 0 deletions app/views/series/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@
</div>
</div>
<p class="h3-info-text"><%= t ".manage_activities_info" %></p>
<div class="callout callout-info <%= @series.activities.count < 3 ? "" : "d-none" %>" id="to-few-activities-info">
<h4>
<i class="mdi mdi-lightbulb-outline"></i>
<%= t '.tips.title' %>
</h4>
<p>
<%= t '.tips.ideal_activity_count' %>
<%= t('.tips.increase_activities')%>
</p>
</div>
<div class="callout callout-info <%= @series.activities.count > 10 ? "" : "d-none" %>" id="to-many-activities-info">
<h4>
<i class="mdi mdi-lightbulb-outline"></i>
<%= t '.tips.title' %>
</h4>
<p>
<%= t '.tips.ideal_activity_count' %>
<%= t('.tips.decrease_activities')%>
</p>
</div>
<h4><%= t ".activities_in_series" %></h4>
<p class="h4-info-text"><%= t ".activities_in_series_info" %></p>
<div class="series-activity-list">
Expand Down
12 changes: 12 additions & 0 deletions app/views/submissions/_description.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
</div>
</div>

<% if submission.exercise.draft? && submission.internal_error? %>
<div class="callout callout-info">
<h4>
<i class="mdi mdi-lightbulb-outline"></i>
<%= t 'submissions.show.tips.title' %>
</h4>
<p>
<%= t 'submissions.show.tips.internal_error_html' %>
</p>
</div>
<% end %>

<% unless submission.queued? or submission.running? %>
<%= submission.judge.renderer.new(submission, current_user).parse %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/models/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ en:
image: Docker image
path: Path
renderer: Rendering class
deprecated: Deprecated
repository:
name: Name
remote: Clone URL
Expand Down
1 change: 1 addition & 0 deletions config/locales/models/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ nl:
image: Docker image
path: Padnaam
renderer: Renderklasse
deprecated: Deprecated
repository:
name: Naam
remote: Clone URL
Expand Down
3 changes: 3 additions & 0 deletions config/locales/views/activities/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ en:
valid_config: "The exercise must have a valid configuration file."
is_valid: "The exercise must have a name and a description."
correct_submission: "You must submit at least one correct solution."
tips:
title: Tip
deprecated_judge_html: "You are using the legacy %{judge} judge. For new exercises, we recommend switching to the TESTed judge for a better experience. See <a href='https://docs.dodona.be/nl/guides/exercises/testsuites/' target='_blank'>our documentation</a> for how to make the switch."
series_activities_add_table:
course_added_to_usable: "Adding this exercise will allow this course to use all of the private exercises in this exercise's repository. Are you sure?"
edit:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/views/activities/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ nl:
valid_config: "De oefening moet een geldig configuratiebestand hebben."
is_valid: "De oefening moet een naam en een beschrijving hebben."
correct_submission: "Je moet minstens één correcte oplossing indienen."
tips:
title: Tip
deprecated_judge_html: "Je gebruikt de verouderde %{judge} judge. Voor nieuwe oefeningen raden we aan om over te schakelen naar de TESTed judge voor een betere ervaring. Zie <a href='https://docs.dodona.be/nl/guides/exercises/testsuites/' target='_blank'>onze documentatie</a> voor hoe je de overstap maakt."
series_activities_add_table:
course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?"
edit:
Expand Down
5 changes: 5 additions & 0 deletions config/locales/views/series/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ en:
confidential: Confidential information
access-link: Secret link
access-help: If the visibility of the series is set to hidden, students will get access to it when using this secret link.
tips:
title: Tip
ideal_activity_count: "Dodona works best if series contain between 3 and 10 exercises."
increase_activities: "Consider adding more exercises below."
decrease_activities: "Adding more can affect loading times."
delete:
title: Delete series
confirm: Please confirm you want to delete this series.
Expand Down
5 changes: 5 additions & 0 deletions config/locales/views/series/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ nl:
confidential: Geheime links en tokens
access-link: Geheime link
access-help: Als de zichtbaarheid van de reeks op verborgen staat ingesteld, dan krijgen studenten met deze geheime link toegang.
tips:
title: Tip
ideal_activity_count: "Dodona werkt het best als reeksen 3 tot 10 oefeningen bevatten."
increase_activities: "Overweeg om meer oefeningen toe te voegen."
decrease_activities: "Het toevoegen van meer oefeningen kan de laadtijden beïnvloeden."
delete:
title: Reeks verwijderen
confirm: Ben je zeker dat je deze reeks wilt verwijderen?
Expand Down
3 changes: 3 additions & 0 deletions config/locales/views/submissions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ en:
cut_off_message:
one: Your output has been cut off as it is much longer than expected. You produced %{generated} characters while only one character was expected.
other: Your output has been cut off as it is much longer than expected. You produced %{generated} characters while only %{count} characters were expected.
tips:
title: Tip
internal_error_html: "Facing an internal error? This usually indicates a problem with your exercise or test configuration. Check <a href='https://docs.dodona.be/en/guides/exercises/' target='_blank'>our documentation</a> for guidance or <a href='/en/contact' target='_blank'>reach out to us</a> for assistance."
3 changes: 3 additions & 0 deletions config/locales/views/submissions/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ nl:
cut_off_message:
one: De uitvoer van je programma is ingekort aangezien je veel meer uitvoer had dan het verwachte resultaat. Je genereerde %{generated} karakters terwijl er slechts één karakter verwacht werd.
other: De uitvoer van je programma is ingekort aangezien je veel meer uitvoer had dan het verwachte resultaat. Je genereerde %{generated} karakters terwijl er slechts %{count} karakters verwacht werden.
tips:
title: Tip
internal_error_html: "Ervaar je een interne fout? Dit duidt meestal op een probleem met je oefening of testconfiguratie. Bekijk <a href='https://docs.dodona.be/nl/guides/exercises/' target='_blank'>onze documentatie</a> voor hulp of <a href='/nl/contact' target='_blank'>neem contact met ons op</a> voor assistentie."
5 changes: 5 additions & 0 deletions db/migrate/20240226090515_add_deprecated_to_judges.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDeprecatedToJudges < ActiveRecord::Migration[7.1]
def change
add_column :judges, :deprecated, :boolean, default: false, null: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_11_07_160330) do
ActiveRecord::Schema[7.1].define(version: 2024_02_26_090515) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
Expand Down Expand Up @@ -333,6 +333,7 @@
t.string "renderer", null: false
t.string "remote"
t.integer "clone_status", default: 1, null: false
t.boolean "deprecated", default: false, null: false
t.index ["name"], name: "index_judges_on_name", unique: true
end

Expand Down
1 change: 1 addition & 0 deletions test/factories/judges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# renderer :string(255) not null
# remote :string(255)
# clone_status :integer default("queued"), not null
# deprecated :boolean default(FALSE), not null
#

require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb"
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/judges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# renderer :string(255) not null
# remote :string(255)
# clone_status :integer default("queued"), not null
# deprecated :boolean default(FALSE), not null
#

python_judge:
Expand Down
1 change: 1 addition & 0 deletions test/models/judge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# renderer :string(255) not null
# remote :string(255)
# clone_status :integer default("queued"), not null
# deprecated :boolean default(FALSE), not null
#

require 'test_helper'
Expand Down

0 comments on commit 683c5a6

Please sign in to comment.