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

Propagate start_at during assessment import, remove unused db columns #1932

Merged
merged 7 commits into from
Jul 9, 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
15 changes: 2 additions & 13 deletions app/controllers/assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def create
"handin.c"
end

@assessment.visible_at = Time.current + 1.day
@assessment.start_at = Time.current + 1.day
@assessment.due_at = Time.current + 1.day
@assessment.end_at = Time.current + 1.day
Expand All @@ -307,16 +306,6 @@ def create
@assessment.quizData = ""
@assessment.max_submissions = params.include?(:max_submissions) ? params[:max_submissions] : -1

if @assessment.embedded_quiz
begin
@assessment.embedded_quiz_form_data = params[:assessment][:embedded_quiz_form].read
rescue StandardError
flash[:error] = "Embedded quiz form cannot be empty!"
redirect_to(action: :install_assessment)
return
end
end

begin
@assessment.construct_folder
rescue StandardError => e
Expand Down Expand Up @@ -365,7 +354,6 @@ def assessmentInitialize(assignName)
@start_at = @assessment.start_at
@due_at = @assessment.due_at
@end_at = @assessment.end_at
@visible_at = @assessment.visible_at
@id = @assessment.id
end

Expand Down Expand Up @@ -960,7 +948,7 @@ def new_assessment_params
ass = params.require(:assessment)
ass[:category_name] = params[:new_category] if params[:new_category].present?
ass.permit(:name, :display_name, :category_name, :has_svn, :has_lang, :group_size,
:embedded_quiz, :embedded_quiz_form_data, :github_submission_enabled)
:github_submission_enabled)
end

def edit_assessment_params
Expand All @@ -979,6 +967,7 @@ def edit_assessment_params

ass.delete(:name)
ass.delete(:config_file)
ass.delete(:embedded_quiz_form)

ass.permit!
end
Expand Down
1 change: 0 additions & 1 deletion app/helpers/assessment_autograde_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ def extend_config_module(assessment, submission, cud)
@start_at = @assessment.start_at
@due_at = @assessment.due_at
@end_at = @assessment.end_at
@visible_at = @assessment.visible_at
@id = @assessment.id

# we iterate over all the methods
Expand Down
23 changes: 12 additions & 11 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ def serialize
s["dates"] = { start_at: start_at.to_s,
due_at: due_at.to_s,
end_at: end_at.to_s,
grading_deadline: grading_deadline.to_s,
visible_at: visible_at.to_s }.deep_stringify_keys
grading_deadline: grading_deadline.to_s }.deep_stringify_keys
s
end

Expand All @@ -486,16 +485,18 @@ def deserialize(s)
raise "Name in yaml (#{s['general']['name']}) doesn't match #{name}"
end

if s["dates"] && s["dates"]["start_at"] && s["dates"]["due_at"] && s["dates"]["end_at"] &&
s["dates"]["visible_at"] && s["dates"]["grading_deadline"]
self.due_at = Time.zone.parse(s["dates"]["due_at"])
self.start_at = Time.zone.parse(s["dates"]["start_at"])
self.end_at = Time.zone.parse(s["dates"]["due_at"])
self.visible_at = Time.zone.parse(s["dates"]["visible_at"])
self.grading_deadline = Time.zone.parse(s["dates"]["grading_deadline"])
if s["dates"] && s["dates"]["start_at"]
if s["dates"]["due_at"] && s["dates"]["end_at"] && s["dates"]["grading_deadline"]
self.due_at = Time.zone.parse(s["dates"]["due_at"])
self.start_at = Time.zone.parse(s["dates"]["start_at"])
self.end_at = Time.zone.parse(s["dates"]["end_at"])
self.grading_deadline = Time.zone.parse(s["dates"]["grading_deadline"])
else
self.due_at = self.end_at = self.start_at = self.grading_deadline =
Time.zone.parse(s["dates"]["start_at"])
end
else
self.due_at = self.end_at = self.visible_at =
self.start_at = self.grading_deadline = Time.current + 1.day
self.due_at = self.end_at = self.start_at = self.grading_deadline = Time.current + 1.day
end

self.quiz = false
Expand Down
49 changes: 0 additions & 49 deletions app/views/assessments/confirmInstall.html.erb

This file was deleted.

48 changes: 0 additions & 48 deletions app/views/courses/confirmInstall.html.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveVisibleAtFromAssessments < ActiveRecord::Migration[6.0]
def change
remove_column :assessments, :visible_at, :timestamp
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveHasAutogradeOldFromAssessments < ActiveRecord::Migration[6.0]
def change
remove_column :assessments, :has_autograde_old, :boolean
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveHasScoreboardOldFromAssessments < ActiveRecord::Migration[6.0]
def change
remove_column :assessments, :has_scoreboard_old, :boolean
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveEmbeddedQuizFormFromAssessments < ActiveRecord::Migration[6.0]
def change
remove_column :assessments, :embedded_quiz_form, :binary
end
end
6 changes: 1 addition & 5 deletions 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.define(version: 2023_06_03_073633) do
ActiveRecord::Schema.define(version: 2023_06_25_131325) do

create_table "annotations", force: :cascade do |t|
t.integer "submission_id"
Expand Down Expand Up @@ -60,7 +60,6 @@
create_table "assessments", force: :cascade do |t|
t.datetime "due_at"
t.datetime "end_at"
t.datetime "visible_at"
t.datetime "start_at"
t.string "name"
t.text "description"
Expand All @@ -82,8 +81,6 @@
t.integer "late_penalty_id"
t.integer "version_penalty_id"
t.datetime "grading_deadline", null: false
t.boolean "has_autograde_old"
t.boolean "has_scoreboard_old"
t.boolean "has_svn"
t.boolean "quiz", default: false
t.text "quizData"
Expand All @@ -92,7 +89,6 @@
t.integer "group_size", default: 1
t.text "embedded_quiz_form_data"
t.boolean "embedded_quiz"
t.binary "embedded_quiz_form"
t.boolean "allow_student_assign_group", default: true
t.boolean "github_submission_enabled", default: true
t.boolean "is_positive_grading", default: false
Expand Down
2 changes: 0 additions & 2 deletions lib/tasks/autolab.rake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ namespace :autolab do
course.assessments.create do |a|
a.category_name = cat

a.visible_at = start
a.start_at = start
a.due_at = start + (5 + rand(11)).days # 5-15d after start date
a.end_at = a.due_at + (1 + rand(7)).day # 1d-1w after the due date
Expand Down Expand Up @@ -349,7 +348,6 @@ namespace :autolab do
asmt = course.assessments.create! do |a|
a.category_name = AUTOGRADE_CATEGORY_NAME

a.visible_at = COURSE_START
a.start_at = COURSE_START
a.due_at = COURSE_START + (5 + rand(11)).days
a.end_at = a.due_at + (1 + rand(7)).day
Expand Down