Skip to content

Commit

Permalink
Remove no longer needed code & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kiragrammel committed Jun 21, 2023
1 parent 68bd69e commit 2144f69
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 147 deletions.
3 changes: 0 additions & 3 deletions app/assets/javascripts/editor/editor.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ var CodeOceanEditor = {
},

initializeWorkspaceButtons: function () {
$('#submit').one('click', this.submitCode.bind(this));
$('#assess').one('click', this.scoreCode.bind(this));
$('#render').on('click', this.renderCode.bind(this));
$('#run').on('click', this.runCode.bind(this));
Expand All @@ -480,7 +479,6 @@ var CodeOceanEditor = {
},

teardownWorkspaceButtons: function () {
$('#submit').unbind('click');
$('#assess').unbind('click');
$('#render').unbind('click');
$('#run').unbind('click');
Expand Down Expand Up @@ -859,7 +857,6 @@ var CodeOceanEditor = {
showScoringFullScoreMessage: function (url) {
$.flash.success({
showPermanent: true,
// TODO: Ask if fa-party-horn from payed version can be used
icon: ['fa-solid', 'fa-graduation-cap'],
text: I18n.t('exercises.submit.full_score', {url: url})
});
Expand Down
22 changes: 0 additions & 22 deletions app/assets/javascripts/editor/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,6 @@ CodeOceanEditorEvaluation = {
}, 0).toFixed(2);
$('#score').data('score', score);
this.renderScore();
this.showSubmitButton();
},

// TODO: Does this part needs to be changed/removed?
showSubmitButton: function () {
if (this.submission_deadline || this.late_submission_deadline) {
const now = new Date();
if (now <= this.submission_deadline) {
// before_deadline
// default is btn-success, so no change in color
$('#submit').get(0).lastChild.nodeValue = I18n.t('exercises.editor.submit_on_time');
} else if (now > this.submission_deadline && this.late_submission_deadline && now <= this.late_submission_deadline) {
// within_grace_period
$('#submit').removeClass("btn-success btn-warning").addClass("btn-warning");
$('#submit').get(0).lastChild.nodeValue = I18n.t('exercises.editor.submit_within_grace_period');
} else if (this.late_submission_deadline && now > this.late_submission_deadline || now > this.submission_deadline) {
// after_late_deadline
$('#submit').removeClass("btn-success btn-warning btn-danger").addClass("btn-danger");
$('#submit').get(0).lastChild.nodeValue = I18n.t('exercises.editor.submit_after_late_deadline');
}
}
$('#submit').removeClass("d-none");
},

printScoringResult: function (result, index) {
Expand Down
23 changes: 0 additions & 23 deletions app/assets/javascripts/editor/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,6 @@ CodeOceanEditorSubmissions = {
}
},

// TODO: Should this code be changed/removed?
submitCode: function(event) {
const button = $(event.target) || $('#submit');
this.startSentryTransaction(button);
this.teardownEventHandlers();
this.createSubmission(button, null, function (response) {
if (response.redirect) {
this.autosaveIfChanged();
this.stopCode(event);
this.editors = [];
Turbolinks.clearCache();
Turbolinks.visit(response.redirect);
} else if (response.status === 'container_depleted') {
this.showContainerDepletedMessage();
} else if (response.message) {
$.flash.danger({
text: response.message
});
}
this.initializeEventHandlers();
})
},

/**
* Autosave-Logic
*/
Expand Down
6 changes: 0 additions & 6 deletions app/assets/javascripts/exercise_graphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ $(document).on('turbolinks:load', function() {
maximumValue = submission.score;
}

// TODO: Does this part needs to be changed/removed?
if(submission.cause == "assess"){
submissionsScoreAndTimeAssess.push(submissionArray);
} else if(submission.cause == "submit"){
submissionsScoreAndTimeSubmits.push(submissionArray);
} else if(submission.cause == "run"){
submissionsScoreAndTimeRuns.push(submissionArray[1]);
} else if(submission.cause == "autosave"){
Expand Down Expand Up @@ -124,9 +121,6 @@ $(document).on('turbolinks:load', function() {
if(largestSubmittedTimeStamp.cause == "assess"){
largestArrayForRange = submissionsScoreAndTimeAssess;
x.domain([0,largestArrayForRange[largestArrayForRange.length - 1][1]]).clamp(true);
} else if(largestSubmittedTimeStamp.cause == "submit"){
largestArrayForRange = submissionsScoreAndTimeSubmits;
x.domain([0,largestArrayForRange[largestArrayForRange.length - 1][1]]).clamp(true);
} else if(largestSubmittedTimeStamp.cause == "run"){
largestArrayForRange = submissionsScoreAndTimeRuns;
x.domain([0,largestArrayForRange[largestArrayForRange.length - 1]]).clamp(true);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ExercisesController < ApplicationController
before_action :handle_file_uploads, only: %i[create update]
before_action :set_execution_environments, only: %i[index create edit new update]
before_action :set_exercise_and_authorize,
only: MEMBER_ACTIONS + %i[clone implement working_times intervention search run statistics submit reload feedback
only: MEMBER_ACTIONS + %i[clone implement working_times intervention search run statistics reload feedback
requests_for_comments study_group_dashboard export_external_check export_external_confirm
external_user_statistics]
before_action :collect_set_and_unset_exercise_tags, only: MEMBER_ACTIONS
Expand Down
2 changes: 0 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@
get :statistics
get :feedback
get :reload
# TODO: Should this route be removed?
post :submit
get 'study_group_dashboard/:study_group_id', to: 'exercises#study_group_dashboard'
post :export_external_check
post :export_external_confirm
Expand Down
90 changes: 0 additions & 90 deletions spec/controllers/exercises_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,96 +288,6 @@
end
end

describe 'POST #submit' do
let(:output) { {} }
let(:perform_request) { post :submit, format: :json, params: {id: exercise.id, submission: {cause: 'submit', exercise_id: exercise.id}} }
let(:user) { create(:external_user) }
let(:scoring_response) do
[{
status: :ok,
stdout: '',
stderr: '',
waiting_for_container_time: 0,
container_execution_time: 0,
file_role: 'teacher_defined_test',
count: 1,
failed: 0,
error_messages: [],
passed: 1,
score: 1.0,
filename: 'index.html_spec.rb',
message: 'Well done.',
weight: 2.0,
}]
end

before do
create(:lti_parameter, external_user: user, exercise:)
submission = build(:submission, exercise:, user:)
allow(submission).to receive(:normalized_score).and_return(1)
allow(submission).to receive(:calculate_score).and_return(scoring_response)
allow(Submission).to receive(:create).and_return(submission)
end

context 'when LTI outcomes are supported' do
before do
allow(controller).to receive(:lti_outcome_service?).and_return(true)
end

context 'when the score transmission succeeds' do
before do
allow(controller).to receive(:send_score).and_return(status: 'success')
perform_request
end

expect_assigns(exercise: :exercise)

it 'creates a submission' do
expect(assigns(:submission)).to be_a(Submission)
end

expect_json
expect_http_status(:ok)
end

context 'when the score transmission fails' do
before do
allow(controller).to receive(:send_score).and_return(status: 'unsupported')
perform_request
end

expect_assigns(exercise: :exercise)

it 'creates a submission' do
expect(assigns(:submission)).to be_a(Submission)
end

expect_json
expect_http_status(:service_unavailable)
end
end

context 'when LTI outcomes are not supported' do
before do
allow(controller).to receive(:lti_outcome_service?).and_return(false)
perform_request
end

expect_assigns(exercise: :exercise)

it 'creates a submission' do
expect(assigns(:submission)).to be_a(Submission)
end

it 'does not send scores' do
expect(controller).not_to receive(:send_score)
end

expect_json
expect_http_status(:ok)
end
end

describe 'PUT #update' do
context 'with a valid exercise' do
let(:exercise_attributes) { build(:dummy).attributes }
Expand Down

0 comments on commit 2144f69

Please sign in to comment.