Automatically submit LTI grade on each score run
With this commit, we refactor the overall score handling of CodeOcean. Previously, "Score" and "Submit" were two distinct actions, requiring users to confirm the LTI transmission of their score (after assessing their submission). This yielded many questions and was unnecessary, since LTI parameters are no longer expiring after each use. Therefore, we can now transmit the current grade on each score run with the very same LTI parameters. As a consequence, the LTI consumer gets a more detailed history of the scores, enabling further analytical insights. For users, the previous "Submit" button got replaced with a notification that is shown as soon as the full score got reached. Then, learners can decide to "finalize" their work on the given exercise, which will initiate a redirect to a follow-up action (as defined in the RedirectBehavior). This RedirectBehavior has also been unified and simplified for better readability. As part of this refactoring, we rephrased the notifications and UX workflow of a) the LTI transmission, b) the finalization of an exercise (measured by reaching the full score) and c) the deadline handling (on time, within grace period, too late). Those information are now separately shown, potentially resulting in multiple notifications. As a side effect, they are much better maintainable, and the LTI transmission is more decoupled from this notification handling.
This commit is contained in:

committed by
Sebastian Serth

parent
1e06ab3fa9
commit
175c8933f3
@ -6,7 +6,8 @@ RSpec.describe SubmissionsController do
|
||||
render_views
|
||||
|
||||
let(:exercise) { create(:math) }
|
||||
let(:submission) { create(:submission, exercise:, contributor:) }
|
||||
let(:cause) { 'save' }
|
||||
let(:submission) { create(:submission, exercise:, contributor:, cause:) }
|
||||
|
||||
shared_examples 'a regular user' do |record_not_found_status_code|
|
||||
describe 'POST #create' do
|
||||
@ -39,6 +40,15 @@ RSpec.describe SubmissionsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #download' do
|
||||
let(:perform_request) { proc { get :download, params: {id: submission.id} } }
|
||||
|
||||
before { perform_request.call }
|
||||
|
||||
expect_assigns(submission: :submission)
|
||||
expect_http_status(:ok)
|
||||
end
|
||||
|
||||
describe 'GET #download_file' do
|
||||
context 'with an invalid filename' do
|
||||
before { get :download_file, params: {filename: SecureRandom.hex, id: submission.id, format: :json} }
|
||||
@ -98,6 +108,84 @@ RSpec.describe SubmissionsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #finalize' do
|
||||
let(:perform_request) { proc { get :finalize, params: {id: submission.id} } }
|
||||
let(:cause) { 'assess' }
|
||||
|
||||
context 'when the request is performed' do
|
||||
before { perform_request.call }
|
||||
|
||||
expect_assigns(submission: :submission)
|
||||
expect_redirect
|
||||
end
|
||||
|
||||
it 'updates cause to submit' do
|
||||
expect { perform_request.call && submission.reload }.to change(submission, :cause).from('assess').to('submit')
|
||||
end
|
||||
|
||||
context 'when contributing to a community solution is possible' do
|
||||
let!(:community_solution) { CommunitySolution.create(exercise:) }
|
||||
|
||||
before do
|
||||
allow(Java21Study).to receive(:allow_redirect_to_community_solution?).and_return(true)
|
||||
perform_request.call
|
||||
end
|
||||
|
||||
expect_redirect { edit_community_solution_path(community_solution, lock_id: CommunitySolutionLock.last) }
|
||||
end
|
||||
|
||||
context 'when sharing exercise feedback is desired' do
|
||||
before do
|
||||
uef&.save!
|
||||
allow_any_instance_of(Submission).to receive(:redirect_to_feedback?).and_return(true)
|
||||
perform_request.call
|
||||
end
|
||||
|
||||
context 'without any previous feedback' do
|
||||
let(:uef) { nil }
|
||||
|
||||
expect_redirect { new_user_exercise_feedback_path(user_exercise_feedback: {exercise_id: submission.exercise.id}) }
|
||||
end
|
||||
|
||||
context 'with a previous feedback for the same exercise' do
|
||||
let(:uef) { create(:user_exercise_feedback, exercise:, user: current_user) }
|
||||
|
||||
expect_redirect { edit_user_exercise_feedback_path(uef) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an RfC' do
|
||||
before do
|
||||
rfc.save!
|
||||
allow_any_instance_of(Submission).to receive(:redirect_to_feedback?).and_return(false)
|
||||
perform_request.call
|
||||
end
|
||||
|
||||
context 'when an own RfC is unsolved' do
|
||||
let(:rfc) { create(:rfc, user: current_user, exercise:, submission:) }
|
||||
|
||||
expect_flash_message(:notice, I18n.t('exercises.editor.exercise_finished_redirect_to_own_rfc'))
|
||||
expect_redirect { request_for_comment_url(rfc) }
|
||||
end
|
||||
|
||||
context 'when another RfC is unsolved' do
|
||||
let(:rfc) { create(:rfc, exercise:) }
|
||||
|
||||
expect_flash_message(:notice, I18n.t('exercises.editor.exercise_finished_redirect_to_rfc'))
|
||||
expect_redirect { request_for_comment_url(rfc) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when neither a community solution, feedback nor RfC is available' do
|
||||
before do
|
||||
allow_any_instance_of(Submission).to receive(:redirect_to_feedback?).and_return(false)
|
||||
perform_request.call
|
||||
end
|
||||
|
||||
expect_redirect { lti_return_path(submission_id: submission.id) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #render_file' do
|
||||
let(:file) { submission.files.first }
|
||||
let(:signed_url) { AuthenticatedUrlHelper.sign(render_submission_url(submission, filename), submission) }
|
||||
@ -259,8 +347,9 @@ RSpec.describe SubmissionsController do
|
||||
|
||||
context 'with an admin user' do
|
||||
let(:contributor) { create(:admin) }
|
||||
let(:current_user) { contributor }
|
||||
|
||||
before { allow(controller).to receive(:current_user).and_return(contributor) }
|
||||
before { allow(controller).to receive_messages(current_user:) }
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
@ -280,10 +369,9 @@ RSpec.describe SubmissionsController do
|
||||
let(:group_author) { create(:external_user) }
|
||||
let(:other_group_author) { create(:external_user) }
|
||||
let(:contributor) { create(:programming_group, exercise:, users: [group_author, other_group_author]) }
|
||||
let(:current_user) { group_author }
|
||||
|
||||
before do
|
||||
allow(controller).to receive_messages(current_contributor: contributor, current_user: group_author)
|
||||
end
|
||||
before { allow(controller).to receive_messages(current_contributor: contributor, current_user:) }
|
||||
|
||||
it_behaves_like 'a regular user', :unauthorized
|
||||
it_behaves_like 'denies access for regular, non-admin users'
|
||||
@ -291,10 +379,9 @@ RSpec.describe SubmissionsController do
|
||||
|
||||
context 'with a learner' do
|
||||
let(:contributor) { create(:external_user) }
|
||||
let(:current_user) { contributor }
|
||||
|
||||
before do
|
||||
allow(controller).to receive_messages(current_user: contributor)
|
||||
end
|
||||
before { allow(controller).to receive_messages(current_user:) }
|
||||
|
||||
it_behaves_like 'a regular user', :unauthorized
|
||||
it_behaves_like 'denies access for regular, non-admin users'
|
||||
|
Reference in New Issue
Block a user