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

Improve the UX for restoring boilerplate #4549

Merged
merged 4 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions app/assets/javascripts/exercise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function initExerciseShow(exerciseId: number, programmingLanguage: string, logge

editor.setValue(rawBoilerplate);
editor.focus();
editor.clearSelection();
restoreWarning.hidden = true;
});
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/activities/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ end %>
</div>
<% end %>
<% if !@edit_submission && !@solution && @last_submission %>
<div class="alert alert-info" id="restore-boilerplate">
<div class="callout callout-info mt-0" id="restore-boilerplate">
<%= t ".preloaded_info" %>
<a >
<a class="link-primary">
<%= t(@activity.boilerplate ? ".preloaded_restore" : ".preloaded_clear") %>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/activities/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ en:
read_at: "Marked as read on %{timestamp}"
preloaded_info: "We have preloaded your latest submission into the editor."
preloaded_clear: Clear editor.
preloaded_restore: Restore the boilerplate code.
preloaded_restore: Restore the initial code.
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
2 changes: 1 addition & 1 deletion config/locales/views/activities/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ nl:
read_at: "Gelezen op %{timestamp}"
preloaded_info: We hebben jouw laatste oplossing ingeladen in de editor.
preloaded_clear: Maak de editor leeg.
preloaded_restore: Herstel de boilerplate-code.
preloaded_restore: Zet de voorbeeldcode terug.
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
8 changes: 4 additions & 4 deletions test/system/activities_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class ActivitiesTest < ApplicationSystemTestCase
Exercise.any_instance.stubs(:boilerplate).returns('boilerplate')
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("hello")')
visit exercise_path(id: @instance.id)
assert_text 'Restore the boilerplate code.'
find('a', text: 'Restore the boilerplate code.').click
assert_text 'Restore the initial code.'
find('a', text: 'Restore the initial code.').click
assert_text 'boilerplate'
end

Expand All @@ -55,8 +55,8 @@ class ActivitiesTest < ApplicationSystemTestCase
create(:submission, exercise: @instance, user: @user, status: :correct, code: 'print("😀")')
visit exercise_path(id: @instance.id)
assert_text 'print("😀")'
assert_text 'Restore the boilerplate code.'
find('a', text: 'Restore the boilerplate code.').click
assert_text 'Restore the initial code.'
find('a', text: 'Restore the initial code.').click
assert_text '`<script>alert("😀")</script>`'
end
end