From f12abe87671b8192364c72946d7172b2a8def302 Mon Sep 17 00:00:00 2001 From: satikaj <117552851+satikaj@users.noreply.github.com> Date: Sat, 15 Jun 2024 21:36:21 +1000 Subject: [PATCH] feat: add attribute to allow file upload before scorm is passed --- app/api/entities/task_definition_entity.rb | 1 + app/api/task_definitions_api.rb | 4 ++++ app/models/task_definition.rb | 10 ++++++++-- db/migrate/20231205011842_create_test_attempts.rb | 2 +- .../20240322021829_add_scorm_config_to_task_def.rb | 4 +++- db/schema.rb | 1 + test/api/units/task_definitions_api_test.rb | 1 + test/models/task_definition_test.rb | 2 +- test_files/COS10001-ImportTasksWithTutorialStream.csv | 2 +- .../COS10001-ImportTasksWithoutTutorialStream.csv | 2 +- test_files/COS10001-Tasks.csv | 2 +- test_files/csv_test_files/COS10001-Tasks.csv | 2 +- test_files/unit_csv_imports/import_group_tasks.csv | 2 +- 13 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/api/entities/task_definition_entity.rb b/app/api/entities/task_definition_entity.rb index f99b2d73d..efb69f591 100644 --- a/app/api/entities/task_definition_entity.rb +++ b/app/api/entities/task_definition_entity.rb @@ -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 diff --git a/app/api/task_definitions_api.rb b/app/api/task_definitions_api.rb index db1f70b6b..0f9d4fa69 100644 --- a/app/api/task_definitions_api.rb +++ b/app/api/task_definitions_api.rb @@ -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' @@ -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, @@ -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' @@ -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, diff --git a/app/models/task_definition.rb b/app/models/task_definition.rb index 88c907d4e..59c798505 100644 --- a/app/models/task_definition.rb +++ b/app/models/task_definition.rb @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/db/migrate/20231205011842_create_test_attempts.rb b/db/migrate/20231205011842_create_test_attempts.rb index c09160615..3f7004a81 100644 --- a/db/migrate/20231205011842_create_test_attempts.rb +++ b/db/migrate/20231205011842_create_test_attempts.rb @@ -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 diff --git a/db/migrate/20240322021829_add_scorm_config_to_task_def.rb b/db/migrate/20240322021829_add_scorm_config_to_task_def.rb index 5daa69c72..99c7dcffb 100644 --- a/db/migrate/20240322021829_add_scorm_config_to_task_def.rb +++ b/db/migrate/20240322021829_add_scorm_config_to_task_def.rb @@ -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 @@ -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 diff --git a/db/schema.rb b/db/schema.rb index ea4362886..66319395c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/test/api/units/task_definitions_api_test.rb b/test/api/units/task_definitions_api_test.rb index ea0826fe6..663ba880f 100644 --- a/test/api/units/task_definitions_api_test.rb +++ b/test/api/units/task_definitions_api_test.rb @@ -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 } diff --git a/test/models/task_definition_test.rb b/test/models/task_definition_test.rb index 5210322ef..a292cd1cd 100644 --- a/test/models/task_definition_test.rb +++ b/test/models/task_definition_test.rb @@ -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) diff --git a/test_files/COS10001-ImportTasksWithTutorialStream.csv b/test_files/COS10001-ImportTasksWithTutorialStream.csv index 7e1df1062..b36339a21 100644 --- a/test_files/COS10001-ImportTasksWithTutorialStream.csv +++ b/test_files/COS10001-ImportTasksWithTutorialStream.csv @@ -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,,, diff --git a/test_files/COS10001-ImportTasksWithoutTutorialStream.csv b/test_files/COS10001-ImportTasksWithoutTutorialStream.csv index 8ed8b6cb4..d5f7eb1e8 100644 --- a/test_files/COS10001-ImportTasksWithoutTutorialStream.csv +++ b/test_files/COS10001-ImportTasksWithoutTutorialStream.csv @@ -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,,,,,, diff --git a/test_files/COS10001-Tasks.csv b/test_files/COS10001-Tasks.csv index d4e15b33a..ae03608c0 100644 --- a/test_files/COS10001-Tasks.csv +++ b/test_files/COS10001-Tasks.csv @@ -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 diff --git a/test_files/csv_test_files/COS10001-Tasks.csv b/test_files/csv_test_files/COS10001-Tasks.csv index 25f7728ec..52a9ebe8d 100644 --- a/test_files/csv_test_files/COS10001-Tasks.csv +++ b/test_files/csv_test_files/COS10001-Tasks.csv @@ -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,,, diff --git a/test_files/unit_csv_imports/import_group_tasks.csv b/test_files/unit_csv_imports/import_group_tasks.csv index 60996825a..e9782cf7e 100644 --- a/test_files/unit_csv_imports/import_group_tasks.csv +++ b/test_files/unit_csv_imports/import_group_tasks.csv @@ -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,,,