Skip to content

Commit

Permalink
feat: add attribute to allow file upload before scorm is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
satikaj committed Jun 15, 2024
1 parent 26ef809 commit f12abe8
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/api/entities/task_definition_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def staff?(my_role)
expose :has_scorm_data?, as: :has_scorm_data
expose :scorm_enabled
expose :scorm_allow_review
expose :scorm_bypass_test
expose :scorm_time_delay_enabled
expose :scorm_attempt_limit
expose :is_graded
Expand Down
4 changes: 4 additions & 0 deletions app/api/task_definitions_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TaskDefinitionsApi < Grape::API
requires :plagiarism_warn_pct, type: Integer, desc: 'The percent at which to record and warn about plagiarism'
requires :scorm_enabled, type: Boolean, desc: 'Whether SCORM assessment is enabled for this task'
requires :scorm_allow_review, type: Boolean, desc: 'Whether a student is allowed to review their completed test attempts'
requires :scorm_bypass_test, type: Boolean, desc: 'Whether a student is allowed to upload files before passing SCORM test'
requires :scorm_time_delay_enabled, type: Boolean, desc: 'Whether there is an incremental time delay between SCORM test attempts'
requires :scorm_attempt_limit, type: Integer, desc: 'The number of times a SCORM test can be attempted'
requires :is_graded, type: Boolean, desc: 'Whether or not this task definition is a graded task'
Expand Down Expand Up @@ -63,6 +64,7 @@ class TaskDefinitionsApi < Grape::API
:plagiarism_warn_pct,
:scorm_enabled,
:scorm_allow_review,
:scorm_bypass_test,
:scorm_time_delay_enabled,
:scorm_attempt_limit,
:is_graded,
Expand Down Expand Up @@ -116,6 +118,7 @@ class TaskDefinitionsApi < Grape::API
optional :plagiarism_warn_pct, type: Integer, desc: 'The percent at which to record and warn about plagiarism'
optional :scorm_enabled, type: Boolean, desc: 'Whether or not SCORM test assessment is enabled for this task'
optional :scorm_allow_review, type: Boolean, desc: 'Whether a student is allowed to review their completed test attempts'
optional :scorm_bypass_test, type: Boolean, desc: 'Whether a student is allowed to upload files before passing SCORM test'
optional :scorm_time_delay_enabled, type: Boolean, desc: 'Whether or not there is an incremental time delay between SCORM test attempts'
optional :scorm_attempt_limit, type: Integer, desc: 'The number of times a SCORM test can be attempted'
optional :is_graded, type: Boolean, desc: 'Whether or not this task definition is a graded task'
Expand Down Expand Up @@ -148,6 +151,7 @@ class TaskDefinitionsApi < Grape::API
:plagiarism_warn_pct,
:scorm_enabled,
:scorm_allow_review,
:scorm_bypass_test,
:scorm_time_delay_enabled,
:scorm_attempt_limit,
:is_graded,
Expand Down
10 changes: 8 additions & 2 deletions app/models/task_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def to_csv_row

def self.csv_columns
[:name, :abbreviation, :description, :weighting, :target_grade, :restrict_status_updates, :max_quality_pts,
:is_graded, :plagiarism_warn_pct, :group_set, :upload_requirements, :scorm_enabled,
:scorm_allow_review, :scorm_time_delay_enabled, :scorm_attempt_limit, :start_week, :start_day, :target_week,
:is_graded, :plagiarism_warn_pct, :group_set, :upload_requirements, :scorm_enabled, :scorm_allow_review,
:scorm_bypass_test, :scorm_time_delay_enabled, :scorm_attempt_limit, :start_week, :start_day, :target_week,
:target_day, :due_week, :due_day, :tutorial_stream]
end

Expand Down Expand Up @@ -351,6 +351,7 @@ def self.task_def_for_csv_row(unit, row)

result.scorm_enabled = %w(Yes y Y yes true TRUE 1).include? "#{row[:scorm_enabled]}".strip
result.scorm_allow_review = %w(Yes y Y yes true TRUE 1).include? "#{row[:scorm_allow_review]}".strip
result.scorm_bypass_test = %w(Yes y Y yes true TRUE 1).include? "#{row[:scorm_bypass_test]}".strip
result.scorm_time_delay_enabled = %w(Yes y Y yes true TRUE 1).include? "#{row[:scorm_time_delay_enabled]}".strip
result.scorm_attempt_limit = row[:scorm_attempt_limit].to_i

