From caa5017d0b3128ef0e52dca1c4c10d18a8f790e5 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Sat, 6 Aug 2022 15:08:59 -0400 Subject: [PATCH 01/12] WIP: initial checkin of some changes to handling settings. WIP: work on course_settings WIP: continued work on the course settings WIP: continued work on course_settings. TEST: mojolicious route testing for settings. WIP: continued work on course settings --- ...ourse_defaults.yml => course_settings.yml} | 285 +++--- lib/DB/Exception.pm | 4 + lib/DB/Schema/Result/Course.pm | 4 +- lib/DB/Schema/Result/CourseSetting.pm | 67 ++ lib/DB/Schema/Result/GlobalSetting.pm | 117 +++ lib/DB/Schema/ResultSet/Course.pm | 265 +++++- lib/DB/Utils.pm | 6 +- lib/WeBWorK3.pm | 15 +- lib/WeBWorK3/Controller/Settings.pm | 60 +- lib/WeBWorK3/Utils/Settings.pm | 251 ++---- package-lock.json | 96 +- package.json | 3 +- src/common/models/parsers.ts | 5 + src/common/models/settings.ts | 323 ++++++- src/components/instructor/SingleSetting.vue | 84 +- src/stores/settings.ts | 140 +-- t/db/002_course_settings.t | 315 ++++--- t/db/build_db.pl | 44 +- t/db/sample_data/course_settings.csv | 8 + t/db/sample_data/courses.csv | 12 +- t/mojolicious/015_course_settings.t | 110 +++ tests/stores/settings.spec.ts | 140 +++ tests/unit-tests/parsing.spec.ts | 48 +- tests/unit-tests/settings.spec.ts | 827 ++++++++++++++++++ 24 files changed, 2592 insertions(+), 637 deletions(-) rename conf/{course_defaults.yml => course_settings.yml} (72%) create mode 100644 lib/DB/Schema/Result/CourseSetting.pm create mode 100644 lib/DB/Schema/Result/GlobalSetting.pm create mode 100644 t/db/sample_data/course_settings.csv create mode 100644 t/mojolicious/015_course_settings.t create mode 100644 tests/stores/settings.spec.ts create mode 100644 tests/unit-tests/settings.spec.ts diff --git a/conf/course_defaults.yml b/conf/course_settings.yml similarity index 72% rename from conf/course_defaults.yml rename to conf/course_settings.yml index 06df7c77..f6d6a2fe 100644 --- a/conf/course_defaults.yml +++ b/conf/course_settings.yml @@ -5,30 +5,33 @@ # For the optional category, there are subcategories. # # For each course setting there are 4 fields -# var: the name of the variable/setting -# doc: a short description of the variable -# doc2: a longer description of the variable (optional) -# type: the type of varable (text, list, multilist, boolean, integer, decimal, time, date_time, time_duration, +# setting_name: the name of the variable/setting +# description: a short description of the variable +# category: category the setting is in (for organization on the UI) +# subcategory: subcategory the setting is in (if applicable) +# doc: a longer description of the variable (optional) +# type: the type of varable (text, list, multilist, boolean, int, decimal, time, date_time, time_duration, # timezone) +# options: an array of strings or objects with the fields value and label; used for a setting of types and multilist # these are the general course settings - - var: institution + setting_name: institution category: general - doc: Name of the institution + description: Name of the institution type: text - default: '' + default_value: '' - - var: course_description + setting_name: course_description category: general - doc: Description of the course + description: Description of the course type: text - default: '' + default_value: '' - - var: language + setting_name: language category: general - doc: Default language for the course - doc2: > + description: Default language for the course + doc: > WeBWorK currently has translations for the following languages: "English en", "French fr", and "German de" type: list @@ -54,12 +57,12 @@ #- # label: Turkish # value: tr - default: en-US # select default value here + default_value: en-US # select default value here - - var: per_problem_lang_and_dir_setting_mode + setting_name: per_problem_lang_and_dir_setting_mode category: general - doc: Mode in which the LANG and DIR settings for a single problem are determined. - doc2: > + description: Mode in which the LANG and DIR settings for a single problem are determined. + doc: > Mode in which the LANG and DIR settings for a single problem are determined. The system will set the LANGuage attribute to either a value determined from the problem, @@ -126,42 +129,41 @@ - auto:zh_hk:ltr - force:he:rtl - auto:he:rtl - default: none + default_value: none - - var: session_key_timeout + setting_name: session_key_timeout category: general - doc: Inactivity time before a user is required to login again + description: Inactivity time before a user is required to login again type: time_duration - # note the default time is in seconds - default: 15 mins + default_value: 15 mins - - var: timezone + setting_name: timezone category: general - doc: Timezone for the course + description: Timezone for the course type: timezone - default: site_default_timezone + default_value: America/New_York - - var: hardcopy_theme + setting_name: hardcopy_theme category: general - doc: Hardcopy Theme - doc2: | + description: Hardcopy Theme + doc: | There are currently two hardcopy themes to choose from: One Column and Two Columns. The Two Columns theme is the traditional hardcopy format. The One Column theme uses the full page width for each column type: list options: [ 'One Column', 'Two Column' ] - default: 'Two Column' + default_value: 'Two Column' - - var: show_course_homework_totals + setting_name: show_course_homework_totals category: general - doc: Show Total Homework Grade on Grades Page - doc2: | + description: Show Total Homework Grade on Grades Page + doc: | When this is on students will see a line on the Grades page which has their total cumulative homework score. This score includes all sets assigned to the student. type: boolean - default: true + default_value: true # this contains all optional features of webwork @@ -169,26 +171,26 @@ - category: optional subcategory: conditional_release - var: enable_conditional_release - doc: Enable Conditional Release - doc2: whether or not problem sets can have conditional release + setting_name: enable_conditional_release + description: Enable Conditional Release + doc: whether or not problem sets can have conditional release type: boolean - default: false + default_value: false # reduced scoring - - var: enable_reduced_scoring + setting_name: enable_reduced_scoring category: optional subcategory: reduced_scoring - doc: whether or not problem sets can have reducing scoring enabled. + description: whether or not problem sets can have reduced scoring enabled. type: boolean - default: false + default_value: false - - var: reducing_scoring_value + setting_name: reduced_scoring_value category: optional subcategory: reduced_scoring - doc: Value of work done in Reduced Scoring Period - doc2: > + description: Value of work done in Reduced Scoring Period + doc: > After the Reduced Scoring Date all additional work done by the student counts at a reduced rate. Here is where you set the reduced rate which must be a percentage. For example if this value is 50% and a student @@ -203,14 +205,14 @@ This works with the avg_problem_grader (which is the default grader) and the std_problem_grader (the all or nothing grader). It will work with custom graders if they are written appropriately. - type: text - default: false + type: decimal + default_value: 0.8 - - var: reduced_scoring_period + setting_name: reduced_scoring_period category: optional subcategory: reduced_scoring - doc: Default Length of Reduced Scoring Period - doc2: > + description: Default Length of Reduced Scoring Period + doc: > The Reduced Scoring Period is the default period before the due date during which all additional work done by the student counts at a reduced rate. When enabling reduced scoring for a set the reduced scoring date will be set to @@ -221,45 +223,45 @@ at 06:17pm EST. During this period all additional work done counts 50% of the original." will be displayed. type: time_duration - default: 3 days + default_value: 3 days # show me another - - var: enable_show_me_another + setting_name: enable_show_me_another category: optional subcategory: show_me_another - doc: Enable Show Me Another button - doc2: > + description: Enable Show Me Another button + doc: > Enables use of the Show Me Another button, which offers the student a newly-seeded version of the current problem, complete with solution (if it exists for that problem). type: boolean - default: false + default_value: false - - var: show_me_another_default + setting_name: show_me_another_default category: optional subcategory: show_me_another - doc: Default number of attempts before Show Me Another can be used (-1 => Never) - doc2: | + description: Default number of attempts before Show Me Another can be used (-1 => Never) + doc: | This is the default number of attempts before show me another becomes available to students. It can be set to -1 to disable show me another by default. - type: integer - default: -1 + type: int + default_value: -1 - - var: show_me_another_max_reps + setting_name: show_me_another_max_reps category: optional subcategory: show_me_another - doc: Maximum times Show me Another can be used per problem (-1 => unlimited) - doc2: | + description: Maximum times Show me Another can be used per problem (-1 => unlimited) + doc: | The Maximum number of times Show me Another can be used per problem by a student. If set to -1 then there is no limit to the number of times that Show Me Another can be used. - type: integer - default: -1 + type: int + default_value: -1 - - var: show_me_another_options + setting_name: show_me_another_options category: optional subcategory: show_me_another - doc: List of options for Show Me Another button - doc2: > + description: List of options for Show Me Another button + doc: >