Expand Down Expand Up @@ -412,6 +413,10 @@ def scorm_allow_review?
scorm_allow_review
end

def scorm_bypass_test?
scorm_bypass_test
end

def scorm_time_delay_enabled?
scorm_time_delay_enabled
end
Expand Down Expand Up @@ -614,6 +619,7 @@ def task_scorm_data_with_abbreviation(abbr)
def reset_scorm_config()
self.scorm_enabled = false
self.scorm_allow_review = false
self.scorm_bypass_test = false
self.scorm_time_delay_enabled = false
self.scorm_attempt_limit = 0
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20231205011842_create_test_attempts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateTestAttempts < ActiveRecord::Migration[7.0]
def change
create_table :test_attempts do |t|
t.references :task
t.datetime :attempted_time, null:false
t.datetime :attempted_time, null: false
t.boolean :terminated, default: false
t.boolean :completion_status, default: false
t.boolean :success_status, default: false
Expand Down
4 changes: 3 additions & 1 deletion db/migrate/20240322021829_add_scorm_config_to_task_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def change
change_table :task_definitions do |t|
t.boolean :scorm_enabled, default: false
t.boolean :scorm_allow_review, default: false
t.boolean :scorm_bypass_test, default: false
t.boolean :scorm_time_delay_enabled, default: false
t.integer :scorm_attempt_limit
end
Expand All @@ -11,7 +12,8 @@ def change
def down
change_table :task_definitions do |t|
t.remove :scorm_enabled
t.boolean :scorm_allow_review
t.remove :scorm_allow_review
t.remove :scorm_bypass_test
t.remove :scorm_time_delay_enabled
t.remove :scorm_attempt_limit
end
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
t.string "moss_language"
t.boolean "scorm_enabled", default: false
t.boolean "scorm_allow_review", default: false
t.boolean "scorm_bypass_test", default: false
t.boolean "scorm_time_delay_enabled", default: false
t.integer "scorm_attempt_limit"
t.index ["group_set_id"], name: "index_task_definitions_on_group_set_id"
Expand Down
1 change: 1 addition & 0 deletions test/api/units/task_definitions_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_task_definition_cud
max_quality_pts: 0,
scorm_enabled: false,
scorm_allow_review: false,
scorm_bypass_test: false,
scorm_time_delay_enabled: true,
scorm_attempt_limit: 0
}
Expand Down
2 changes: 1 addition & 1 deletion test/models/task_definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_export_task_definitions_csv
task_defs_csv = CSV.parse unit.task_definitions_csv, headers: true
task_defs_csv.each do |task_def_csv|
task_def = unit.task_definitions.find_by(abbreviation: task_def_csv['abbreviation'])
keys_to_ignore = ['tutorial_stream', 'start_week', 'start_day', 'target_week', 'target_day', 'due_week', 'due_day', 'scorm_enabled', 'scorm_allow_review', 'scorm_time_delay_enabled', 'scorm_attempt_limit']
keys_to_ignore = ['tutorial_stream', 'start_week', 'start_day', 'target_week', 'target_day', 'due_week', 'due_day', 'scorm_enabled', 'scorm_allow_review', 'scorm_bypass_test', 'scorm_time_delay_enabled', 'scorm_attempt_limit']
task_def_csv.each do |key, value|
unless keys_to_ignore.include?(key)
assert_equal(task_def[key].to_s, value)
Expand Down
2 changes: 1 addition & 1 deletion test_files/COS10001-ImportTasksWithTutorialStream.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_time_delay_enabled,scorm_attempt_limit
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_bypass_test,scorm_time_delay_enabled,scorm_attempt_limit
Pass Task 1.1 - Hello World,1.1P,"As a first step, create the classic 'Hello World' program. This will help ensure that you have all of the software installed correctly, and are ready to move on with creating other,,, programs.",1,0,FALSE,"[{""key"":""file0"",""name"":""HelloWorld.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks,,,
Pass Task 1.2 - Picture Drawing,1.2P,Create a program that calls procedures to draw a picture to a window (something other than a house which we use as the example).,2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks,,,
Pass Task 1.3 - Creating a Procedure,1.3P,"Now that you have created a program that uses procedures, you can learn how to create your own procedures. Creating procedures will allow you to group your program's actions into procedures that perform meaningful tasks.",2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks,,,
Expand Down
2 changes: 1 addition & 1 deletion test_files/COS10001-ImportTasksWithoutTutorialStream.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_time_delay_enabled,scorm_attempt_limit
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_bypass_test,scorm_time_delay_enabled,scorm_attempt_limit
Pass Task 1.1 - Hello World,1.1P,"As a first step, create the classic 'Hello World' program. This will help ensure that you have all of the software installed correctly, and are ready to move on with creating other,,, programs.",1,0,FALSE,"[{""key"":""file0"",""name"":""HelloWorld.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,,,,
Pass Task 1.2 - Picture Drawing,1.2P,Create a program that calls procedures to draw a picture to a window (something other than a house which we use as the example).,2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,,,,
Pass Task 1.3 - Creating a Procedure,1.3P,"Now that you have created a program that uses procedures, you can learn how to create your own procedures. Creating procedures will allow you to group your program's actions into procedures that perform meaningful tasks.",2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,,,,
Expand Down
2 changes: 1 addition & 1 deletion test_files/COS10001-Tasks.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_time_delay_enabled,scorm_attempt_limit
name,abbreviation,description,weighting,target_grade,restrict_status_updates,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_bypass_test,scorm_time_delay_enabled,scorm_attempt_limit
Pass Task 1.1 - Hello World,1.1P,"As a first step, create the classic 'Hello World' program. This will help ensure that you have all of the software installed correctly, and are ready to move on with creating other,,, programs.",1,0,FALSE,"[{""key"":""file0"",""name"":""HelloWorld.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks
Pass Task 1.2 - Picture Drawing,1.2P,Create a program that calls procedures to draw a picture to a window (something other than a house which we use as the example).,2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks
Pass Task 1.3 - Creating a Procedure,1.3P,"Now that you have created a program that uses procedures, you can learn how to create your own procedures. Creating procedures will allow you to group your program's actions into procedures that perform meaningful tasks.",2,0,FALSE,"[{""key"":""file0"",""name"":""PictureDrawing.pas"",""type"":""code""},{""key"":""file1"",""name"":""Screenshot"",""type"":""image""}]",1,Tue,2,Tue,5,Mon,0,FALSE,90,,,import-tasks
Expand Down
2 changes: 1 addition & 1 deletion test_files/csv_test_files/COS10001-Tasks.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name,abbreviation,description,weighting,target_grade,restrict_status_updates,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,scorm_enabled,scorm_allow_review,scorm_time_delay_enabled,scorm_attempt_limit
name,abbreviation,description,weighting,target_grade,restrict_status_updates,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,scorm_enabled,scorm_allow_review,scorm_bypass_test,scorm_time_delay_enabled,scorm_attempt_limit
Assignment 12,A12,rerum ut fugit saepe ipsa in quidem,2,0,FALSE,0,FALSE,50,[],,"[{""key"":""file0"",""name"":""Assumenda accusamus quas"",""type"":""image""}]",-1,Sat,1,Mon,13,Mon,,,
2 changes: 1 addition & 1 deletion test_files/unit_csv_imports/import_group_tasks.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name,abbreviation,description,weighting,target_grade,restrict_status_updates,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_time_delay_enabled,scorm_attempt_limit
name,abbreviation,description,weighting,target_grade,restrict_status_updates,max_quality_pts,is_graded,plagiarism_warn_pct,plagiarism_checks,group_set,upload_requirements,start_week,start_day,target_week,target_day,due_week,due_day,tutorial_stream,scorm_enabled,scorm_allow_review,scorm_bypass_test,scorm_time_delay_enabled,scorm_attempt_limit
Group Import 1,1GI,Test Description - Import,16,0,FALSE,0,FALSE,80,[],Group Work,[],0,Mon,1,Sun,2,Wed,group-tasks-test,,,
Missing Group,2GI,Test Description - Import FAIL,16,0,FALSE,0,FALSE,80,[],Group Work1,[],0,Mon,1,Sun,2,Wed,group-tasks-test,,,

0 comments on commit f12abe8

Please sign in to comment.