From dbedb413b347edc382ff1f50ef6f2b87300570c9 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 3 Aug 2022 22:22:52 -0500 Subject: [PATCH] Update the renderer for the restructuring of PG. The WeBWorK::PG module is now part of PG, and PG has its own environment so the webwork2 WeBWorK::PG module (and its derivatives) have been removed. The WeBWorK::Constants, WeBWorK::Debug, and WeBWork::CourseEnvironment modulesa and the webwork2 conf files are no longer needed and so are removed. The renderer uses the WeBWorK::PG::Environment module which is part of PG. Note that this adds one minor installation step for the renderer. The file conf/pg_config.yml must be copied to lib/PG/conf. Usually that file will work as is, but in some cases administrators may want to make changes to it. For example, the externalPrograms are the standard linux executables and in the standard locations. On some systems those may need to be changed. Most of the WeBWorK::Utils module has been removed. All that is left is the two methods that the renderer uses. In addition the renderer lib directory has been flattened. lib/WeBWorK/lib/WeBWorK is now just lib/WeBWorK. With this (among other things) the WEBWORK_ROOT environment variable is not needed. Note that $WeBWorK::Constants::PG_DIRECTORY is not available. $ENV{PG_ROOT} is used instead in the renderer code. Note that the unnecessary encoding and decoding of perl warnings has been removed. Also note that the references to drdrew42 have been changed to openwebwork. --- .gitattributes | 1 - .github/CODEOWNERS | 2 - .github/workflows/createContainer.yml | 2 +- .gitignore | 1 + Dockerfile | 16 +- Dockerfile_with_OPL | 14 +- README.md | 74 +- conf/pg_config.yml | 264 ++ docs/make_translation_files.md | 12 +- lib/PG | 2 +- lib/RenderApp.pm | 24 +- .../Controller/FormatRenderedProblem.pm | 46 +- lib/RenderApp/Controller/RenderProblem.pm | 217 +- lib/RenderApp/Controller/StaticFiles.pm | 6 +- lib/RenderApp/Model/Problem.pm | 2 +- lib/WeBWorK/{lib/WeBWorK => }/Form.pm | 0 lib/WeBWorK/{lib/WeBWorK => }/Localize.pm | 8 +- lib/WeBWorK/{lib/WeBWorK => }/Localize/en.po | 0 lib/WeBWorK/{lib/WeBWorK => }/Localize/heb.po | 0 .../{lib/WeBWorK => }/Localize/standalone.pot | 0 lib/WeBWorK/Utils.pm | 84 + .../{lib/WeBWorK => }/Utils/AttemptsTable.pm | 43 +- .../Utils/LanguageAndDirection.pm | 4 - lib/WeBWorK/{lib/WeBWorK => }/Utils/Tags.pm | 0 lib/WeBWorK/conf/defaults.config | 2168 ----------------- lib/WeBWorK/conf/site.conf | 337 --- lib/WeBWorK/lib/WeBWorK/Constants.pm | 120 - lib/WeBWorK/lib/WeBWorK/CourseEnvironment.pm | 381 --- lib/WeBWorK/lib/WeBWorK/Debug.pm | 146 -- lib/WeBWorK/lib/WeBWorK/PG.pm | 532 ---- lib/WeBWorK/lib/WeBWorK/PG/Local.pm | 566 ----- lib/WeBWorK/lib/WeBWorK/Utils.pm | 292 --- .../lib/WeBWorK/Utils/DelayedMailer.pm | 167 -- .../WeBWorK/Utils/RestrictedClosureClass.pm | 116 - .../lib => }/WebworkClient/classic_format.pl | 2 +- .../lib => }/WebworkClient/json_format.pl | 1 - .../WebworkClient/jwe_secure_format.pl | 1 - .../lib => }/WebworkClient/nosubmit_format.pl | 1 - .../lib => }/WebworkClient/practice_format.pl | 2 +- .../lib => }/WebworkClient/simple_format.pl | 4 +- .../lib => }/WebworkClient/single_format.pl | 2 +- .../lib => }/WebworkClient/standard_format.pl | 3 - .../lib => }/WebworkClient/static_format.pl | 2 +- .../lib => }/WebworkClient/ww3_format.pl | 1 - public/Rederly-50.png | Bin 4072 -> 0 bytes public/filebrowser.js | 9 +- public/navbar.js | 7 +- templates/columns/tags.html.ep | 4 +- 48 files changed, 542 insertions(+), 5144 deletions(-) delete mode 100644 .github/CODEOWNERS create mode 100644 conf/pg_config.yml rename lib/WeBWorK/{lib/WeBWorK => }/Form.pm (100%) rename lib/WeBWorK/{lib/WeBWorK => }/Localize.pm (91%) rename lib/WeBWorK/{lib/WeBWorK => }/Localize/en.po (100%) rename lib/WeBWorK/{lib/WeBWorK => }/Localize/heb.po (100%) rename lib/WeBWorK/{lib/WeBWorK => }/Localize/standalone.pot (100%) create mode 100644 lib/WeBWorK/Utils.pm rename lib/WeBWorK/{lib/WeBWorK => }/Utils/AttemptsTable.pm (94%) rename lib/WeBWorK/{lib/WeBWorK => }/Utils/LanguageAndDirection.pm (99%) rename lib/WeBWorK/{lib/WeBWorK => }/Utils/Tags.pm (100%) delete mode 100644 lib/WeBWorK/conf/defaults.config delete mode 100644 lib/WeBWorK/conf/site.conf delete mode 100644 lib/WeBWorK/lib/WeBWorK/Constants.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/CourseEnvironment.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/Debug.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/PG.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/PG/Local.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/Utils.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/Utils/DelayedMailer.pm delete mode 100644 lib/WeBWorK/lib/WeBWorK/Utils/RestrictedClosureClass.pm rename lib/{WeBWorK/lib => }/WebworkClient/classic_format.pl (98%) rename lib/{WeBWorK/lib => }/WebworkClient/json_format.pl (98%) rename lib/{WeBWorK/lib => }/WebworkClient/jwe_secure_format.pl (99%) rename lib/{WeBWorK/lib => }/WebworkClient/nosubmit_format.pl (99%) rename lib/{WeBWorK/lib => }/WebworkClient/practice_format.pl (98%) rename lib/{WeBWorK/lib => }/WebworkClient/simple_format.pl (96%) rename lib/{WeBWorK/lib => }/WebworkClient/single_format.pl (98%) rename lib/{WeBWorK/lib => }/WebworkClient/standard_format.pl (97%) rename lib/{WeBWorK/lib => }/WebworkClient/static_format.pl (98%) rename lib/{WeBWorK/lib => }/WebworkClient/ww3_format.pl (95%) delete mode 100644 public/Rederly-50.png diff --git a/.gitattributes b/.gitattributes index 7e1e2899e..9db083dea 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,2 @@ -lib/WeBWorK/htdocs/** linguist-vendored public/** linguist-vendored *.pl linguist-language=Perl diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 0106e6c4c..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# Default reviewers on all PRs -* @drdrew42 diff --git a/.github/workflows/createContainer.yml b/.github/workflows/createContainer.yml index 1878c42ba..f237093f4 100644 --- a/.github/workflows/createContainer.yml +++ b/.github/workflows/createContainer.yml @@ -3,7 +3,7 @@ name: Github Packages Release on: push: branches: - - master + - main - development tags: - v* diff --git a/.gitignore b/.gitignore index 7204d00bb..6b17b8dba 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ lib/WeBWorK/bin/* webwork-open-problem-library/ private/ tmp/* +!tmp/.gitkeep logs/*.log node_modules node_modules/* diff --git a/Dockerfile b/Dockerfile index 1018d7de0..ae6221b36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM ubuntu:20.04 -LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer -MAINTAINER drdrew42 +LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer WORKDIR /usr/app ARG DEBIAN_FRONTEND=noninteractive @@ -11,10 +10,8 @@ RUN apt-get update \ apt-utils \ git \ gcc \ - npm \ make \ curl \ - nodejs \ dvipng \ openssl \ libc-dev \ @@ -43,6 +40,9 @@ RUN apt-get update \ libmath-random-secure-perl \ libdata-structure-util-perl \ liblocale-maketext-lexicon-perl \ + libyaml-libyaml-perl \ + && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \ + && apt-get install -y --no-install-recommends --no-install-suggests nodejs \ && apt-get clean \ && rm -fr /var/lib/apt/lists/* /tmp/* @@ -51,7 +51,13 @@ RUN cpanm install Mojo::Base Statistics::R::IO::Rserve Date::Format Future::Asyn COPY . . -RUN cd lib/WeBWorK/htdocs && npm install && cd ../../.. +RUN cp render_app.conf.dist render_app.conf + +RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml + +RUN npm install + +RUN cd lib/PG/htdocs && npm install && cd ../../.. EXPOSE 3000 diff --git a/Dockerfile_with_OPL b/Dockerfile_with_OPL index eb5847acb..ecde4c5a0 100644 --- a/Dockerfile_with_OPL +++ b/Dockerfile_with_OPL @@ -1,6 +1,5 @@ FROM ubuntu:20.04 -LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer -MAINTAINER drdrew42 +LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer WORKDIR /usr/app ARG DEBIAN_FRONTEND=noninteractive @@ -11,10 +10,8 @@ RUN apt-get update \ apt-utils \ git \ gcc \ - npm \ make \ curl \ - nodejs \ dvipng \ openssl \ libc-dev \ @@ -43,6 +40,9 @@ RUN apt-get update \ libmath-random-secure-perl \ libdata-structure-util-perl \ liblocale-maketext-lexicon-perl \ + libyaml-libyaml-perl \ + && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \ + && apt-get install -y --no-install-recommends --no-install-suggests nodejs \ && apt-get clean \ && rm -fr /var/lib/apt/lists/* /tmp/* @@ -64,7 +64,11 @@ COPY . . RUN cp render_app.conf.dist render_app.conf -RUN cd lib/WeBWorK/htdocs && npm install && cd ../../.. +RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml + +RUN npm install + +RUN cd lib/PG/htdocs && npm install && cd ../../.. EXPOSE 3000 diff --git a/README.md b/README.md index fe51a4216..2a5a5b456 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ # WeBWorK Standalone Problem Renderer & Editor -![Commit Activity](https://img.shields.io/github/commit-activity/m/drdrew42/renderer?style=plastic) -![License](https://img.shields.io/github/license/drdrew42/renderer?style=plastic) - +![Commit Activity](https://img.shields.io/github/commit-activity/m/openwebwork/renderer?style=plastic) +![License](https://img.shields.io/github/license/openwebwork/renderer?style=plastic) This is a PG Renderer derived from the WeBWorK2 codebase -* https://github.com/openwebwork/WeBWorK2 -## DOCKER CONTAINER INSTALL ### +* [https://github.com/openwebwork/webwork2](https://github.com/openwebwork/webwork2) -``` +## DOCKER CONTAINER INSTALL + +```bash mkdir volumes mkdir container git clone https://github.com/openwebwork/webwork-open-problem-library volumes/webwork-open-problem-library -git clone --recursive https://github.com/drdrew42/renderer container/ +git clone --recursive https://github.com/openwebwork/renderer container/ docker build --tag renderer:1.0 ./container docker run -d \ @@ -25,35 +25,41 @@ docker run -d \ renderer:1.0 ``` -If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by adding the following line to the `docker run` command: +If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by adding the following line to the +`docker run` command: -``` +```bash --mount type=bind,source=/pathToYourLocalContentRoot,target=/usr/app/private \ ``` -A default configuration file is included in the container, but it can be overridden by mounting a replacement at the application root. This is necessary if, for example, you want to run the container in `production` mode. +A default configuration file is included in the container, but it can be overridden by mounting a replacement at the + application root. This is necessary if, for example, you want to run the container in `production` mode. -``` +```bash --mount type=bind,source=/pathToYour/render_app.conf,target=/usr/app/render_app.conf \ ``` -## LOCAL INSTALL ### +## LOCAL INSTALL If using a local install instead of docker: -* Clone the renderer and its submodules: `git clone --recursive https://github.com/drdrew42/renderer` +* Clone the renderer and its submodules: `git clone --recursive https://github.com/openwebwork/renderer` * Enter the project directory: `cd renderer` -* Install perl dependencies listed in Dockerfile (CPANMinus recommended) +* Install Perl dependencies listed in Dockerfile (CPANMinus recommended) * clone webwork-open-problem-library into the provided stub ./webwork-open-problem-library - - `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library` + * `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library` * copy `render_app.conf.dist` to `render_app.conf` and make any desired modifications -* install other dependencies - - `cd lib/WeBWorK/htdocs` - - `npm install` -* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing root url +* copy `conf/pg_config.yml` to `lib/PG/pg_config.yml` and make any desired modifications +* install third party JavaScript dependencies + * `npm install` +* install PG JavaScript dependencies + * `cd lib/PG/htdocs` + * `npm install` +* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing + root url * access on `localhost:3000` by default or otherwise specified root url -# Editor Interface +## Editor Interface * point your browser at [`localhost:3000`](http://localhost:3000/) * select an output format (see below) @@ -64,10 +70,12 @@ If using a local install instead of docker: ![image](https://user-images.githubusercontent.com/3385756/129100124-72270558-376d-4265-afe2-73b5c9a829af.png) -# Renderer API +## Renderer API + Can be interfaced through `/render-api` ## Parameters + | Key | Type | Default Value | Required | Description | Notes | | --- | ---- | ------------- | -------- | ----------- | ----- | | problemSourceURL | string | null | true if `sourceFilePath` and `problemSource` are null | The URL from which to fetch the problem source code | Takes precedence over `problemSource` and `sourceFilePath`. A request to this URL is expected to return valid pg source code in base64 encoding. | @@ -80,12 +88,13 @@ Can be interfaced through `/render-api` | format | string | '' | false | Determine how the response is formatted ('html' or 'json') || | outputFormat | string (enum) | static | false | Determines how the problem should render, see below descriptions below | | | language | string | en | false | Language to render the problem in (if supported) | | -| showHints | number (boolean) | 1 | false | Whether or not to show hints (restrictions apply) | Irrelevant if `permissionLevel >= 10`, in which case `showHints` is regarded as automatically 'true' | -| showSolutions | number (boolean) | 0 | false | Whether or not to show the solutions (restrictions apply) | Irrelevant if `permissionLevel >= 10`, in which case `showSolutions` is regarded as automatically 'true' | -| permissionLevel | number | 0 | false | Affects the rendering of hints and solutions. Also controls display of scaffold problems (possibly more) | See the levels we use below | +| showHints | number (boolean) | 1 | false | Whether or not to show hints | | +| showSolutions | number (boolean) | 0 | false | Whether or not to show the solutions | | +| permissionLevel | number | 0 | false | Deprecated. See below. | +| isInstructor | number (boolean) | 0 | false | Is the user viewing the problem an instructor or not. | Used by PG to determine if scaffolds can be allowed to be open among other things | | problemNumber | number | 1 | false | We don't use this | | | numCorrect | number | 0 | false | The number of correct attempts on a problem | | -| numIncorrect | number | 1000 | false | the number of incorrect attempts on this problem | Relevant for triggering hints that are not immediately available | +| numIncorrect | number | 1000 | false | The number of incorrect attempts on this problem | | | processAnswers | number (boolean) | 1 | false | Determines whether or not answer json is populated, and whether or not problem_result and problem_state are non-empty | | | answersSubmitted | number (boolean) | ? | false? | Determines whether to process form-data associated to the available input fields | | | showSummary | number (boolean) | ? | false? | Determines whether or not to show the summary result of processing the form-data associated with `answersSubmitted` above || @@ -93,6 +102,7 @@ Can be interfaced through `/render-api` | includeTags | number (boolean) | 0 | false | Includes problem tags in the returned JSON | Only relevant when requesting `format: 'json'` | ## Output Format + | Key | Description | | ----- | ----- | | static | zero buttons, locked form fields (read-only) | @@ -103,16 +113,16 @@ Can be interfaced through `/render-api` | practice | check answers + show answers buttons | ## Permission level + | Key | Value | | --- | ----- | | student | 0 | | prof | 10 | | admin | 20 | -## Permission logic summary for hints and solutions -* If `permissionLevel >= 10`, then hints and solutions will be rendered - no exceptions. -* If `permissionLevel < 10`, then: - - solutions (if they are provided in the pg source code) will be rendered if and only if `showSolutions` is true. - - hints (if they are provided in the pg source code) will be rendered if and only if: - + `showHints` is true, and - + `numCorrect + numIncorrect > n` where `n` is set by the pg sourcce code being rendered +## Permission logic summary + +* `permissionLevel` is ignored if `isInstructor` is directly set. +* If `permissionLevel >= 10`, then `isInstructor` will be set to true. +* If `permissionLevel < 10`, then `isInstructor` will be set to false. +* `permissionLevel` is not used to determine if hints or solutions are shown. diff --git a/conf/pg_config.yml b/conf/pg_config.yml new file mode 100644 index 000000000..bc55b7ecd --- /dev/null +++ b/conf/pg_config.yml @@ -0,0 +1,264 @@ +# Configuration options needed by PG. + +# You should not edit pg_config.dist.yml directly. Copy pg_config.dist.yml file to pg_config.yml and make changes to +# that file. + +# $pg_root may be used in values and will be replaced with the pg root directory set from the PG_ROOT environment +# variable. + +# $render_root may be used in values and will be replaced with the renderer root directory set from the RENDER_ROOT +# environment variable. + +# $OPL_dir may be used in values and will be replaced with the value of the directories OPL setting below. +# $Contrib_dir may be used in values and will be replaced with the value of the directories Contrib setting below. +# $pg_root_url may be used in values and will be replaced with the value of the URLs html setting below. + +directories: + # The OPL and Contrib directories. + OPL: $render_root/Library + Contrib: $render_root/Contrib + + # The root PG location. This will be set from the PG_ROOT environment variable, but can be overriden here. + root: $pg_root + + # Global temporary directory. This location must be writable. + tmp: $render_root/tmp + + # Public html location containing the PG javascript, css, and help files. + html: $pg_root/htdocs + + # Temporary directory from which generated files will be served. This location must be writable. + html_temp: $render_root/tmp + + # Directory from which WeBWorK::PG::IO allows files to be read. + permitted_read_dir: $render_root + + # Location of cached equation images. + equationCache: $render_root/tmp/equations + + # The macro file search path. Each directory in this list is searched + # (in this order) by loadMacros when it looks for a .pl macro file. + macrosPath: + - . + - $pg_root/macros + - $OPL_dir/macros/Alfred + - $OPL_dir/macros/BrockPhysics + - $OPL_dir/macros/CollegeOfIdaho + - $OPL_dir/macros/Dartmouth + - $OPL_dir/macros/FortLewis + - $OPL_dir/macros/Hope + - $OPL_dir/macros/LaTech + - $OPL_dir/macros/MC + - $OPL_dir/macros/Michigan + - $OPL_dir/macros/Mizzou + - $OPL_dir/macros/NAU + - $OPL_dir/macros/PCC + - $OPL_dir/macros/TCNJ + - $OPL_dir/macros/UBC + - $OPL_dir/macros/UMass-Amherst + - $OPL_dir/macros/UW-Stout + - $OPL_dir/macros/UniSiegen + - $OPL_dir/macros/Union + - $OPL_dir/macros/WHFreeman + - $OPL_dir/macros/Wiley + - $Contrib_dir/CAPA/macros/CAPA_Tools + - $Contrib_dir/CAPA/macros/CAPA_MCTools + +URLs: + # The public URL of the html directory above. + html: $pg_root_url/pg_files + + # The public URL of the html_temp directory above. + tempURL: $pg_root_url/pg_files/tmp + + # The public URL of the PG help files. + localHelpURL: $pg_root_url/pg_files/helpFiles + + # URL of cached equation images. + equationCache: $pg_root_url/pg_files/tmp/equations + + # Paths to search for auxiliary html files (requires full url). + htmlPath: + - . + - $pg_root_url/pg_files + + # Paths to search for image files (requires full url). + imagesPath: + - . + - $pg_root_url/pg_files/images + +# Flat-file database used to protect against MD5 hash collisions. TeX equations +# are hashed to determine the name of the image file. There is a tiny chance of +# a collision between two TeX strings. This file allows for that. However, this +# is slow, so most people chose not to worry about it. Set this to '' if you +# don't want to use the equation cache file. +equationCacheDB: '' + +externalPrograms: + curl: /usr/bin/curl + cp: /bin/cp + mv: /bin/mv + rm: /bin/rm + tar: /bin/tar + latex: /usr/bin/latex --no-shell-escape + pdflatex: /usr/bin/pdflatex --no-shell-escape + dvisvgm: /usr/bin/dvisvgm + pdf2svg: /usr/bin/pdf2svg + convert: /usr/bin/convert + dvipng: /usr/bin/dvipng + +specialPGEnvironmentVars: + # switch to remove explanation essay block from questions that have one + waiveExplanations: 0 + + # To disable the Parser-based versions of num_cmp and fun_cmp, and use the + # original versions instead, set this value to 1. + useOldAnswerMacros: 0 + + # Determines whether or not MathObjects contexts will parse the alternative tokens + # listed in the "alternatives" property (mostly for unicode alternatives for parse tokens). + parseAlternatives: 0 + + # Determines whether or not the MathObjects parser will convert the Full Width Unicode block + # (U+FF01 to U+FF5E) to their corresponding ASCII characters (U+0021 to U+007E) automatically. + convertFullWidthCharacters: 0 + + # Binary that the PGtikz.pl and PGlateximage.pl macros will use to create svg images. + # This should be either 'pdf2svg' or 'dvipdfm'. + latexImageSVGMethod: pdf2svg + + # When ImageMagick is used for image conversions, this sets the default options. + # See https://imagemagick.org/script/convert.php for a full list of options. + # convert will be called as: + # convert file.ext1 file.ext2 + latexImageConvertOptions: + input: + density: 300 + output: + quality: 100 + + # Strings to insert at the start and end of the body of a problem. + problemPreamble: + TeX: '' + HTML: '' + problemPostamble: + TeX: '' + HTML: '' + + # Math entry assistance + entryAssist: MathQuill + + # Whether to use javascript for rendering Live3D graphs. + use_javascript_for_live3d: 1 + + # Size in pixels of dynamically-generated images, i.e. graphs. + onTheFlyImageSize: 400 + + # Locations of CAPA resources. (Only necessary if you need to use converted CAPA problems.) + CAPA_Tools: $Contrib_dir/CAPA/macros/CAPA_Tools/ + CAPA_MCTools: $Contrib_dir/Contrib/CAPA/macros/CAPA_MCTools/ + CAPA_GraphicsDirectory: $Contrib_dir/Contrib/CAPA/CAPA_Graphics/ + CAPA_Graphics_URL: $pg_root_url/pg_files/CAPA_Graphics/ + +# Answer evaluatior defaults +ansEvalDefaults: + functAbsTolDefault: 0.001 + functLLimitDefault: 0.0000001 + functMaxConstantOfIntegration: 1E8 + functNumOfPoints: 3 + functRelPercentTolDefault: 0.1 + functULimitDefault: 0.9999999 + functVarDefault: x + functZeroLevelDefault: 1E-14 + functZeroLevelTolDefault: 1E-12 + numAbsTolDefault: 0.001 + numFormatDefault: '' + numRelPercentTolDefault: 0.1 + numZeroLevelDefault: 1E-14 + numZeroLevelTolDefault: 1E-12 + useBaseTenLog: 0 + defaultDisplayMatrixStyle: '[s]' # left delimiter, middle line delimiters, right delimiter + +options: + # The default grader to use, if a problem doesn't specify. + grader: avg_problem_grader + + # Note that the first of useMathQuill, useMathView, and useWirisEditor that is set (in that order) to 1 will be used. + + # Set to 1 use MathQuill in answer boxes. + useMathQuill: 1 + + # Set to 1 to use the MathView preview system with answer boxes. + useMathView: 0 + + # This is the operations file to use for mathview, each contains a different locale. + mathViewLocale: mv_locale_us.js + + # Set to 1 to show the WirisEditor preview system. + useWirisEditor: 0 + + # Catch translation warnings internally. + catchWarnings: 1 + +# "images" mode has several settings: +displayModeOptions: + images: + # Determines the method used to align images in output. Can be any valid value for the css vertical-align rule such + # as 'baseline' or 'middle'. + dvipng_align: baseline + + # If dbsource is set to a nonempty value, then this database connection information will be used to store depths. + # It is assumed that the 'depths' table exists in the database. + dvipng_depth_db: + dbsource: '' + user: '' + passwd: '' + +# PG modules to load +# The first item of each list is the module to load. The remaining items are additional packages to import. +# That is: If you wish to include a module MyModule.pm which depends on additional modules Dependency1.pm and +# Dependency2.pm, these should appear as [Mymodule, Dependency1, Dependency2] +modules: + - [Encode] + - ['Encode::Encoding'] + - ['HTML::Parser'] + - ['HTML::Entities'] + - [DynaLoader] + - [Encode] + - [Exporter] + - [GD] + - [AlgParser, AlgParserWithImplicitExpand, Expr, ExprWithImplicitExpand, utf8] + - [AnswerHash, AnswerEvaluator] + - [LaTeXImage] + - [WWPlot] # required by Circle (and others) + - [Circle] + - ['Class::Accessor'] + - [Complex] + - [Complex1] + - [Distributions] + - [Fraction] + - [Fun] + - [Hermite] + - [Label] + - [ChoiceList] + - [Match] + - [MatrixReal1] # required by Matrix + - [Matrix] + - [Multiple] + - [PGrandom] + - [Regression] + - [Select] + - [Units] + - [VectorField] + - [Parser, Value] + - ['Parser::Legacy'] + - [Statistics] + - [Chromatic] # for Northern Arizona graph problems + - [Applet, GeogebraWebApplet] + - [PGcore, PGalias, PGresource, PGloadfiles, PGanswergroup, PGresponsegroup, 'Tie::IxHash'] + - ['Locale::Maketext'] + - [JSON] + - [Rserve, 'Class::Tiny', 'IO::Handle'] + - [DragNDrop] + - ['Types::Serialiser'] + - ['WeBWorK::Localize'] diff --git a/docs/make_translation_files.md b/docs/make_translation_files.md index b59723d9a..a31d5ac9f 100644 --- a/docs/make_translation_files.md +++ b/docs/make_translation_files.md @@ -1,16 +1,18 @@ +# How to generate translation files - Go to the location under which the renderer was installed. - You need to have `xgettext.pl` installed. +- This assumes that you are starting in the directory of the renderer clone. -``` -cd container/lib -xgettext.pl -o WeBWorK/lib/WeBWorK/Localize/standalone.pot -D PG/lib -D PG/macros -D RenderApp -D WeBWorK/lib RenderApp.pm +```bash +cd lib +xgettext.pl -o WeBWorK/Localize/standalone.pot -D PG/lib -D PG/macros -D RenderApp -D WeBWorK RenderApp.pm ``` - That creates the POT file of all strings found -``` -cd WeBWorK/lib/WeBWorK/Localize +```bash +cd WeBWorK/Localize find . -name '*.po' -exec bash -c "echo \"Updating {}\"; msgmerge -qUN {} standalone.pot" \; ``` diff --git a/lib/PG b/lib/PG index d242aab31..201843acf 160000 --- a/lib/PG +++ b/lib/PG @@ -1 +1 @@ -Subproject commit d242aab3175b905a9b428789bf720efe1c75ee3f +Subproject commit 201843acf9761295ae13184748889d829037c2e8 diff --git a/lib/RenderApp.pm b/lib/RenderApp.pm index 28e93b946..02e88b2cc 100644 --- a/lib/RenderApp.pm +++ b/lib/RenderApp.pm @@ -9,23 +9,13 @@ BEGIN { $ENV{RENDER_ROOT} = $main::dirname->dirname unless ( defined( $ENV{RENDER_ROOT} ) ); - # WEBWORK_ROOT is required for PG/lib/WeBWorK/IO. - # PG_ROOT is required for PG/lib/PGEnvironment.pm. - # These are hardcoded to avoid conflict with environment variables for webwork2. - # There is no need for these to be configurable. - $ENV{WEBWORK_ROOT} = $main::dirname . '/WeBWorK'; + # PG_ROOT is required for PG/lib/PGEnvironment.pm, FormatRenderedProblem.pm, and RenderProblem.pm. + # This is hardcoded to avoid conflict with the environment variable for webwork2. + # There is no need for this to be configurable. $ENV{PG_ROOT} = $main::dirname . '/PG'; - # Used for reconstructing library paths from sym-links. - $ENV{OPL_DIRECTORY} = "webwork-open-problem-library"; - $WeBWorK::Constants::WEBWORK_DIRECTORY = $main::dirname . "/WeBWorK"; - $WeBWorK::Constants::PG_DIRECTORY = $main::dirname . "/PG"; - unless ( -r $WeBWorK::Constants::WEBWORK_DIRECTORY ) { - die "Cannot read webwork root directory at $WeBWorK::Constants::WEBWORK_DIRECTORY"; - } - unless ( -r $WeBWorK::Constants::PG_DIRECTORY ) { - die "Cannot read webwork pg directory at $WeBWorK::Constants::PG_DIRECTORY"; - } + # Used for reconstructing library paths from sym-links. + $ENV{OPL_DIRECTORY} = "webwork-open-problem-library"; $ENV{MOJO_CONFIG} = (-r "$ENV{RENDER_ROOT}/render_app.conf") ? "$ENV{RENDER_ROOT}/render_app.conf" : "$ENV{RENDER_ROOT}/render_app.conf.dist"; # $ENV{MOJO_MODE} = 'production'; @@ -112,8 +102,8 @@ sub startup { } # Static file routes - $r->any('/webwork2_files/CAPA_Graphics/*static')->to('StaticFiles#CAPA_graphics_file'); - $r->any('/webwork2_files/tmp/*static')->to('StaticFiles#temp_file'); + $r->any('/pg_files/CAPA_Graphics/*static')->to('StaticFiles#CAPA_graphics_file'); + $r->any('/pg_files/tmp/*static')->to('StaticFiles#temp_file'); $r->any('/pg_files/*static')->to('StaticFiles#pg_file'); # any other requests fall through diff --git a/lib/RenderApp/Controller/FormatRenderedProblem.pm b/lib/RenderApp/Controller/FormatRenderedProblem.pm index c9b8ff566..777bc3e2e 100755 --- a/lib/RenderApp/Controller/FormatRenderedProblem.pm +++ b/lib/RenderApp/Controller/FormatRenderedProblem.pm @@ -27,11 +27,10 @@ package RenderApp::Controller::FormatRenderedProblem; use warnings; use strict; -use lib "$WeBWorK::Constants::WEBWORK_DIRECTORY/lib"; -use lib "$WeBWorK::Constants::PG_DIRECTORY/lib"; +use lib "$ENV{PG_ROOT}/lib"; + use MIME::Base64 qw( encode_base64 decode_base64); use WeBWorK::Utils::AttemptsTable; #import from ww2 -use WeBWorK::PG::ImageGenerator; # import from ww2 use WeBWorK::Utils::LanguageAndDirection; use WeBWorK::Utils qw(wwRound getAssetURL); # required for score summary use WeBWorK::Localize ; # for maketext @@ -60,6 +59,7 @@ sub new { userID => 'bar', # optional? course_password => 'baz', inputs_ref => {}, + problem_seed => 6666, @_, }; bless $self, $class; @@ -119,7 +119,7 @@ sub formatRenderedProblem { if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ $warnings = "

WARNINGS

" - . Encode::decode("UTF-8", decode_base64($rh_result->{WARNINGS}) ) + . $rh_result->{WARNINGS} . "

"; } #warn "keys: ", join(" | ", sort keys %{$rh_result }); @@ -152,34 +152,28 @@ sub formatRenderedProblem { ################################################# - my $XML_URL = $self->url // ''; - my $FORM_ACTION_URL = $self->{form_action_url} // ''; - my $SITE_URL = $self->{baseURL} // ''; - my $SITE_HOST = $ENV{SITE_HOST} // ''; - my $courseID = $self->{courseID} // ''; - my $userID = $self->{userID} // ''; - my $course_password = $self->{course_password} // ''; - my $session_key = $rh_result->{session_key} // ''; + my $XML_URL = $self->url // ''; + my $FORM_ACTION_URL = $self->{form_action_url} // ''; + my $SITE_URL = $self->{baseURL} // ''; + my $SITE_HOST = $ENV{SITE_HOST} // ''; + my $courseID = $self->{courseID} // ''; + my $userID = $self->{userID} // ''; + my $course_password = $self->{course_password} // ''; + my $problemSeed = $self->{problem_seed}; + my $psvn = $self->{inputs_ref}{psvn} // 54321; my $displayMode = $self->{inputs_ref}{displayMode} // 'MathJax'; my $problemJWT = $self->{inputs_ref}{problemJWT} // ''; my $sessionJWT = $self->{return_object}{sessionJWT} // ''; - my $webwork_htdocs_url = $self->{ce}{webworkURLs}{htdocs}; - my $previewMode = defined( $self->{inputs_ref}{previewAnswers} ) || 0; my $checkMode = defined( $self->{inputs_ref}{checkAnswers} ) || 0; my $submitMode = defined( $self->{inputs_ref}{submitAnswers} ) || 0; my $showCorrectMode = defined( $self->{inputs_ref}{showCorrectAnswers} ) || 0; - # use Data::Dumper; - # print Dumper($self->{inputs_ref}); - - # problemIdentifierPrefix can be added to the request as a parameter. - # It adds a prefix to the - # identifier used by the format so that several different problems + # problemUUID can be added to the request as a parameter. It adds a prefix + # to the identifier used by the format so that several different problems # can appear on the same page. - my $problemIdentifierPrefix = - $self->{inputs_ref}->{problemIdentifierPrefix} // ''; + my $problemUUID = $self->{inputs_ref}{problemUUID} // 1; my $problemResult = $rh_result->{problem_result} // ''; my $problemState = $rh_result->{problem_state} // ''; my $showPartialCorrectAnswers = $self->{inputs_ref}{showPartialCorrectAnswers} @@ -202,8 +196,6 @@ sub formatRenderedProblem { answersSubmitted => $self->{inputs_ref}{answersSubmitted}//0, answerOrder => $answerOrder//[], displayMode => $self->{inputs_ref}{displayMode}, - imgGen => undef, # $imgGen, - ce => '', #used only to build the imgGen showAnswerNumbers => 0, showAttemptAnswers => 0, showAttemptPreviews => ($previewMode or $submitMode or $showCorrectMode), @@ -216,7 +208,7 @@ sub formatRenderedProblem { ); my $answerTemplate = $tbl->answerTemplate; - $tbl->imgGen->render(refresh => 1) if $tbl->displayMode eq 'images'; + $tbl->imgGen->render(body_text => \$answerTemplate) if $tbl->displayMode eq 'images'; # warn "imgGen is ", $tbl->imgGen; #warn "answerOrder ", $tbl->answerOrder; @@ -264,13 +256,9 @@ sub formatRenderedProblem { } # Add CSS files requested by problems via ADD_CSS_FILE() in the PG file - # or via a setting of $self->{ce}{pg}{specialPGEnvironmentVars}{extra_css_files} # (the value should be an anonomous array). my $extra_css_files = ''; my @cssFiles; - if (ref($self->{ce}{pg}{specialPGEnvironmentVars}{extra_css_files}) eq 'ARRAY') { - push(@cssFiles, { file => $_, external => 0 }) for @{ $self->{ce}{pg}{specialPGEnvironmentVars}{extra_css_files} }; - } if (ref($rh_result->{flags}{extra_css_files}) eq 'ARRAY') { push @cssFiles, @{ $rh_result->{flags}{extra_css_files} }; } diff --git a/lib/RenderApp/Controller/RenderProblem.pm b/lib/RenderApp/Controller/RenderProblem.pm index 8c165ea8e..04dc4001e 100644 --- a/lib/RenderApp/Controller/RenderProblem.pm +++ b/lib/RenderApp/Controller/RenderProblem.pm @@ -1,10 +1,8 @@ -#/usr/bin/perl -w +package RenderApp::Controller::RenderProblem; use strict; use warnings; -package RenderApp::Controller::RenderProblem; - use Time::HiRes qw/time/; use Date::Format; use MIME::Base64 qw(encode_base64 decode_base64); @@ -20,13 +18,12 @@ use JSON::XS; use Crypt::JWT qw( encode_jwt ); use Digest::MD5 qw( md5_hex ); -use lib "$WeBWorK::Constants::WEBWORK_DIRECTORY/lib"; -use lib "$WeBWorK::Constants::PG_DIRECTORY/lib"; +use lib "$ENV{PG_ROOT}/lib"; use Proc::ProcessTable; # use for log memory use -use WeBWorK::PG; #webwork2 (use to set up environment) -use WeBWorK::CourseEnvironment; +use WeBWorK::PG; use WeBWorK::Utils::Tags; +use WeBWorK::Localize; use RenderApp::Controller::FormatRenderedProblem; use 5.10.0; @@ -81,14 +78,11 @@ sub process_pg_file { my $problem = shift; my $inputHash = shift; - our $seed_ce = create_course_environment(); - - my $file_path = $problem->path; + my $file_path = $problem->path; my $problem_seed = $problem->seed || '666'; # just make sure we have the fundamentals covered... - $inputHash->{displayMode} = - 'MathJax'; # is there any reason for this to be anything else? + $inputHash->{displayMode} //= 'MathJax'; $inputHash->{sourceFilePath} ||= $file_path; $inputHash->{outputFormat} ||= 'static'; $inputHash->{language} ||= 'en'; @@ -107,7 +101,7 @@ sub process_pg_file { time; # this is Time::HiRes's time, which gives floating point values my ( $error_flag, $formatter, $error_string ) = - process_problem( $seed_ce, $file_path, $inputHash ); + process_problem( $file_path, $inputHash ); my $pg_stop = time; my $pg_duration = $pg_stop - $pg_start; @@ -119,7 +113,7 @@ sub process_pg_file { renderedHTML => $html, answers => $pg_obj->{answers}, debug => { - perl_warn => Encode::decode("UTF-8", decode_base64( $pg_obj->{WARNINGS} ) ), + perl_warn => $pg_obj->{WARNINGS}, pg_warn => $pg_obj->{warning_messages}, debug => $pg_obj->{debug_messages}, internal => $pg_obj->{internal_debug_messages} @@ -162,7 +156,6 @@ sub process_pg_file { ####################################################################### sub process_problem { - my $ce = shift; my $file_path = shift; my $inputs_ref = shift; my $adj_file_path; @@ -179,7 +172,6 @@ sub process_problem { my $problem_seed = $inputs_ref->{problemSeed}; die "problem seed not defined in Controller::RenderProblem::process_problem" unless $problem_seed; - my $display_mode = $inputs_ref->{displayMode}; # if base64 source is provided, use that over fetching problem path if ( $inputs_ref->{problemSource} && $inputs_ref->{problemSource} =~ m/\S/ ) @@ -248,8 +240,8 @@ sub process_problem { my $memory_use_start = get_current_process_memory(); - # can include @args as fourth input below - $return_object = standaloneRenderer( $ce, \$source, $inputs_ref ); + # can include @args as third input below + $return_object = standaloneRenderer( \$source, $inputs_ref ); # stash assets list in $return_object $return_object->{pgResources} = $pgResources; @@ -287,10 +279,6 @@ sub process_problem { # Create FormatRenderedProblems object ################################################## - # PG/macros/PG.pl wipes out problemSeed -- put it back! - # $inputs_ref->{problemSeed} = $problem_seed; # NO DONT - $inputs_ref->{displayMode} = $display_mode; - # my $encoded_source = encode_base64($source); # create encoding of source_file; my $formatter = RenderApp::Controller::FormatRenderedProblem->new( return_object => $return_object, @@ -303,7 +291,7 @@ sub process_problem { userID => 'Motoko_Kusanagi', course_password => 'daemon', inputs_ref => $inputs_ref, - ce => $ce, + problem_seed => $problem_seed ); ################################################## @@ -335,89 +323,57 @@ sub process_problem { ########################################### sub standaloneRenderer { - - #print "entering standaloneRenderer\n\n"; - my $ce = shift; my $problemFile = shift // ''; - my $inputs_ref = shift // ''; + my $inputs_ref = shift // {}; my %args = @_; - # my $key = $r->param('key'); - # WTF is this even here for? PG doesn't do authz - but it wants key? - my $key = '3211234567654321'; - - my $user = fake_user(); - my $set = fake_set(); - my $showHints = $inputs_ref->{showHints} // 1; # default is to showHint if neither showHints nor numIncorrect is provided - my $showSolutions = $inputs_ref->{showSolutions} // 0; - my $problemNumber = $inputs_ref->{problemNumber} // 1; # ever even relevant? - my $displayMode = $inputs_ref->{displayMode} || 'MathJax'; # $ce->{pg}->{options}->{displayMode}; - my $problem_seed = $inputs_ref->{problemSeed} || 1234; - my $permission_level = $inputs_ref->{permissionLevel} || 0; # permissionLevel >= 10 will show hints, solutions + open all scaffold - my $num_correct = $inputs_ref->{numCorrect} || 0; # consider replacing - this may never be relevant... - my $num_incorrect = $inputs_ref->{numIncorrect} // 1000; # default to exceed any problem's showHint threshold unless provided - my $processAnswers = $inputs_ref->{processAnswers} // 1; # default to 1, explicitly avoid generating answer components - my $psvn = $inputs_ref->{psvn} // 123; # by request from Tani - + # default to 1, explicitly avoid generating answer components + my $processAnswers = $inputs_ref->{processAnswers} // 1; print "NOT PROCESSING ANSWERS" unless $processAnswers == 1; - my $translationOptions = { - displayMode => $displayMode, - showHints => $showHints, - showSolutions => $showSolutions, - refreshMath2img => 1, - processAnswers => $processAnswers, - QUIZ_PREFIX => $inputs_ref->{answerPrefix} // '', - useMathQuill => !defined $inputs_ref->{entryAssist} || $inputs_ref->{entryAssist} eq 'MathQuill' ? 1 : 0, - - #use_site_prefix => 'http://localhost:3000', - use_opaque_prefix => 0, - permissionLevel => $permission_level, - effectivePermissionLevel => $permission_level - }; - my $extras = {}; # passed as arg to renderer->new() - - # Create template of problem then add source text or a path to the source file - local $ce->{pg}{specialPGEnvironmentVars}{problemPreamble} = - { TeX => '', HTML => '' }; - local $ce->{pg}{specialPGEnvironmentVars}{problemPostamble} = - { TeX => '', HTML => '' }; - - my $problem = fake_problem(); # eliminated $db arg - $problem->{problem_seed} = $problem_seed; - $problem->{value} = -1; - $problem->{num_correct} = $num_correct; - $problem->{num_incorrect} = $num_incorrect; - $problem->{attempted} = $num_correct + $num_incorrect; - - if ( ref $problemFile ) { - $problem->{source_file} = $inputs_ref->{sourceFilePath}; - $translationOptions->{r_source} = $problemFile; - - # warn "standaloneProblemRenderer: setting source_file = $problemFile"; + unless (ref $problemFile) { + # In this case the source file name is passed + print "standaloneProblemRenderer: setting source_file = $problemFile"; } - else { - #in this case the actual source is passed - $problem->{source_file} = $problemFile; - warn "standaloneProblemRenderer: setting source_file = $problemFile"; - # a path to the problem (relative to the course template directory?) - } - - my $pg = WeBWorK::PG->new( - $ce, - $user, - $key, - $set, - $problem, - $psvn, # by request from Tani - $inputs_ref, - $translationOptions, - $extras, - ); + # Attempt to match old parameters. + my $isInstructor = $inputs_ref->{isInstructor} // ($inputs_ref->{permissionLevel} // 0) >= 10; + + my $pg = WeBWorK::PG->new( + ref $problemFile + ? ( + sourceFilePath => $inputs_ref->{sourceFilePath} // '', + r_source => $problemFile, + ) + : (sourceFilePath => $problemFile), + problemSeed => $inputs_ref->{problemSeed}, + processAnswers => $processAnswers, + showHints => $inputs_ref->{showHints}, # default is to showHint (set in PG.pm) + showSolutions => $inputs_ref->{showSolutions}, + problemNumber => $inputs_ref->{problemNumber}, # ever even relevant? + num_of_correct_ans => $inputs_ref->{numCorrect} || 0, + num_of_incorrect_ans => $inputs_ref->{numIncorrect} // 1000, + displayMode => $inputs_ref->{displayMode}, + useMathQuill => !defined $inputs_ref->{entryAssist} || $inputs_ref->{entryAssist} eq 'MathQuill', + answerPrefix => $inputs_ref->{answerPrefix}, + isInstructor => $isInstructor, + forceScaffoldsOpen => $inputs_ref->{forceScaffoldsOpen}, + psvn => $inputs_ref->{psvn}, + problemUUID => $inputs_ref->{problemUUID}, + language => $inputs_ref->{language} // 'en', + language_subroutine => WeBWorK::Localize::getLoc($inputs_ref->{language} // 'en'), + inputs_ref => {%$inputs_ref}, # Copy the inputs ref so the original can be relied on after rendering. + templateDirectory => "$ENV{RENDER_ROOT}/", + debuggingOptions => { + show_resource_info => $inputs_ref->{show_resource_info}, + view_problem_debugging_info => $inputs_ref->{view_problem_debugging_info} // $isInstructor, + show_pg_info => $inputs_ref->{show_pg_info}, + show_answer_hash_info => $inputs_ref->{show_answer_hash_info}, + show_answer_group_info => $inputs_ref->{show_answer_group_info} + } + ); # new version of output: - my $warning_messages = ''; # for now -- set up warning trap later my ( $internal_debug_messages, $pgwarning_messages, $pgdebug_messages ); if ( ref( $pg->{pgcore} ) ) { $internal_debug_messages = $pg->{pgcore}->get_internal_debug_messages; @@ -435,7 +391,7 @@ sub standaloneRenderer { post_header_text => $pg->{post_header_text}, answers => $pg->{answers}, errors => $pg->{errors}, - WARNINGS => encode_base64( Encode::encode("UTF-8", $pg->{warnings} ) ), + WARNINGS => $pg->{warnings}, PG_ANSWERS_HASH => $pg->{pgcore}->{PG_ANSWERS_HASH}, problem_result => $pg->{result}, problem_state => $pg->{state}, @@ -522,57 +478,6 @@ sub generateJWTs { return ($sessionJWT, $answerJWT); } -sub fake_user { - my $user = { - user_id => 'Motoko_Kusanagi', - first_name => 'Motoko', - last_name => 'Kusanagi', - email_address => 'motoko.kusanagi@npsc.go.jp', - student_id => '123456789', - section => '9', - recitation => '', - comment => '', - }; - return ($user); -} - -sub fake_problem { - my $problem = { - set_id => 'Section_9', - problem_id => 1, - value => 1, - max_attempts => -1, - showMeAnother => -1, - showMeAnotherCount => 0, - problem_seed => 666, - status => 0, - sub_status => 0, - attempted => 0, - last_answer => '', - num_correct => 0, - num_incorrect => 0, - prCount => -10 - }; - - return ($problem); -} - -sub fake_set { - - # my $db = shift; - - my $set = {}; - $set->{psvn} = 666; - $set->{set_id} = "Section_9"; - $set->{open_date} = time(); - $set->{due_date} = time(); - $set->{answer_date} = time(); - $set->{visible} = 0; - $set->{enable_reduced_scoring} = 0; - $set->{hardcopy_header} = "defaultHeader"; - return ($set); -} - # Get problem template source and adjust file_path name sub get_source { my $file_path = shift; @@ -652,25 +557,11 @@ sub pretty_print_rh { return $out . " "; } -sub create_course_environment { - my $self = shift; - my $courseName = $self->{courseName} || 'renderer'; - my $ce = WeBWorK::CourseEnvironment->new( - { - webwork_dir => $ENV{WEBWORK_ROOT}, - courseName => $courseName - } - ); - warn "Unable to find environment for course: |$courseName|" unless ref($ce); - return ($ce); -} - sub writeRenderLogEntry($$$) { my ( $function, $details, $beginEnd ) = @_; $beginEnd = ( $beginEnd eq "begin" ) ? ">" : ( $beginEnd eq "end" ) ? "<" : "-"; -#writeLog($seed_ce, "render_timing", "$$ ".time." $beginEnd $function [$details]"); local *LOG; if ( open LOG, ">>", $path_to_log_file ) { print LOG "[", time2str( "%a %b %d %H:%M:%S %Y", time ), diff --git a/lib/RenderApp/Controller/StaticFiles.pm b/lib/RenderApp/Controller/StaticFiles.pm index 0554cdea2..faf8bea20 100644 --- a/lib/RenderApp/Controller/StaticFiles.pm +++ b/lib/RenderApp/Controller/StaticFiles.pm @@ -11,12 +11,12 @@ sub reply_with_file_if_readable ($c, $file) { } } -# Route requests for webwork2_files/CAPA_Graphics to render root Contrib/CAPA/CAPA_Graphics +# Route requests for pg_files/CAPA_Graphics to render root Contrib/CAPA/CAPA_Graphics sub CAPA_graphics_file ($c) { return $c->reply_with_file_if_readable($c->app->home->child('Contrib/CAPA/CAPA_Graphics', $c->stash('static'))); } -# Route requests for webwork2_files to the render root tmp. The +# Route requests for pg_files to the render root tmp. The # only requests should be for files in the temporary directory. # FIXME: Perhaps this directory should be configurable. sub temp_file ($c) { @@ -25,7 +25,7 @@ sub temp_file ($c) { # Route request to pg_files to lib/PG/htdocs. sub pg_file ($c) { - $c->reply_with_file_if_readable(path($WeBWorK::Constants::PG_DIRECTORY, 'htdocs', $c->stash('static'))); + $c->reply_with_file_if_readable(path($ENV{PG_ROOT}, 'htdocs', $c->stash('static'))); } 1; diff --git a/lib/RenderApp/Model/Problem.pm b/lib/RenderApp/Model/Problem.pm index 55bc24ed5..b435a29ac 100644 --- a/lib/RenderApp/Model/Problem.pm +++ b/lib/RenderApp/Model/Problem.pm @@ -162,7 +162,7 @@ sub save { my $self = shift; my $success = 0; my $write_path = - ( $self->{write_path} =~ /\S/ ) ? + ( $self->{write_path} =~ /\S/ ) ? $self->{write_path} : $self->{read_path}; diff --git a/lib/WeBWorK/lib/WeBWorK/Form.pm b/lib/WeBWorK/Form.pm similarity index 100% rename from lib/WeBWorK/lib/WeBWorK/Form.pm rename to lib/WeBWorK/Form.pm diff --git a/lib/WeBWorK/lib/WeBWorK/Localize.pm b/lib/WeBWorK/Localize.pm similarity index 91% rename from lib/WeBWorK/lib/WeBWorK/Localize.pm rename to lib/WeBWorK/Localize.pm index 4bed116cf..5805004f8 100644 --- a/lib/WeBWorK/lib/WeBWorK/Localize.pm +++ b/lib/WeBWorK/Localize.pm @@ -5,10 +5,10 @@ use File::Spec; use Locale::Maketext; use Locale::Maketext::Lexicon; -my $path = "$WeBWorK::Constants::WEBWORK_DIRECTORY/lib/WeBWorK/Localize"; -my $pattern = File::Spec->catfile($path, '*.[pm]o'); -my $decode = 1; -my $encoding = undef; +my $path = "$ENV{RENDER_ROOT}/lib/WeBWorK/Localize"; +my $pattern = File::Spec->catfile($path, '*.[pm]o'); +my $decode = 1; +my $encoding = undef; eval " package WeBWorK::Localize::I18N; diff --git a/lib/WeBWorK/lib/WeBWorK/Localize/en.po b/lib/WeBWorK/Localize/en.po similarity index 100% rename from lib/WeBWorK/lib/WeBWorK/Localize/en.po rename to lib/WeBWorK/Localize/en.po diff --git a/lib/WeBWorK/lib/WeBWorK/Localize/heb.po b/lib/WeBWorK/Localize/heb.po similarity index 100% rename from lib/WeBWorK/lib/WeBWorK/Localize/heb.po rename to lib/WeBWorK/Localize/heb.po diff --git a/lib/WeBWorK/lib/WeBWorK/Localize/standalone.pot b/lib/WeBWorK/Localize/standalone.pot similarity index 100% rename from lib/WeBWorK/lib/WeBWorK/Localize/standalone.pot rename to lib/WeBWorK/Localize/standalone.pot diff --git a/lib/WeBWorK/Utils.pm b/lib/WeBWorK/Utils.pm new file mode 100644 index 000000000..095e34a5e --- /dev/null +++ b/lib/WeBWorK/Utils.pm @@ -0,0 +1,84 @@ +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2022 The WeBWorK Project, https://github.com/openwebwork +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +package WeBWorK::Utils; +use base qw(Exporter); + +use strict; +use warnings; + +use JSON; + +our @EXPORT_OK = qw( + wwRound + getAssetURL +); + +# usage wwRound($places,$float) +# return $float rounded up to number of decimal places given by $places +sub wwRound(@) { + my $places = shift; + my $float = shift; + my $factor = 10**$places; + return int($float * $factor + 0.5) / $factor; +} + +my $staticPGAssets; + +# Get the url for static assets. +sub getAssetURL { + my ($language, $file, $isThemeFile) = @_; + + # Load the static files list generated by `npm install` the first time this method is called. + if (!$staticPGAssets) { + my $staticAssetsList = "$ENV{PG_ROOT}/htdocs/static-assets.json"; + if (-r $staticAssetsList) { + my $data = do { + open(my $fh, "<:encoding(UTF-8)", $staticAssetsList) + or die "FATAL: Unable to open '$staticAssetsList'!"; + local $/; + <$fh>; + }; + + $staticPGAssets = JSON->new->decode($data); + } else { + warn "ERROR: '$staticAssetsList' not found!\n" + . "You may need to run 'npm install' from '$ENV{PG_ROOT}/htdocs'."; + } + } + + # If a right-to-left language is enabled (Hebrew or Arabic) and this is a css file that is not a third party asset, + # then determine the rtl varaint file name. This will be looked for first in the asset lists. + my $rtlfile = $file =~ s/\.css$/.rtl.css/r + if ($language =~ /^(he|ar)/ && $file !~ /node_modules/ && $file =~ /\.css$/); + + # Now check to see if this is a file in the pg htdocs location with a rtl variant. + # These also can only be local files. + return "/pg_files/$staticPGAssets->{$rtlfile}" if defined $rtlfile && defined $staticPGAssets->{$rtlfile}; + + # Next check to see if this is a file in the pg htdocs location. + if (defined $staticPGAssets->{$file}) { + # File served by cdn. + return $staticPGAssets->{$file} if $staticPGAssets->{$file} =~ /^https?:\/\//; + # File served locally. + return "/pg_files/$staticPGAssets->{$file}"; + } + + # If the file was not found in the lists, then just use the given file and assume its path is relative to the pg + # htdocs location. + return "/pg_files/$file"; +} + +1; diff --git a/lib/WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm b/lib/WeBWorK/Utils/AttemptsTable.pm similarity index 94% rename from lib/WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm rename to lib/WeBWorK/Utils/AttemptsTable.pm index 7667777b3..344d7e6a8 100644 --- a/lib/WeBWorK/lib/WeBWorK/Utils/AttemptsTable.pm +++ b/lib/WeBWorK/Utils/AttemptsTable.pm @@ -146,8 +146,10 @@ use base qw(Class::Accessor); use strict; use warnings; + use Scalar::Util 'blessed'; use WeBWorK::Utils 'wwRound'; +use WeBWorK::PG::Environment; use CGI; # Object contains hash of answer results @@ -193,7 +195,7 @@ sub new { sub _init { # verify display mode - # build imgGen if it is not supplied + # build imgGen my $self = shift; my %options = @_; $self->{submitted}=$options{submitted}//0; @@ -207,30 +209,21 @@ sub _init { $self->{numBlanks}=0; $self->{numEssay}=0; - if ( $self->displayMode eq 'images') { - if ( blessed( $options{imgGen} ) ) { - $self->{imgGen} = $options{imgGen}; - } elsif ( blessed( $options{ce} ) ) { - warn "building imgGen"; - my $ce = $options{ce}; - my $site_url = $ce->{server_root_url}; - my %imagesModeOptions = %{$ce->{pg}->{displayModeOptions}->{images}}; - - my $imgGen = WeBWorK::PG::ImageGenerator->new( - tempDir => $ce->{webworkDirs}->{tmp}, - latex => $ce->{externalPrograms}->{latex}, - dvipng => $ce->{externalPrograms}->{dvipng}, - useCache => 1, - cacheDir => $ce->{webworkDirs}->{equationCache}, - cacheURL => $site_url.$ce->{webworkURLs}->{equationCache}, - cacheDB => $ce->{webworkFiles}->{equationCacheDB}, - dvipng_align => $imagesModeOptions{dvipng_align}, - dvipng_depth_db => $imagesModeOptions{dvipng_depth_db}, - ); - $self->{imgGen} = $imgGen; - } else { - warn "Must provide image Generator (imgGen) or a course environment (ce) to build attempts table."; - } + if ($self->displayMode eq 'images') { + my $pg_envir = WeBWorK::PG::Environment->new; + + $self->{imgGen} = WeBWorK::PG::ImageGenerator->new( + tempDir => $pg_envir->{directories}{tmp}, + latex => $pg_envir->{externalPrograms}{latex}, + dvipng => $pg_envir->{externalPrograms}{dvipng}, + useCache => 1, + cacheDir => $pg_envir->{directories}{equationCache}, + cacheURL => $pg_envir->{URLs}{equationCache}, + cacheDB => $pg_envir->{equationCacheDB}, + useMarkers => 1, + dvipng_align => $pg_envir->{displayModeOptions}{images}{dvipng_align}, + dvipng_depth_db => $pg_envir->{displayModeOptions}{images}{dvipng_depth_db}, + ); } } diff --git a/lib/WeBWorK/lib/WeBWorK/Utils/LanguageAndDirection.pm b/lib/WeBWorK/Utils/LanguageAndDirection.pm similarity index 99% rename from lib/WeBWorK/lib/WeBWorK/Utils/LanguageAndDirection.pm rename to lib/WeBWorK/Utils/LanguageAndDirection.pm index 8faf84a15..f0e8da8a1 100644 --- a/lib/WeBWorK/lib/WeBWorK/Utils/LanguageAndDirection.pm +++ b/lib/WeBWorK/Utils/LanguageAndDirection.pm @@ -38,12 +38,8 @@ language. use strict; use warnings; -use Carp; -use WeBWorK::PG; -use WeBWorK::Debug; our @EXPORT = qw(get_lang_and_dir get_problem_lang_and_dir); -our @EXPORT_OK = (); =head1 FUNCTIONS diff --git a/lib/WeBWorK/lib/WeBWorK/Utils/Tags.pm b/lib/WeBWorK/Utils/Tags.pm similarity index 100% rename from lib/WeBWorK/lib/WeBWorK/Utils/Tags.pm rename to lib/WeBWorK/Utils/Tags.pm diff --git a/lib/WeBWorK/conf/defaults.config b/lib/WeBWorK/conf/defaults.config deleted file mode 100644 index faa2ea1a2..000000000 --- a/lib/WeBWorK/conf/defaults.config +++ /dev/null @@ -1,2168 +0,0 @@ -#!perl -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2022 The WeBWorK Project, https://github.com/openwebwork -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -# This file is used to set up the default WeBWorK course environment for all -# requests. Values may be overwritten by the course.conf for a specific course. -# All package variables set in this file are added to the course environment. -# If you wish to set a variable here but omit it from the course environment, -# use the "my" keyword. The $webwork_dir variable is set in the WeBWorK Apache -# configuration file (webwork.apache-config) and is available for use here. In -# addition, the $courseName variable holds the name of the current course. - -# YOU SHOULD NOT NEED TO EDIT THIS FILE!! -# All site-specific settings such as file locations and web addresses are -# configured in site.conf. If you want to override any settings in this -# file, you can put a directive in localOverrides.conf. - -include("conf/site.conf"); - -################################################################################ -# site.conf should contain basic information about directories and URLs on -# your server -################################################################################ - -################################################################################ -# Mail Settings -################################################################################ - -# AllowedRecipients defines addresses that the PG system is allowed to send mail -# to. this prevents subtle PG exploits. This should be set in course.conf to the -# addresses of professors of each course. Sending mail from the PG system (i.e. -# questionaires, essay questions) will fail if this is not set somewhere (either -# here or in course.conf). -$mail{allowedRecipients} = [ - #'prof1@yourserver.yourdomain.edu', - #'prof2@yourserver.yourdomain.edu', -]; - -# By default, feedback is sent to all users who have permission to -# receive_feedback. If this list is non-empty, feedback is also sent to the -# addresses specified here. -# -# * If you want to disable feedback altogether, leave this empty and set -# submit_feedback => $nobody in %permissionLevels below. This will cause the -# feedback button to go away as well. -# -# * If you want to send email ONLY to addresses in this list, set -# receive_feedback => $nobody in %permissionLevels below. -# -# It's often useful to set this in the course.conf to change the behavior of -# feedback for a specific course. -# -# Items in this list may be bare addresses, or RFC822 mailboxes, like: -# 'Joe User ' -# The advantage of this form is that the resulting email will include the name -# of the recipient in the "To" field of the email. -# -$mail{feedbackRecipients} = [ - #'prof1@yourserver.yourdomain.edu', - #'prof2@yourserver.yourdomain.edu', -]; - -# Feedback subject line -- the following escape sequences are recognized: -# -# %c = course ID -# %u = user ID -# %s = set ID -# %p = problem ID -# %x = section -# %r = recitation -# %% = literal percent sign -# - -$mail{feedbackSubjectFormat} = "[WWfeedback] course:%c user:%u set:%s prob:%p sec:%x rec:%r"; - -# feedbackVerbosity: -# 0: send only the feedback comment and context link -# 1: as in 0, plus user, set, problem, and PG data -# 2: as in 1, plus the problem environment (debugging data) -$mail{feedbackVerbosity} = 1; - -# Should the studentID be included in the feedback email when feedbackVerbosity > 0: -# The default is yes -$blockStudentIDinFeedback = 0; - -# Defines the size of the Mail Merge editor window -# FIXME: should this be here? it's UI, not mail -# FIXME: replace this with the auto-size method that TWiki uses -$mail{editor_window_rows} = 15; -$mail{editor_window_columns} = 100; - -################################################################################## -# Customizing the action of the "Email your instructor" button -################################################################################## - -# Customizing the behavior for this button is best done by copying the lines below, entering them -# in the localOverrides.conf file and making the desired modifications. -# Then you will not need to update these modifications -# when you download a new version of WeBWorK. - -# Use this to customize the text of the feedback button. -$feedback_button_name = "Email Instructor"; - -# If this value is true, feedback will only be sent to users with the same -# section as the user initiating the feedback. -$feedback_by_section = 0; - -# If the variable below is set to a non-empty value (i.e. in course.conf), WeBWorK's usual -# email feedback mechanism will be replaced with a link to the given URL. -# See also $feedback_button_name, above. - -$courseURLs{feedbackURL} = ""; - -# If the variable below is set to a non-empty value (i.e. in course.conf), -# WeBWorK's usual email feedback mechanism will be replaced with a link to the given URL and -# a POST request with information about the problem including the HTML rendering -# of the problem will be sent to that URL. -# See also $feedback_button_name, above. - -#$courseURLs{feedbackFormURL} = "http://www.mathnerds.com/MathNerds/mmn/SDS/askQuestion.aspx"; #"http://www.tipjar.com/cgi-bin/test"; -$courseURLs{feedbackFormURL} = ""; - -################################################################################ -# Repository Information -################################################################################ -# This is where you put your remote and branch for your WeBWorK, PG and OPL -# github repositories. - -# Note: This process uses git ls-remote which can be very slow on some -# systems. If your course list page in the admin course is very slow -# consider disabling this option. - -$enableGitUpgradeNotifier = 0; - -$gitWeBWorKRemoteName = "origin"; -$gitWeBWorKBranchName = "main"; -$gitPGRemoteName = "origin"; -$gitPGBranchName = "main"; -$gitLibraryRemoteName = "origin"; -$gitLibraryBranchName = "main"; - -################################################################################ -# Theme -################################################################################ - -$defaultTheme = "math4"; -$defaultThemeTemplate = "system"; - -# The institution logo should be an image file in the theme's images folder -$institutionLogo = 'maa_logo.png'; -$institutionURL = 'http://www.maa.org'; -$institutionName = 'MAA (Mathematical Association of America)'; - -################################################################################ -# Hardcopy Theme -################################################################################ - -# Available Hardcopy themes (located in snippets) -# (their "internal" name and their pretty name for end users) -$hardcopyThemeNames = { - oneColumn => 'One Column', - twoColumn => 'Two Columns', - #XeLaTeX-oneColumn => 'English - one Column', - #XeLaTeX-twoColumn => 'English - two Columns', - #XeLaTeX-Hebrew-oneColumn => 'Hebrew/English - one Column', - #XeLaTeX-Hebrew-twoColumn => 'Hebrew/English - two Columns', -}; - -# This is needed to enforce an order that the options are presented when making a hardcopy -$hardcopyThemes = [ - 'oneColumn', - 'twoColumn', - #'XeLaTeX-oneColumn', - #'XeLaTeX-twoColumn', - #'XeLaTeX-Hebrew-oneColumn', - #'XeLaTeX-Hebrew-twoColumn', -]; - -# Default Hardcopy theme -$hardcopyTheme = "twoColumn"; - -################################################################################ -# Achievements -################################################################################ -$achievementsEnabled = 0; -$achievementItemsEnabled = 0; -$achievementPointsPerProblem = 5; -$achievementPreambleFile = "preamble.at"; - -################################################################################ -# Achievements -################################################################################ -$showCourseHomeworkTotals = 1; - -################################################################################ -# Editor -################################################################################ -$editor{author} = ''; -$editor{authorInstitute} = ''; -$editor{textTitle} = ''; -$editor{textEdition} = ''; -$editor{textAuthor} = ''; - -################################################################################ -# showMeAnother -################################################################################ -# switch to enable showMeAnother button -$pg{options}{enableShowMeAnother} = 0; -# default number of attempts before enabling show me another -$pg{options}{showMeAnotherDefault} = -1; -# maximum number of times (per problem) the button can be used -$pg{options}{showMeAnotherMaxReps} = 3; -# maximum number of attempts to check if changing the problem seed -# changes the problem -$pg{options}{showMeAnotherGeneratesDifferentProblem} = 5; -# showMeAnother options -$pg{options}{showMeAnother}=[ -"SMAcheckAnswers", -"SMAshowSolutions", -"SMAshowCorrect", -"SMAshowHints", -]; - -############################################################################### -# periodicRandomization -################################################################################ -# switch to enable periodic re-randomization -$pg{options}{enablePeriodicRandomization} = 0; -# course-wide default period for re-randomization, should be an integer -# the value of 0 disables re-randomization -$pg{options}{periodicRandomizationPeriod} = 5; -# Show the correct answer after a student's last attempt at the current version -# and before a new version is requested. -$pg{options}{showCorrectOnRandomize} = 0; - -################################################################################ -# Waive Explanations -################################################################################ -# switch to remove explanation essay block from questions that have one -$pg{specialPGEnvironmentVars}{waiveExplanations} = 0; - -################################################################################ -# Language -################################################################################ - -$language = "en"; # tr = turkish, en=english - -# $perProblemLangAndDirSettingMode controls how and whether LANG and/or DIR -# attributes are added to the DIV element enveloping a problem -# which helps handle proper display of problems with a text direction -# different from that used course-wide. Ex: enables English problems to -# be displayed properly in a Hebrew course site, which helps select problems -# to be translated to Hebrew. -$perProblemLangAndDirSettingMode = "force::ltr"; - -################################################################################ -# System-wide locations (directories and URLs) -################################################################################ - -# The root directory, set by webwork_root variable in Apache configuration. -$webworkDirs{root} = "$webwork_dir"; - -# Location of system-wide data files. -$webworkDirs{DATA} = "$webworkDirs{root}/DATA"; - -# Used for temporary storage of uploaded files. -$webworkDirs{uploadCache} = "$webworkDirs{DATA}/uploads"; - -# Location of utility programs. -$webworkDirs{bin} = "$webworkDirs{root}/bin"; - -# Location of configuration files, templates, snippets, etc. -$webworkDirs{conf} = "$webworkDirs{root}/conf"; - -# Location of course directories. -$webworkDirs{courses} = "$webwork_courses_dir" || "$webworkDirs{root}/courses"; - -# Contains log files. -$webworkDirs{logs} = "$ENV{RENDER_ROOT}/logs"; - -# Contains non-web-accessible temporary files, such as TeX working directories. -$webworkDirs{tmp} = "$ENV{RENDER_ROOT}/tmp"; - -# The (absolute) destinations of symbolic links that are OK for the FileManager to follow. -# (any subdirectory of these is a valid target for a symbolic link.) -# For example: -# $webworkDirs{valid_symlinks} = ["$webworkDirs{courses}/modelCourse/templates","/ww2/common/sets"]; -$webworkDirs{valid_symlinks} = []; - -# Location of the common tex input files packages.tex, CAPA.tex, and PGML.tex -# used for hardcopy generation. -$webworkDirs{texinputs_common} = "$webworkDirs{root}/conf/snippets/hardcopyThemes/common"; - -################################################################################ -##### The following locations are web-accessible. -################################################################################ - -# The root URL (usually /webwork2), set by in Apache configuration. -$webworkURLs{root} = "$webwork_url"; - -# Location of system-wide web-accessible files, such as equation images, and -# help files. -$webworkDirs{htdocs} = "$webwork_htdocs_dir" || "$ENV{RENDER_ROOT}/tmp"; -$webworkURLs{htdocs} = "$webwork_htdocs_url"; - -# Location of web-accessible temporary files, such as equation images. -# These two should be set in localOverrides.conf -- not here since this can be overwritten by new versions. -$webworkDirs{htdocs_temp} = "$ENV{RENDER_ROOT}/tmp"; -$webworkURLs{htdocs_temp} = "$webworkURLs{htdocs}/tmp"; - -# Location of cached equation images. -$webworkDirs{equationCache} = "$webworkDirs{htdocs_temp}/equations"; -$webworkURLs{equationCache} = "$webworkURLs{htdocs_temp}/equations"; - -# Contains context-sensitive help files. -$webworkDirs{local_help} = "$webworkDirs{htdocs}/helpFiles"; -$webworkURLs{local_help} = "$webworkURLs{htdocs}/helpFiles"; - -# Location of theme templates. -$webworkDirs{themes} = "$webworkDirs{htdocs}/themes"; - -# Location of localization directory. -$webworkDirs{localize} = "$webworkDirs{root}/lib/WeBWorK/Localize"; - -# URL of general WeBWorK documentation. -$webworkURLs{docs} = "https://webwork.maa.org"; - -# URL of WeBWorK Bugzilla database. -$webworkURLs{bugReporter} = "https://bugs.webwork.maa.org/enter_bug.cgi"; - -# URL of WeBWorK on GitHub -$webworkURLs{GitHub} = "https://github.com/openwebwork"; - -# Registration form URL, security signup mail address -$webworkURLs{serverRegForm} = "https://forms.gle/vrqpKiRHritnQNf37"; -$webworkURLs{wwSecurityAnnounce} = "https://groups.google.com/g/ww-security-announce"; -$webworkSecListManagers = 'ww-security-announce+managers@googlegroups.com'; - -# URLs in the Wiki -$webworkURLs{WikiMain} = "https://webwork.maa.org/wiki/"; -$webworkURLs{SiteMap} = "https://webwork.maa.org/wiki/WeBWorK_Sites"; - -#URL for help buttons on the PGProblemEditor pages: -$webworkURLs{problemTechniquesHelpURL}='https://webwork.maa.org/wiki/Category:Problem_Techniques'; -$webworkURLs{MathObjectsHelpURL} ='https://webwork.maa.org/wiki/Category:MathObjects'; -$webworkURLs{PODHelpURL} ='https://webwork.maa.org/pod/'; -$webworkURLs{PGLabHelpURL} ='https://demo.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/2?login_practice_user=true'; -$webworkURLs{PGMLHelpURL} ='https://demo.webwork.rochester.edu/webwork2/cervone_course/PGML/1?login_practice_user=true'; -$webworkURLs{AuthorHelpURL} ='https://webwork.maa.org/wiki/Category:Authors'; - -# Location of CSS -# $webworkURLs{stylesheet} = "$webworkURLs{htdocs}/css/${defaultTheme}.css"; -# this is never used -- changing the theme from the config panel -# doesn't appear to reset the theme in time? -# It's better to refer directly to the .css file in the system.template -# /css/math.css"/> - -################################################################################ -# Defaults for course-specific locations (directories and URLs) -################################################################################ - -# The root directory of the current course. (The ID of the current course is -# available in $courseName.) -$courseDirs{root} = "$webworkDirs{courses}/$courseName"; - -# Location of course-specific data files. -$courseDirs{DATA} = "$courseDirs{root}/DATA"; - -# Location of course HTML files, passed to PG. -$courseDirs{html} = "$courseDirs{root}/html"; -$courseURLs{html} = "$webwork_courses_url/$courseName"; - -# Location of course image files, passed to PG. -$courseDirs{html_images} = "$courseDirs{html}/images"; - -# Location of web-accessible, course-specific temporary files, like static and -# dynamically-generated PG graphics. -$courseDirs{html_temp} = "$webworkDirs{htdocs_temp}/$courseName"; -$courseURLs{html_temp} = "$webworkURLs{htdocs_temp}/$courseName"; - -# Location of course-specific logs, like the transaction log. -$courseDirs{logs} = "$courseDirs{root}/logs"; - -# Location of scoring files. -$courseDirs{scoring} = "$courseDirs{root}/scoring"; - -# Location of PG templates and set definition files. -$courseDirs{templates} = $ENV{RENDER_ROOT}; - -# Location of course achievement files. -$courseDirs{achievements} = "$courseDirs{templates}/achievements"; -$courseDirs{achievements_html} = "$courseDirs{html}/achievements"; #contains badge icons -$courseURLs{achievements} = "$courseURLs{html}/achievements"; - -# Location of course-specific macro files. -$courseDirs{macros} = "$courseDirs{templates}/macros"; - -# Location of mail-merge templates. -$courseDirs{email} = "$courseDirs{templates}/email"; - -# Location of temporary editing files. -$courseDirs{tmpEditFileDir} = "$courseDirs{templates}/tmpEdit"; - -# mail merge status directory -$courseDirs{mailmerge} = "$courseDirs{DATA}/mailmerge"; - -################################################################################ -# System-wide files -################################################################################ - -# Location of this file. -$webworkFiles{environment} = "$webworkDirs{conf}/defaults.conf"; - -# Flat-file database used to protect against MD5 hash collisions. TeX equations -# are hashed to determine the name of the image file. There is a tiny chance of -# a collision between two TeX strings. This file allows for that. However, this -# is slow, so most people chose not to worry about it. Set this to "" if you -# don't want to use the equation cache file. -$webworkFiles{equationCacheDB} = ""; # "$webworkDirs{DATA}/equationcache"; - -################################################################################ -# Hardcopy snippets are used in constructing a TeX file for hardcopy output. -# They should contain TeX code unless otherwise noted. -################################################################################ - -# The setHeader precedes each set in hardcopy output. It is a PG file. -# This is the default file which is used if a specific files is not selected -$webworkFiles{hardcopySnippets}{setHeader} = "$webworkDirs{conf}/snippets/ASimpleCombinedHeaderFile.pg"; - -################################################################################ -# In general the following files are determined by which hardcopy theme you -# are using however you can set these variables to override the theme settings. -# Note: These overrides are perminant across all themes. -################################################################################ - -# The preamble is the first thing in the TeX file. -#$webworkFiles{hardcopySnippets}{preamble} = "$webworkDirs{conf}/snippets/hardcopyPreamble.tex"; - -# The problem divider goes between problems. -#$webworkFiles{hardcopySnippets}{problemDivider} = "$webworkDirs{conf}/snippets/hardcopyProblemDivider.tex"; - -# The set footer goes after each set. Is is a PG file. -#$webworkFiles{hardcopySnippets}{setFooter} = "$webworkDirs{conf}/snippets/hardcopySetFooter.pg"; - -# The set divider goes between sets (in multiset output). -#$webworkFiles{hardcopySnippets}{setDivider} = "$webworkDirs{conf}/snippets/hardcopySetDivider.tex"; - -# The user divider does between users (in multiuser output). -#$webworkFiles{hardcopySnippets}{userDivider} = "$webworkDirs{conf}/snippets/hardcopyUserDivider.tex"; - -# The postamble is the last thing in the TeX file. -#$webworkFiles{hardcopySnippets}{postamble} = "$webworkDirs{conf}/snippets/hardcopyPostamble.tex"; - -################################################################################ -##### Screen snippets are used when displaying problem sets on the screen. -################################################################################ - -# The set header is displayed on the problem set page. It is a PG file. -# This is the default file which is used if a specific files is not selected -$webworkFiles{screenSnippets}{setHeader} = "$webworkDirs{conf}/snippets/ASimpleCombinedHeaderFile.pg"; - -# A PG template for creation of new problems. -$webworkFiles{screenSnippets}{blankProblem} = "$webworkDirs{conf}/snippets/blankProblem2.pg"; # screenSetHeader.pg" - -# A site info "message of the day" file -$webworkFiles{site_info} = "$webworkDirs{htdocs}/site_info.txt"; - -################################################################################ -# Course-specific files -################################################################################ - -# The course configuration file. -$courseFiles{environment} = "$courseDirs{root}/course.conf"; - -# The course simple configuration file (holds web-based configuration). -$courseFiles{simpleConfig} = "$courseDirs{root}/simple.conf"; - -# File contents are displayed after login, on the problem sets page. Path given -# here is relative to the templates directory. -$courseFiles{course_info} = "course_info.txt"; - -# File contents are displayed on the login page. Path given here is relative to -# the templates directory. -$courseFiles{login_info} = "login_info.txt"; - -# These course specific files cannot be edited from the File Manager for safety reasons except -# by an administrator. These are paths relative to the course directory. -$uneditableCourseFiles = [ - 'simple.conf', - 'course.conf', -]; - -# Additional library buttons can be added to the Library Browser (SetMaker.pm) -# by adding the libraries you want to the following line. For each key=>value -# in the list, if a directory (or link to a directory) with name 'key' appears -# in the templates directory, then a button with name 'value' will be placed at -# the top of the problem browser. (No button will appear if there is no -# directory or link with the given name in the templates directory.) For -# example, -# -# $courseFiles{problibs} = {rochester => "Rochester", asu => "ASU"}; -# -# would add two buttons, one for the Rochester library and one for the ASU -# library, provided templates/rochester and templates/asu exists either as -# subdirectories or links to other directories. The "OPL Directory" button -# activated below gives access to all the directories in the National -# Problem Library. -# -$courseFiles{problibs} = { - Library => "OPL Directory", - Contrib => "Contrib", # remember to create link from Contrib to Contrib - # library directory - capaLibrary => "CAPA", # remember to create link from capaLibrary to CAPA - # in contrib -}; - -################################################################################ -# Status system -################################################################################ - -# This is the default status given to new students and students with invalid -# or missing statuses. -$default_status = "Enrolled"; - -# The first abbreviation in the abbreviations list is the canonical -# abbreviation, and will be used when setting the status value in a user record -# or an exported classlist file. -# -# Results are undefined if more than one status has the same abbreviation. -# -# The four behaviors that are controlled by status are: -# allow_course_access => is this user allowed to log in? -# include_in_assignment => is this user included when assigning as set to "all" users? -# include_in_stats => is this user included in statistical reports? -# include_in_email => is this user included in emails sent to the class? -# include_in_scoring => is this user included in score reports? - -%statuses = ( - Enrolled => { - abbrevs => [qw/ C c current enrolled /], - behaviors => [qw/ allow_course_access include_in_assignment include_in_stats include_in_email include_in_scoring /], - }, - Audit => { - abbrevs => [qw/ A a audit /], - behaviors => [qw/ allow_course_access include_in_assignment include_in_stats include_in_email /], - }, - Drop => { - abbrevs => [qw/ D d drop withdraw /], - behaviors => [qw/ /], - }, - Proctor => { - abbrevs => [qw/ P p proctor /], - behaviors => [qw/ /], - }, -); - -################################################################################ -# Database options -################################################################################ - -# Database schemas are defined in the file conf/database.conf and stored in the -# hash %dbLayouts. The standard schema is called "sql_single"; - -# include( "./conf/database.conf.dist"); # always include database.conf.dist - - # in the rare case where you want local overrides - # you can place include("conf/database.conf") in - # the database.conf.dist file -# this change is meant to help alleviate the common mistake of forgetting to update the -# database.conf file when changing WW versions. - -# Select the default database layout. This can be overridden in the course.conf -# file of a particular course. The only database layout supported in WW 2.1.4 -# and up is "sql_single". -$dbLayoutName = "sql_single"; - -# This sets the symbol "dbLayout" as an alias for the selected database layout. -*dbLayout = $dbLayouts{$dbLayoutName}; - -# This sets the max course id length. It might need to be changed depending -# on what database tables are present. Mysql allows a max table length of 64 -# characters. With the ${course_id}_global_user_achievement table that means -# the max ${course_id} is exactly 40 characters. - -$maxCourseIdLength = 40; - -# Reference: https://dev.mysql.com/doc/refman/8.0/en/identifier-length.html - -################################################################################ -# Problem library options -################################################################################ -# -# The problemLibrary configuration data should now be set in localOverrides.conf - -# For configuration instructions, see: -# https://webwork.maa.org/wiki/Open_Problem_Library -# The directory containing the open problem library files. -# Set the root to "" if no problem - -#RE-CONFIGURE problemLibrary values in localOverrides.conf -# if these defaults are not correct. -################################################# -$problemLibrary{root} = "$ENV{RENDER_ROOT}/webwork-open-problem-library/OpenProblemLibrary"; -$contribLibrary{root} = "$ENV{RENDER_ROOT}/Contrib"; -$problemLibrary{version} = "2.5"; -########################################################### - -# Problem Library SQL database connection information -$problemLibrary_db = { - dbsource => $database_dsn, - user => $database_username, - passwd => $database_password, - storage_engine => 'MYISAM', -}; - -$problemLibrary{tree} = 'library-directory-tree.json'; - -# These flags control if statistics on opl problems are shown in the library -# browser. If you want to include local statistics you will need to -# run webwork2/bin/update-OPL-statistics on a regular basis. -$problemLibrary{showLibraryLocalStats} = 1; -# This flag controls whether global statistics will be displayed -$problemLibrary{showLibraryGlobalStats} = 1; - -################################################################################ -# Logs -################################################################################ - - -# Logs data about how long it takes to process problems. (Do not confuse this -# with the /other/ timing log which can be set by WeBWorK::Timing and is used -# for benchmarking system performance in general. At some point, this timing -# mechanism will be deprecated in favor of the WeBWorK::Timing mechanism.) -$webworkFiles{logs}{timing} = "$webworkDirs{logs}/timing.log"; - -# Logs data about how long it takes to process problems. (Do not confuse this -# with the /other/ timing log which can be set by WeBWorK::Timing and is used -# for benchmarking system performance in general. At some point, this timing -# mechanism will be deprecated in favor of the WeBWorK::Timing mechanism.) -$webworkFiles{logs}{render_timing} = "$webworkDirs{logs}/render_timing.log"; - -# Logs courses created via the web-based Course Administration module. -$webworkFiles{logs}{hosted_courses} = "$webworkDirs{logs}/hosted_courses.log"; - -# The transaction log contains data from each recorded answer submission. This -# is useful if the database becomes corrupted. -$webworkFiles{logs}{transaction} = "$webworkDirs{logs}/${courseName}_transaction.log"; - -# The answer log stores a history of all users' submitted answers. -$courseFiles{logs}{answer_log} = "$courseDirs{logs}/answer.log"; - -# Log logins. -$courseFiles{logs}{login_log} = "$courseDirs{logs}/login.log"; - -# Log for almost every click. By default it is the empty string, which -# turns this log off. If you want it turned on, we suggest -# "$courseDirs{logs}/activity.log" -# When turned on, this log can get quite large. -$courseFiles{logs}{activity_log} = ''; - -################################################################################ -# Site defaults (Usually overridden in localOverrides.conf) -################################################################################ - -# The default_templates_course is used by default to create a new course. -# The contents of the templates directory are copied from this course -# to the new course being created. -$siteDefaults{default_templates_course} ="modelCourse"; - -# Provide a list of model courses which are not real courses, but from which -# the templates for a new course can be copied. -$modelCoursesForCopy = [ "modelCourse" ]; - -################################################################################ -# Authentication system -################################################################################ - -# FIXME This mechanism is a little awkward and probably should be merged with -# the dblayout selection system somehow. - -# Select the authentication module to use for normal logins. -# -# If this value is a string, the given authentication module will be used -# regardless of the database layout. If it is a hash, the database layout name -# will be looked up in the hash and the resulting value will be used as the -# authentication module. The special hash key "*" is used if no entry for the -# current database layout is found. -# If this value is a sequence of strings or hashes, then each -# string or hash in the sequence will be successively tested to see if it -# provides a module that can handle -# the authentication request (by calling the module's -# sub request_has_data_for_this_verification_module ). -# The first module that responds affirmatively will be used. -# -# -$authen{user_module} = { - # sql_moodle => "WeBWorK::Authen::Moodle", - # sql_ldap => "WeBWorK::Authen::LDAP", - "*" => "WeBWorK::Authen::Basic_TheLastOption", -}; - -# Select the authentication module to use for proctor logins. -# -# A string or a hash is accepted, as above. -# -$authen{proctor_module} = "WeBWorK::Authen::Proctor"; -$authen{xmlrpc_module} = "WeBWorK::Authen::XMLRPC"; -################################################################################ -# Authorization system (Make local overrides in localOverrides.conf ) -################################################################################ - -# this section lets you define which groups of users can perform which actions. - -# this hash maps a numeric permission level to the name of a role. the number -# assigned to a role is significant -- roles with higher numbers are considered -# "more privileged", and are included when that role is listed for a privilege -# below. -# -%userRoles = ( - guest => -5, - student => 0, - login_proctor => 2, - grade_proctor => 3, - ta => 5, - professor => 10, - admin => 20, - nobody => 99999999, # insure that nobody comes at the end -); - -# this hash maps operations to the roles that are allowed to perform those -# operations. the role listed and any role with a higher permission level (in -# the %userRoles hash) will be allowed to perform the operation. If the role -# is undefined, no users will be allowed to perform the operation. -# -%permissionLevels = ( - login => "guest", - navigation_allowed => "guest", - report_bugs => "ta", - submit_feedback => "student", - change_password => "student", - change_email_address => "student", - change_pg_display_settings => "student", - - proctor_quiz_login => "login_proctor", - proctor_quiz_grade => "grade_proctor", - view_proctored_tests => "student", - view_hidden_work => "ta", - - view_multiple_sets => "ta", - view_unopened_sets => "ta", - view_hidden_sets => "ta", - view_answers => "ta", - view_ip_restricted_sets => "ta", - - become_student => "professor", - access_instructor_tools => "ta", - score_sets => "professor", - send_mail => "professor", - receive_feedback => "ta", - - create_and_delete_problem_sets => "professor", - assign_problem_sets => "professor", - modify_problem_sets => "professor", - modify_student_data => "professor", - modify_classlist_files => "professor", - modify_set_def_files => "professor", - modify_scoring_files => "professor", - modify_problem_template_files => "professor", - manage_course_files => "professor", - edit_achievements => "professor", - create_and_delete_courses => "professor", - fix_course_databases => "professor", - modify_tags => "admin", - edit_restricted_files => "admin", - - ##### Behavior of the interactive problem processor ##### - show_resource_info => "admin", - show_correct_answers_before_answer_date => "ta", - show_solutions_before_answer_date => "ta", - avoid_recording_answers => "nobody", # record the grade/status/state of everyone's entries. - # Setting this to "ta" would record grade/status/state - # for students but not TA's or professors; - # TA's and above could avoid having their answers recorded. - - # controls if old answers can be shown - can_show_old_answers => "student", - check_answers_before_open_date => "ta", - check_answers_after_open_date_with_attempts => "guest", - check_answers_after_open_date_without_attempts => "guest", - check_answers_after_due_date => "guest", - check_answers_after_answer_date => "guest", - can_check_and_submit_answers => "ta", - can_use_show_me_another_early => "ta", - create_new_set_version_when_acting_as_student => undef, - print_path_to_problem => "professor", # see "Special" PG environment variables - always_show_hint => "professor", # see "Special" PG environment variables - always_show_solution => "professor", # see "Special" PG environment variables - record_set_version_answers_when_acting_as_student => undef, - record_answers_when_acting_as_student => undef, - # "record_answers_when_acting_as_student" takes precedence - # over the following for professors acting as students: - record_answers_before_open_date => undef, - record_answers_after_open_date_with_attempts => "student", - record_answers_after_open_date_without_attempts => undef, - record_answers_after_due_date => undef, - record_answers_after_answer_date => undef, - dont_log_past_answers => undef, - # controls logging of the responses to a question - # in the past answer data base - # and in the myCourse/logs/answer_log file. - # Activities of users with this permission enabled are not entered - # in these logs. This might be used when collecting student data - # to avoid contaminating the data with TA and instructor activities. - # The professor setting means that professor's answers are not logged or - # saved in the past answer database. - view_problem_debugging_info => "ta", - show_pg_info_checkbox => "admin", - show_answer_hash_info_checkbox => "admin", - show_answer_group_info_checkbox => "admin", - ##### Behavior of the Hardcopy Processor ##### - - download_hardcopy_multiuser => "ta", - download_hardcopy_multiset => "ta", - download_hardcopy_view_errors =>"professor", - download_hardcopy_format_pdf => "guest", - download_hardcopy_format_tex => "ta", - download_hardcopy_change_theme=> "ta", -); - -# This is the default permission level given to new students and students with -# invalid or missing permission levels. -$default_permission_level = $userRoles{student}; - -################################################################################ -# Session options -################################################################################ - -# $sessionKeyTimeout defines seconds of inactivity before a key expires -$sessionKeyTimeout = 60*30; - -# $sessionKeyLength defines the length (in characters) of the session key -$sessionKeyLength = 32; - -# @sessionKeyChars lists the legal session key characters -@sessionKeyChars = ('A'..'Z', 'a'..'z', '0'..'9'); - -# Practice users are users who's names start with $practiceUser -# (you can comment this out to remove practice user support) -$practiceUserPrefix = "practice"; - -# There is a practice user who can be logged in multiple times. He's -# commented out by default, though, so you don't hurt yourself. It is -# kindof a backdoor to the practice user system, since he doesn't have a -# password. Come to think of it, why do we even have this?! -#$debugPracticeUser = "practice666"; - -# Option for gateway tests; $gatewayGracePeriod is the time in seconds -# after the official due date during which we'll still grade the test -$gatewayGracePeriod = 120; - -################################################################################ -# Session Management -################################################################################ - -## Session management, i.e., checking whether the session has timed out, -## can be handled either using the key database, the traditional method, -## or by using session cookies. If one is using the key database -## for session_management and is using WeBWorK's password authentication, -## then one has the option of keeping a Login cookie with a duration -## of up to 30 days. However, if one uses cookies for session management, -## then one cannot also use Login cookies. So session management using -## cookies is more appropriate when external authentication systems -## are used, e.g., LDAP, LTIBasic, etc. -## - -## The following ability to update the cookie timestamp instead of the timestamp in the database -## has been disabled for now. It opens a potential security hole. -## Setting $session_management_via="session_cookies" sets a session cookie automatically -## even if you don't ask for it explicitly and this login cookie contains a session_key which -## allows you to reenter your course (within 20 minutes or so) even if you move away from the -## webwork HTML page and loose the session_key embedded in the HTML page. -## However the time stamp in the cookie is not used currently used for anything. -## -#### NOT CURRENT: The reason one might want to use cookies for session management -#### is to avoid having to obtain a write lock on the Key database -#### every time a request is received in order to update the timestamp -#### in the Key database. When cookies are used for session management, -#### one obtains a write lock on the Key database for the original -#### login request in order to write the new session key and its initial -#### timestamp to the Key database, but on subsequent requests, -#### one merely obtains a read lock on the Key database in order -#### to verify that the session key in the session cookie is the -#### same as the session key in the Key database. The session timestamp -#### is maintained in the cookie, not in the Key database, which will -#### only show the timestamp of the original login. - - - -## For session management using session_cookies, uncomment the first of the -## following lines. -## For session management using keys stored -## in the key database and, possibly, enduring cookies if any have been set, -## uncomment the second line. - -## These choices can be overridden locally in the localOverrides.conf file. -## The default is to use "session_cookie". - -$session_management_via = "session_cookie"; -#$session_management_via = "key"; - -################################################################################ -# WeBWorK Caliper -################################################################################ - -# Caliper is disabled by default. See localOverrides.conf.dist for configuration -# options when enabling Caliper. -$caliper{enabled} = 0; - -################################################################################ -# Cookie control settings -################################################################################ - -# The following variables can be set to control cookie behavior. - -# Set the value of the samesite attribute of the WeBWorK cookie: -# See: https://blog.chromium.org/2019/10/developers-get-ready-for-new.html -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite -# https://tools.ietf.org/html/draft-west-cookie-incrementalism-00 - - -# Notes about the $CookieSameSite options: -# The "None" setting should only be used with HTTPS and when $CookieSecure = 1; is set below. The "None" setting is also less secure and can allow certain types of cross-site attacks. -# The "Strict" setting can break the links in the system generated feedback emails when read in a web mail client. -# Due to those factors, the "Lax" setting is probably the optimal choice for typical WeBWorK servers. - -$CookieSameSite = "Lax"; - -# Set the value of the secure cookie attribute: -$CookieSecure = 0; # Default is 0 here, as 1 will not work without https - -# At present the CookieLifeTime setting only effect how long the -# browser is to supposed to retain the cookie. -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie -$CookieLifeTime = "+7d"; - -# NOTE: In general the cookie lifespan settings use the CGI.pm relative time settings. -# Search for "30 seconds from now" at https://metacpan.org/pod/CGI to see the various options. -# A WW option is to set it to "session", in which case the Cookie will expire when the -# browser session ends (a "session cookie"). - -################################################################################ -# PG subsystem options -################################################################################ - -# List of enabled display modes. Comment out any modes you don't wish to make -# available for use. -# The first uncommented option is the default for instructors rendering problems -# in the homework sets editor. -$pg{displayModes} = [ - "MathJax", # render TeX math expressions on the client side using MathJax - # we strongly recommend people install and use MathJax, and it is required if you want to use mathview - "images", # display math expressions as images generated by dvipng -# "plainText", # display raw TeX for math expressions -]; - - -########################################################################################## -#### Default settings for homework editor pages -########################################################################################## - -# Whether the homework editor pages should show options for conditional release -$options{enableConditionalRelease} = 0; - -# In the hmwk sets editor, how deep to search within templates for .def files. -# Note that this does not apply to the Library and Contrib directories. -# Those directories are not searched in any case (see below). -# 0 means only within templates. -$options{setDefSearchDepth} = 0; - -# In the hmwk sets editor, also list OPL or Contrib set defintion files. Note -# that the directories are not searched, but these lists are loaded from the -# files htdocs/DATA/library-set-defs.json and htdocs/DATA/contrib-set-defs.json -# which are generated by running bin/generate-OPL-set-def-lists.pl (which is -# also run if you run bin/OPL-update). -$options{useOPLdefFiles} = 0; -$options{useContribDefFiles} = 0; - - -########################################################################################## -#### Default settings for the problem grader page -########################################################################################## - -# gap betweens cores in score dropdown - e.g. 5 gives 5, 10, 15, 20 -$options{problemGraderScoreDelta} = 5; - -########################################################################################## -#### Default settings for the problem editor pages -########################################################################################## - -# This sets if the PG editor should use a js based "codemirror" editor or -# just a textarea -$options{PGCodeMirror} = 1; - -# This sets if mathview is available on the PG editor for use as a minimal latex equation editor -$options{PGMathView} = 0; -# This sets if WirisEditor is available on the PG editor for use as a minimal latex equation editor -$options{PGWirisEditor}= 0; -# This sets if MathQuill is available on the PG editor for use as a minimal latex equation editor -$options{PGMathQuill}= 0; - - -########################################################################################### -#### Default settings for the PG translator -#### This section controls the display of equations, HINTS, answers, SOLUTIONS, -#### "sticky_answers" a.k.a. showOldAnswers, -#### coloring of answer blanks and the numeric display of entered answers. -########################################################################################### - -# Default display mode. Should be listed above (uncomment only one). -$pg{options}{displayMode} = "MathJax"; - -# The default grader to use, if a problem doesn't specify. -$pg{options}{grader} = "avg_problem_grader"; - -# Fill in answer blanks with the student's last answer by default? -$pg{options}{showOldAnswers} = 1; - -# Default for showing the MathView preview system. To completely disable MathView you need to change the PG special environment variable. -$pg{options}{useMathView} = 1; -# This is the operations file to use for mathview, each contains a different locale. -$pg{options}{mathViewLocale} = "mv_locale_us.js"; - -# Default for showing the WirisEditor preview system. To completely disable WirisEditor you need to change the PG special environment variable. -$pg{options}{useWirisEditor} = 1; - - -# Default for showing the MathQuill preview system. To completely disable MathQuill you need to change the PG special environment variable. -$pg{options}{useMathQuill} = 1; - -# Show correct answers (when allowed) by default? -$pg{options}{showCorrectAnswers} = 0; # this is a backup value use when nothing else has been set. I can think of no case where it should anything but zero. - -# Customize hints and solutions -# Show hints (when allowed) by default? -$pg{options}{showHints} = 0; # this is a backup value use when nothing else has been set. I can think of no case where it should anything but zero. - - -# Show solutions (when allowed) by default? -$pg{options}{showSolutions} = 0; # this is a backup value use when nothing else has been set. I can think of no case where it should anything but zero. -$pg{options}{showAnsGroupInfo} = 0; -$pg{options}{showAnsHashInfo} = 0; -$pg{options}{showPGInfo} = 0; - -# By default hints and solutions are ALWAYS shown for professors (and above) so that they -# can check hints and solutions easily and make corrections. -# To disable this feature set the permission levels -# always_show_hint to "nobody" (by default this is "professor") -# and always_show_solution to "nobody" (by default this is "professor") -# This is done in the %permissions section above. - -# If always_show_hint is set to "nobody" then hints are shown, even to professors, only after -# a certain number of submissions have occurred. This number is set in each problem with -# the variable $main::showHints - - -# Use knowls for hints -$pg{options}{use_knowls_for_hints} = 1; - -# Use knowls for solutions -$pg{options}{use_knowls_for_solutions} = 1; - -# The buttons below are active only if knowls are being used. If set to 1 then the hints (and solutions) -# checkboxes are shown and when these are checked and the problem resubmitted THEN the knowls outline -# appears. I can't immediately think of a useful case where these should be set to 1. If knowls are not being -# used then these checkboxes are ALWAYS shown when a hint or solution is available and the value -# of these two options is ignored. - -# Show solution checkbox -$pg{options}{show_solution_checkbox} = 0; - -# Show hint checkbox -$pg{options}{show_hint_checkbox} = 0; - -# Display the "Entered" column which automatically shows the evaluated student answer, e.g. 1 if student input is sin(pi/2). -# If this is set to 0, e.g. to save space in the response area, the student can still see their evaluated answer by hovering -# the mouse pointer over the typeset version of their answer -$pg{options}{showEvaluatedAnswers} = 1; - -# Catch translation warnings internally by default? (We no longer need to do -# this, since there is a global warnings handler. So this should be off.) -$pg{options}{catchWarnings} = 0; - -# decorations for correct input blanks -- apparently you can't define and name attribute collections in a .css file -$pg{options}{correct_answer} = "{border-width:2;border-style:solid;border-color:#8F8}"; #matches resultsWithOutError class in math2.css - -# decorations for incorrect input blanks -$pg{options}{incorrect_answer} = "{border-width:2;border-style:solid;border-color:#F55}"; #matches resultsWithError class in math2.css - -##### Currently-selected renderer - -# Only the local renderer is supported in this version. -$pg{renderer} = "WeBWorK::PG::Local"; - -# The remote renderer connects to an XML-RPC PG rendering server. -#$pg{renderer} = "WeBWorK::PG::Remote"; - -##### Renderer-dependent options - -# The remote renderer has one option: -$pg{renderers}{"WeBWorK::PG::Remote"} = { - # The "proxy" server to connect to for remote rendering. - proxy => "http://localhost:21000/RenderD", -}; - -##### Settings for various display modes - -# "images" mode has several settings: -$pg{displayModeOptions}{images} = { - # Determines the method used to align images in output. Can be - # "baseline", "absmiddle", or "mysql". - dvipng_align => 'mysql', - - # If mysql is chosen, this information indicates which database contains the - # 'depths' table. Since 2.3.0, the depths table is kept in the main webwork - # database. (If you are upgrading from an earlier version of webwork, and - # used the mysql method in the past, you should move your existing 'depths' - # table to the main database.) - dvipng_depth_db => { - dbsource => $database_dsn, - user => $database_username, - passwd => $database_password, - }, -}; - -##### Directories used by PG - -# The root of the PG directory tree (from pg_root in Apache config). -$pg{directories}{root} = "$ENV{RENDER_ROOT}/lib/PG"; # "$pg_dir"; -$pg{directories}{lib} = "$pg{directories}{root}/lib"; -$pg{directories}{macros} = "$pg{directories}{root}/macros"; - -# -# The macro file search path. Each directory in this list is seached -# (in this order) by loadMacros() when it looks for a .pl file. -# -$pg{directories}{macrosPath} = [ - ".", # search the problem file's directory - #$courseDirs{macros}, - $pg{directories}{macros}, - "$problemLibrary{root}/macros/Alfred", - "$problemLibrary{root}/macros/BrockPhysics", - "$problemLibrary{root}/macros/CollegeOfIdaho", - "$problemLibrary{root}/macros/Dartmouth", - "$problemLibrary{root}/macros/FortLewis", - "$problemLibrary{root}/macros/Hope", - "$problemLibrary{root}/macros/LaTech", - "$problemLibrary{root}/macros/MC", - "$problemLibrary{root}/macros/Michigan", - "$problemLibrary{root}/macros/Mizzou", - "$problemLibrary{root}/macros/NAU", - "$problemLibrary{root}/macros/PCC", - "$problemLibrary{root}/macros/TCNJ", - "$problemLibrary{root}/macros/UBC", - "$problemLibrary{root}/macros/UMass-Amherst", - "$problemLibrary{root}/macros/UW-Stout", - "$problemLibrary{root}/macros/UniSiegen", - "$problemLibrary{root}/macros/Union", - "$problemLibrary{root}/macros/WHFreeman", - "$problemLibrary{root}/macros/Wiley", -]; - -# The applet search path. If a full URL is given, it is used unmodified. If an -# absolute path is given, the URL of the local server is prepended to it. -# -# For example, if an item is "/math/applets", -# and the local server is "https://math.yourschool.edu", -# then the URL "https://math.yourschool.edu/math/applets" will be used. -# - -$pg{directories}{appletPath} = [ # paths to search for applets (requires full url) - "$webworkURLs{htdocs}/applets", - "$webworkURLs{htdocs}/applets/geogebra_stable", - "$courseURLs{html}/applets", - "$webworkURLs{htdocs}/applets/Xgraph", - "$webworkURLs{htdocs}/applets/PointGraph", - "$webworkURLs{htdocs}/applets/Xgraph", - "$webworkURLs{htdocs}/applets/liveJar", - "$webworkURLs{htdocs}/applets/Image_and_Cursor_All", -]; - - -$pg{directories}{htmlPath} = [ # paths to search for auxiliary html files (requires full url) - ".", - "$courseURLs{html}", - "$webworkURLs{htdocs}", -]; -$pg{directories}{imagesPath} = [ # paths to search for image files (requires full url) - ".", - "$courseURLs{html}/images", - "$webworkURLs{htdocs}/images", -]; -$pg{directories}{pdfPath} = [ # paths to search for pdf files (requires full url) - ".", - "$courseURLs{html}/pdf", - "$webworkURLs{htdocs}/pdf", -]; -##### "Special" PG environment variables. (Stuff that doesn't fit in anywhere else.) - -# Users for whom to print the file name of the PG file being processed. -$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = [ "professor", ]; - # ie file paths are printed for 'gage' -$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL} = - $userRoles{ $permissionLevels{print_path_to_problem} }; - # (file paths are also printed for anyone with this permission or higher) -$pg{specialPGEnvironmentVars}{ALWAYS_SHOW_HINT_PERMISSION_LEVEL} = - $userRoles{ $permissionLevels{always_show_hint} }; - # (hints are automatically shown to anyone with this permission or higher) -$pg{specialPGEnvironmentVars}{ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL} = - $userRoles{ $permissionLevels{always_show_solution} }; - # (solutions are automatically shown to anyone with this permission or higher) -$pg{specialPGEnvironmentVars}{VIEW_PROBLEM_DEBUGGING_INFO} = - $userRoles{ $permissionLevels{view_problem_debugging_info} }; - # (variable whether to show the debugging info from a problem to a student) - -$pg{specialPGEnvironmentVars}{use_knowls_for_hints} = $pg{options}{use_knowls_for_hints}; -$pg{specialPGEnvironmentVars}{use_knowls_for_solutions} = $pg{options}{use_knowls_for_solutions}; - -# whether to use javascript for rendering Live3D graphs -$pg{specialPGEnvironmentVars}{use_javascript_for_live3d} = 1; - -# Binary that the PGtikz.pl and PGlateximage.pl macros will use to create svg images. -# This should be either 'pdf2svg' or 'dvipdfm'. -$pg{specialPGEnvironmentVars}{latexImageSVGMethod} = "pdf2svg"; - -# When ImageMagick is used for image conversions, this sets the default options. -# See https://imagemagick.org/script/convert.php for a full list of options. -# convert will be called as: -# convert file.ext1 file.ext2 -$pg{specialPGEnvironmentVars}{latexImageConvertOptions} = {input => {density => 300}, output => {quality => 100}}; - - # set the flags immediately above in the $pg{options} section above -- not here. - -# Locations of CAPA resources. (Only necessary if you need to use converted CAPA -# problems.) -################################################################################ -# "Special" PG environment variables. (Stuff that doesn't fit in anywhere else.) -################################################################################ - - $pg{specialPGEnvironmentVars}{CAPA_Tools} = "$courseDirs{templates}/Contrib/CAPA/macros/CAPA_Tools/", - $pg{specialPGEnvironmentVars}{CAPA_MCTools} = "$courseDirs{templates}/Contrib/CAPA/macros/CAPA_MCTools/", - $pg{specialPGEnvironmentVars}{CAPA_GraphicsDirectory} = "$courseDirs{templates}/Contrib/CAPA/CAPA_Graphics/", - $pg{specialPGEnvironmentVars}{CAPA_Graphics_URL} = "$webworkURLs{htdocs}/CAPA_Graphics/", - - # The link Contrib in the course templates directory should point to ../webwork-open-problem-library/Contrib - # The link webwork2/htdocs/CAPA_Graphics should point to ../webwork-open-problem-library/Contrib/CAPA/macros/CAPA_graphics -# Size in pixels of dynamically-generated images, i.e. graphs. -$pg{specialPGEnvironmentVars}{onTheFlyImageSize} = 400, - -# To disable the Parser-based versions of num_cmp and fun_cmp, and use the -# original versions instead, set this value to 1. -$pg{specialPGEnvironmentVars}{useOldAnswerMacros} = 0; - -# Determines whether or not MathObjects contexts will parse the alternative tokens -# listed in the "alternatives" property (mostly for unicode alternatives for parse tokens). -$pg{specialPGEnvironmentVars}{parseAlternatives} = 0; - -# Determines whether or not the MathObjects parser will convert the Full Width Unicode block -# (U+FF01 to U+FF5E) to their corresponding ASCII characters (U+0021 to U+007E) automatically. -$pg{specialPGEnvironmentVars}{convertFullWidthCharacters} = 0; - - -# Strings to insert at the start and end of the body of a problem -# (at beginproblem() and ENDDOCUMENT) in various modes. More display modes -# can be added if different behaviours are desired (e.g., HTML_dpng, -# HTML_asciimath, etc.). These parts are not used in the Library browser. - -$pg{specialPGEnvironmentVars}{problemPreamble} = { TeX => '', HTML=> '' }; -$pg{specialPGEnvironmentVars}{problemPostamble} = { TeX => '', HTML=>'' }; - -# this snippet checks to see if Moodle has already called MathJax -# $pg{specialPGEnvironmentVars}{problemPreamble} = { TeX => '', HTML=> < -# if (MathJax.Hub.Startup.params.config && MathJax.Hub.config.config.length) { -# MathJax.Hub.Config({ -# config: [], -# skipStartupTypeset: false -# }); -# } -# -# END_PREAMBLE - -# -# $pg{specialPGEnvironmentVars}{problemPostamble} = { TeX => '', HTML=> <\n!; -#$pg{specialPGEnvironmentVars}{problemPostamble}{HTML}= qq!\n!; - -# To have the problem body indented and boxed, uncomment: -# $pg{specialPGEnvironmentVars}{problemPreamble}{HTML} = '
-#
'; -# $pg{specialPGEnvironmentVars}{problemPostamble}{HTML} = '
-#
'; - -##### PG modules to load - -# The first item of each list is the module to load. The remaining items are -# additional packages to import. -# -# That is: If you wish to include a module MyModule.pm which depends -# on additional modules Dependency1.pm and Dependency2.pm, these -# should appear as [qw(Mymodule.pm, Dependency1.pm, Dependency2.pm)] - -${pg}{modules} = [ - [qw(Encode)], - [qw(Encode::Encoding)], - [qw(HTML::Parser)], - [qw(HTML::Entities)], - [qw(DynaLoader)], - [qw(Encode)], - [qw(Exporter )], - [qw(GD)], - [qw(AlgParser AlgParserWithImplicitExpand Expr ExprWithImplicitExpand utf8)], - [qw(AnswerHash AnswerEvaluator)], - [qw(LaTeXImage)], - [qw(WWPlot)], # required by Circle (and others) - [qw(Circle)], - [qw(Class::Accessor)], - [qw(Complex)], - [qw(Complex1)], - [qw(Distributions)], - [qw(Fraction)], - [qw(Fun)], - [qw(Hermite)], - [qw(Label)], - [qw(ChoiceList)], - [qw(Match)], - [qw(MatrixReal1)], # required by Matrix - [qw(Matrix)], - [qw(Multiple)], - [qw(PGrandom)], - [qw(Regression)], - [qw(Select)], - [qw(Units)], - [qw(VectorField)], - [qw(Parser Value)], - [qw(Parser::Legacy)], - [qw(Statistics)], - #[qw(Chromatic)], # for Northern Arizona graph problems - [qw(Applet GeogebraWebApplet)], - [qw(PGcore PGalias PGresource PGloadfiles PGanswergroup PGresponsegroup Tie::IxHash)], - [qw(Locale::Maketext)], - [qw(WeBWorK::Localize)], - [qw(JSON)], - [qw(Rserve Class::Tiny IO::Handle)], - [qw(DragNDrop)], - [qw(Types::Serialiser)], - [qw(Mojo::Exception)], -]; - -##### Problem creation defaults - -# The default weight (also called value) of a problem to use when using the -# Library Browser, Problem Editor or Hmwk Sets Editor to add problems to a set -# or when this value is left blank in an imported set definition file. -$problemDefaults{value} = 1; - -# The default max_attempts for a problem to use when using the -# Library Browser, Problem Editor or Hmwk Sets Editor to add problems to a set -# or when this value is left blank in an imported set definition file. Note that -# setting this to -1 gives students unlimited attempts. -$problemDefaults{max_attempts} = -1; - -# The default showMeAnother for a problem to use when using the -# Library Browser, Problem Editor or Hmwk Sets Editor to add problems to a set -# or when this value is left blank in an imported set definition file. Note that -# setting this to -1 disables the showMeAnother button -$problemDefaults{showMeAnother} = -2; - -#The default attempts to open children value to use when adding -# a problem. This only matters for JITAR sets -$problemDefaults{att_to_open_children} = 1; - -#The default counts for parent grade problem value to use when adding -# a problem. This only matters for JITAR sets -$problemDefaults{counts_parent_grade} = 0; - -# The default prPeriod value (re-randomization period) to use for the newly created problem. -# It is suggested to use the value of -1, which means that the course-wide setting would be used -# Setting this to -1 defaults to the use of course-wide settings (suggested) -# Setting this to 0 disables periodic randomization regardless of the course-wide setting -# Setting this to a positive value will override the course-wide setting -$problemDefaults{prPeriod} = -1; - -##### Answer evaluatior defaults - -$pg{ansEvalDefaults} = { - functAbsTolDefault => .001, - functLLimitDefault => .0000001, - functMaxConstantOfIntegration => 1E8, - functNumOfPoints => 3, - functRelPercentTolDefault => .1, - functULimitDefault => .9999999, - functVarDefault => "x", - functZeroLevelDefault => 1E-14, - functZeroLevelTolDefault => 1E-12, - numAbsTolDefault => .001, - numFormatDefault => "", - numRelPercentTolDefault => .1, - numZeroLevelDefault => 1E-14, - numZeroLevelTolDefault => 1E-12, - useBaseTenLog => 0, - defaultDisplayMatrixStyle => "[s]", # left delimiter, middle line delimiters, right delimiter - enableReducedScoring => 0, - reducedScoringPeriod => 0, # Default length of Reduced Scoring Period in minutes - reducedScoringValue => .75, # Percent of score students receive in Reduced Scoring Period - timeAssignDue => "11:59pm", - assignOpenPriorToDue => 14400, # a number of minutes (default is 10 days) - answersOpenAfterDueDate => 2880 # number of minutes (default is 2 days) -}; - - - -################################################################################ -# Compatibility -################################################################################ - -# Define the old names for the various "root" variables. -$webworkRoot = $webworkDirs{root}; -$webworkURLRoot = $webworkURLs{root}; -$pgRoot = $pg{directories}{root}; - - - -################################################################################ -# Webservices -################################################################################ -$webservices = { - enableCourseActions => 0, # enable createCourse, addUser, dropUser - enableCourseActionsLog => 0 ,# enable logging of course actions - # will log when courses are created and - # when students are added or dropped - courseActionsLogfile => "$webworkDirs{logs}/courseactions.log", - # enable this to assign all visible homework sets to new students - # added by webservices - courseActionsAssignHomework => 0, -}; - - -############################################################################### -# Math entry assistance -############################################################################### - -$pg{specialPGEnvironmentVars}{entryAssist} = 'MathQuill'; - -############################################################################### -# default Homework Config settings -############################################################################### - -# time of day the assignment is due. -$pg{timeAssignDue} = '11:59pm'; - -# number of minutes prior to due date that the assignment is open. -$pg{assignOpenPriorToDue} = 10080; - -#number of minutes after due date are the answers open; -$pg{answersOpenAfterDueDate} = 2880; - -############################################################################### -# Progress Bar switch -############################################################################### -$pg{options}{enableProgressBar} = 1; - -################################################################################ -# WeBWorK::ContentGenerator::Instructor::Config -################################################################################ - -# Configuration data -# It is organized by section. The allowable types are -# 'text' for a text string (no quote marks allowed), -# 'number' for a number, -# 'list' for a list of text strings, -# 'permission' for a permission value, -# 'boolean' for variables which really hold 0/1 values as flags. -# 'checkboxlist' for variables which really hold a list of values which -# can be independently picked yes/no as checkboxes - -# Localization Info: The doc strings in this portion are reproduced in -# lib/WeBWorK/Localize.pm solely so that xgettext.pl will -# include them when creating .pot files. -# If you change these strings you should make the corresponding changes in -# Localize.pm - -# This is a dummy function used to mark strings in the config values for localization. -# The method in lib/WeBWorK/Utils.pm cannot be used here. -sub x { return @_; } - -$ConfigValues = [ - [ - x('General'), - { - var => 'courseFiles{course_info}', - doc => x('Name of course information file'), - doc2 => x( - 'The name of course information file (located in the templates directory). ' - . 'Its contents are displayed in the right panel next to the list of homework sets.' - ), - type => 'text' - }, - { - var => 'defaultTheme', - doc => x('Theme (refresh page after saving changes to reveal new theme.)'), - doc2 => x( - 'There is one main theme to choose from: math4. It has two variants, math4-green and math4-red. ' - . 'The theme specifies a unified look and feel for the WeBWorK course web pages.' - ), - values => [qw(math4 math4-green math4-red)], - type => 'popuplist', - hashVar => '{defaultTheme}' - }, - { - var => 'language', - doc => x('Language (refresh page after saving changes to reveal new language.)'), - doc2 => x('WeBWorK currently has translations for the languages listed in the course configuration.'), - values => [qw(en tr es fr zh-HK he)], - type => 'popuplist' - }, - { - var => 'perProblemLangAndDirSettingMode', - doc => x('Mode in which the LANG and DIR settings for a single problem are determined.'), - doc2 => x( - '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, a course-wide default, ' - . 'or the system default, depending on the mode selected. The tag will only be added to ' - . 'the DIV enclosing the problem if it is different than the value which should be set in the ' - . 'main HTML tag set for the entire course based on the course language.

There are two options ' - . 'for the DIRection attribute: "ltr" for left-to-write sripts, and "rtl" for right-to-left ' - . 'scripts like Arabic and Hebrew.

The DIRection attribute is needed to trigger proper display ' - . 'of the question text when the problem text-direction is different than that used by the current ' - . 'language of the course. For example, English problems from the library browser would display ' - . 'improperly in RTL mode for a Hebrew course, unless the problen Direction is set to LTR.' - . '

The feature to set a problem language and direction was only added in 2018 to the PG ' - . 'language, so most problems will not declare their language, and the system needs to fall ' - . 'back to determining the language and direction in a different manner. The OPL itself is all ' - . 'English, so the system wide fallback is to en-US in LTR mode.

Since the defaults fall back ' - . 'to the LTR direction, most sites should be fine with the "auto::" mode, but may want to select ' - . 'the one which matches their course language. The mode "force::ltr" would also be an option for ' - . 'a course which runs into trouble with the "auto" modes.

Modes:

  • "none" prevents any ' - . 'additional LANG and/or DIR tag being added. The browser will use the main setting which was ' - . 'applied to the entire HTML page. This is likely to cause trouble when a problem of the other ' - . 'direction is displayed.
  • "auto::" allows the system to make the settings based on the ' - . 'language and direction reported by the problem (a new feature, so not set in almost all ' - . 'existing problems) and falling back to the expected default of en-US in LTR mode.
  • ' - . '
  • "auto:LangCode:Dir" allows the system to make the settings based on the language and ' - . 'direction reported by the problem (a new feature, so not set in almost all existing problems) ' - . 'but falling back to the language with the given LangCode and the direction Dir when problem ' - . 'settings are not available from PG.
  • "auto::Dir" for problems without PG settings, this ' - . 'will use the default en=english language, but force the direction to Dir. Problems with PG ' - . 'settings will get those settings.
  • "auto:LangCode:" for problems without PG settings, ' - . 'this will use the default LTR direction, but will set the language to LangCode.Problems with PG ' - . 'settings will get those settings.
  • "force:LangCode:Dir" will ignore any setting ' - . 'made by the PG code of the problem, and will force the system to set the language with the ' - . 'given LangCode and the direction to Dir for all problems.
  • "force::Dir" will ' - . 'ignore any setting made by the PG code of the problem, and will force the system to set ' - . 'the direction to Dir for all problems, but will avoid setting any language attribute for ' - . 'individual problem.
' - ), - values => [ - qw(none auto:: force::ltr force::rtl force:en:ltr auto:en:ltr force:tr:ltr auto:tr:ltr force:es:ltr - auto:es:ltr force:fr:ltr auto:fr:ltr force:zh_hk:ltr auto:zh_hk:ltr force:he:rtl auto:he:rtl) - ], - type => 'popuplist' - }, - { - var => 'sessionKeyTimeout', - doc => x('Inactivity time before a user is required to login again'), - doc2 => x( - 'Length of time, in seconds, a user has to be inactive before he is required to login again.

' - . 'This value should be entered as a number, so as 3600 instead of 60*60 for one hour' - ), - type => 'number' - }, - { - var => 'siteDefaults{timezone}', - doc => x('Timezone for the course'), - doc2 => x( - 'Some servers handle courses taking place in different timezones. If this course is not showing ' - . 'the correct timezone, enter the correct value here. The format consists of unix times, such ' - . 'as "America/New_York","America/Chicago", "America/Denver", "America/Phoenix" or ' - . '"America/Los_Angeles". Complete list: ' - . 'TimeZoneFiles' - ), - type => 'timezone', - hashVar => '{siteDefaults}->{timezone}' - }, - { - var => 'hardcopyTheme', - doc => x('Hardcopy Theme'), - doc2 => x( - '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' - ), - values => $hardcopyThemes, - labels => $hardcopyThemeNames, - type => 'popuplist', - hashVar => '{hardcopyTheme}' - }, - { - var => 'showCourseHomeworkTotals', - doc => x('Show Total Homework Grade on Grades Page'), - doc2 => x( - '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' - }, - { - var => 'pg{options}{enableProgressBar}', - doc => x('Enable Progress Bar and current problem highlighting'), - doc2 => x( - 'A switch to govern the use of a Progress Bar for the student; this also enables/disables the ' - . 'highlighting of the current problem in the side bar, and whether it is correct (✓), ' - . 'in progress (…), incorrect (✗), or unattempted (no symbol).' - ), - type => 'boolean' - }, - { - var => 'pg{timeAssignDue}', - doc => x('Default Time that the Assignment is Due'), - doc2 => x( - 'The time of the day that the assignment is due. This can be changed on an individual basis, ' - . 'but WeBWorK will use this value for default when a set is created.' - ), - type => 'time', - hashVar => '{pg}->{timeAssignDue}' - }, - { - var => 'pg{assignOpenPriorToDue}', - doc => x('Default Amount of Time (in minutes) before Due Date that the Assignment is Open'), - doc2 => x( - 'The amount of time (in minutes) before the due date when the assignment is opened. You can change ' - . 'this for individual homework, but WeBWorK will use this value when a set is created.' - ), - type => 'number', - hashVar => '{pg}->{assignOpenPriorToDue}' - }, - { - var => 'pg{answersOpenAfterDueDate}', - doc => x('Default Amount of Time (in minutes) after Due Date that Answers are Open'), - doc2 => x( - 'The amount of time (in minutes) after the due date that the Answers are available to student to ' - . 'view. You can change this for individual homework, but WeBWorK will use this value when a set ' - . 'is created.' - ), - type => 'number', - hashVar => '{pg}->{answersOpenAfterDueDate}' - }, - ], - [ - x('Optional Modules'), - { - var => 'achievementsEnabled', - doc => x('Enable Course Achievements'), - doc2 => x( - 'Activiating this will enable Mathchievements for webwork. Mathchievements can be managed ' - . 'by using the Achievement Editor link.' - ), - type => 'boolean' - }, - { - var => 'achievementPointsPerProblem', - doc => x('Achievement Points Per Problem'), - doc2 => x('This is the number of achievement points given to each user for completing a problem.'), - type => 'number' - }, - { - var => 'achievementItemsEnabled', - doc => x('Enable Achievement Rewards'), - doc2 => x( - 'Activating this will enable achievement rewards. This feature allows students to earn rewards by ' - . 'completing achievements that allow them to affect their homework in a limited way.' - ), - type => 'boolean' - }, - { - var => 'achievementExcludeSet', - doc => x('List of sets excluded from achievements'), - doc2 => x( - 'Comma separated list of set names that are excluded from all achievements. ' - . 'No achievement points and badges can be earned for submitting problems in these sets. ' - . 'Note that underscores (_) must be used for spaces in set names.' - ), - type => 'list' - }, - { - var => 'options{enableConditionalRelease}', - doc => x('Enable Conditional Release'), - doc2 => x( - 'Enables the use of the conditional release system. To use conditional release you need to specify a ' - . 'list of set names on the Problem Set Detail Page, along with a minimum score. Students will ' - . 'not be able to access that homework set until they have achieved the minimum score on all of ' - . 'the listed sets.' - ), - type => 'boolean' - }, - { - var => 'pg{ansEvalDefaults}{enableReducedScoring}', - doc => x('Enable Reduced Scoring'), - doc2 => x( - '

This sets whether the Reduced Scoring system will be enabled. If enabled you will need to set the ' - . 'default length of the reduced scoring period and the value of work done in the reduced scoring ' - . 'period below.

To use this, you also have to enable Reduced Scoring for individual ' - . 'assignments and set their Reduced Scoring Dates by editing the set data.

This works with ' - . 'the avg_problem_grader (which is the 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 => 'boolean' - }, - { - var => 'pg{ansEvalDefaults}{reducedScoringValue}', - doc => x('Value of work done in Reduced Scoring Period'), - doc2 => x( - '

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 views a problem during the Reduced Scoring Period, they will see the ' - . 'message "You are in the Reduced Scoring Period: All additional work done counts 50% of the ' - . 'original."

To use this, you also have to enable Reduced Scoring and set the Reduced ' - . 'Scoring Date for individual assignments by editing the set data using the Hmwk Sets Editor.

' - . '

This works with the avg_problem_grader (which is the the default grader) and the ' - . 'std_problem_grader (the all or nothing grader). It will work with custom graders if they ' - . 'are written appropriately.

' - ), - labels => { - '0.1' => '10%', - '0.15' => '15%', - '0.2' => '20%', - '0.25' => '25%', - '0.3' => '30%', - '0.35' => '35%', - '0.4' => '40%', - '0.45' => '45%', - '0.5' => '50%', - '0.55' => '55%', - '0.6' => '60%', - '0.65' => '65%', - '0.7' => '70%', - '0.75' => '75%', - '0.8' => '80%', - '0.85' => '85%', - '0.9' => '90%', - '0.95' => '95%', - '1' => '100%' - }, - values => [qw(1 0.95 0.9 0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1)], - type => 'popuplist' - }, - { - var => 'pg{ansEvalDefaults}{reducedScoringPeriod}', - doc => x('Default Length of Reduced Scoring Period in minutes'), - doc2 => x( - '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 the due date minus this number. The reduced scoring date ' - . 'can then be changed. If the Reduced Scoring is enabled and if it is after the reduced scoring ' - . 'date, but before the due date, a message like "This assignment has a Reduced Scoring Period ' - . 'that begins 11/08/2009 at 06:17pm EST and ends on the due date, 11/10/2009 at 06:17pm EST. ' - . 'During this period all additional work done counts 50% of the original." will be displayed.' - ), - type => 'number' - }, - { - var => 'pg{options}{enableShowMeAnother}', - doc => x('Enable Show Me Another button'), - doc2 => x( - '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' - }, - { - var => 'pg{options}{showMeAnotherDefault}', - doc => x('Default number of attempts before Show Me Another can be used (-1 => Never)'), - doc2 => x( - '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 => 'number' - }, - { - var => 'pg{options}{showMeAnotherMaxReps}', - doc => x('Maximum times Show me Another can be used per problem (-1 => unlimited)'), - doc2 => x( - '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 => 'number' - }, - { - var => 'pg{options}{showMeAnother}', - doc => x('List of options for Show Me Another button'), - doc2 => x( - '
  • SMAcheckAnswers: enables the Check Answers button for the new problem when ' - . 'Show Me Another is clicked
  • SMAshowSolutions: shows walk-through solution ' - . 'for the new problem when Show Me Another is clicked; a check is done first to make ' - . 'sure that a solution exists
  • SMAshowCorrect: correct answers for the new ' - . 'problem can be viewed when Show Me Another is clicked; note that SMAcheckAnswers' - . 'needs to be enabled at the same time
  • SMAshowHints: show hints for the new ' - . 'problem (assuming they exist)
Note: there is very little point enabling the ' - . 'button unless you check at least one of these options - the students would simply see a new ' - . 'version that they can not attempt or learn from.

' - ), - min => 0, - values => [ "SMAcheckAnswers", "SMAshowSolutions", "SMAshowCorrect", "SMAshowHints" ], - type => 'checkboxlist' - }, - { - var => 'pg{options}{enablePeriodicRandomization}', - doc => x('Enable periodic re-randomization of problems'), - doc2 => x( - 'Enables periodic re-randomization of problems after a given number of attempts. Student would have ' - . 'to click Request New Version to obtain new version of the problem and to continue working on ' - . 'the problem' - ), - type => 'boolean' - }, - { - var => 'pg{options}{periodicRandomizationPeriod}', - doc => x('The default number of attempts between re-randomization of the problems ( 0 => never)'), - doc2 => x('The default number of attempts before the problem is re-randomized. ( 0 => never )'), - type => 'number' - }, - { - var => 'pg{options}{showCorrectOnRandomize}', - doc => x('Show the correct answer to the current problem before re-randomization.'), - doc2 => x( - 'Show the correct answer to the current problem on the last attempt before a new version is ' - . 'requested.' - ), - type => 'boolean' - }, - ], - [ - x('Permissions'), - { - var => 'permissionLevels{login}', - doc => x('Allowed to login to the course'), - type => 'permission' - }, - { - var => 'permissionLevels{change_password}', - doc => x('Allowed to change their password'), - doc2 => x( - 'Users at this level and higher are allowed to change their password. ' - . 'Normally guest users are not allowed to change their password.' - ), - type => 'permission' - }, - { - var => 'permissionLevels{become_student}', - doc => x('Allowed to act as another user'), - type => 'permission' - }, - { - var => 'permissionLevels{submit_feedback}', - doc => x('Can e-mail instructor'), - doc2 => x('Only this permission level and higher get buttons for sending e-mail to the instructor.'), - type => 'permission' - }, - { - var => 'permissionLevels{record_answers_when_acting_as_student}', - doc => x('Can submit answers for a student'), - doc2 => - x('When acting as a student, this permission level and higher can submit answers for that student.'), - type => 'permission' - }, - { - var => 'permissionLevels{report_bugs}', - doc => x('Can report bugs'), - doc2 => x( - 'Users with at least this permission level get a link in the left panel for reporting bugs to the ' - . 'bug tracking system at bugs.webwork.maa.org.' - ), - type => 'permission' - }, - { - var => 'permissionLevels{change_email_address}', - doc => x('Allowed to change their e-mail address'), - doc2 => x( - 'Users at this level and higher are allowed to change their e-mail address. Normally guest users are ' - . 'not allowed to change the e-mail address since it does not make sense to send e-mail to ' - . 'anonymous accounts.' - ), - type => 'permission' - }, - { - var => 'permissionLevels{change_pg_display_settings}', - doc => x('Allowed to change display settings used in pg problems'), - doc2 => x( - 'Users at this level and higher are allowed to change display settings used in pg problems.' - . 'Note that if it is expected that there will be students that have vision impairments and ' - . 'MathQuill is enabled to assist with answer entry, then you should not set this permission to a ' - . 'level above student as those students may need to disable MathQuill.' - ), - type => 'permission' - }, - { - var => 'permissionLevels{view_answers}', - doc => x('Allowed to view past answers'), - doc2 => x('These users and higher get the "Show Past Answers" button on the problem page.'), - type => 'permission' - }, - { - var => 'permissionLevels{view_unopened_sets}', - doc => x('Allowed to view problems in sets which are not open yet'), - type => 'permission' - }, - { - var => 'permissionLevels{show_correct_answers_before_answer_date}', - doc => x('Allowed to see the correct answers before the answer date'), - type => 'permission' - }, - { - var => 'permissionLevels{show_solutions_before_answer_date}', - doc => x('Allowed to see solutions before the answer date'), - type => 'permission' - }, - { - var => 'permissionLevels{can_show_old_answers}', - doc => x('Can show old answers'), - doc2 => x( - 'When viewing a problem, WeBWorK usually puts the previously submitted answer in the answer blank. ' - . 'Below this level, old answers are never shown. Typically, that is the desired behaviour for ' - . 'guest accounts.' - ), - type => 'permission' - }, - { var => 'permissionLevels{navigation_allowed}', - doc => 'Allowed to view course home page', - doc2 => 'If a user does not have this permission, then the user will not be allowed to navigate to the ' - . 'course home page, i.e., the Homework Sets page. This should only be used for a course when LTI ' - . 'authentication is used, and is most useful when LTIGradeMode is set to homework. In this case the ' - . 'Homework Sets page is not useful and can even be confusing to students. To use this feature set ' - . 'this permission to "login_proctor".', - type => 'permission' - }, - ], - [ - x('Problem Display/Answer Checking'), - { - var => 'pg{displayModes}', - doc => x('List of display modes made available to students'), - doc2 => x( - '

When viewing a problem, users may choose different methods of rendering formulas via an options ' - . 'box in the left panel. Here, you can adjust what display modes are listed.

Some display ' - . 'modes require other software to be installed on the server. Be sure to check that all display ' - . 'modes selected here work from your server.

The display modes are

  • plainText: ' - . 'shows the raw LaTeX strings for formulas.
  • images: produces images using the external ' - . 'programs LaTeX and dvipng.
  • MathJax: a successor to jsMath, uses javascript to place ' - . 'render mathematics.

You must use at least one display mode. If you select only ' - . 'one, then the options box will not give a choice of modes (since there will only be one active).' - . '

' - ), - min => 1, - values => [ "MathJax", "images", "plainText" ], - type => 'checkboxlist' - }, - { - var => 'pg{options}{displayMode}', - doc => x('The default display mode'), - doc2 => - x('Enter one of the allowed display mode types above. See \'display modes entry\' for descriptions.'), - min => 1, - values => [qw(MathJax images plainText)], - type => 'popuplist' - }, - { - var => 'pg{specialPGEnvironmentVars}{entryAssist}', - doc => x('Assist with the student answer entry process.'), - doc2 => x( - '

MathQuill renders students answers in real-time as they type on the keyboard.

MathView ' - . 'allows students to choose from a variety of common math structures (such as fractions and ' - . 'square roots) as they attempt to input their answers.

WIRIS provides a separate workspace ' - . 'for students to construct their response in a WYSIWYG environment.

' - ), - min => 1, - values => [qw(None MathQuill MathView WIRIS)], - type => 'popuplist' - }, - { - var => 'pg{options}{showEvaluatedAnswers}', - doc => x('Display the evaluated student answer'), - doc2 => x( - 'Set to true to display the "Entered" column which automatically shows the evaluated student answer, ' - . 'e.g., 1 if student input is sin(pi/2). If this is set to false, e.g., to save space in the ' - . 'response area, the student can still see their evaluated answer by clicking on the typeset ' - . 'version of their answer.' - ), - type => 'boolean' - }, - { - var => 'pg{ansEvalDefaults}{useBaseTenLog}', - doc => x('Use log base 10 instead of base e'), - doc2 => x('Set to true for log to mean base 10 log and false for log to mean natural logarithm.'), - type => 'boolean' - }, - { - var => 'pg{specialPGEnvironmentVars}{useOldAnswerMacros}', - doc => x('Use older answer checkers'), - doc2 => x( - '

During summer 2005, a newer version of the answer checkers was implemented for answers which are ' - . 'functions and numbers. The newer checkers allow more functions in student answers, and behave ' - . 'better in certain cases. Some problems are specifically coded to use new (or old) answer ' - . 'checkers. However, for the bulk of the problems, you can choose what the default will be here.' - . '

Choosing false here means that the newer answer checkers will be used by default, ' - . 'and choosing true means that the old answer checkers will be used by default.

' - ), - type => 'boolean' - }, - { - var => 'pg{specialPGEnvironmentVars}{parseAlternatives}', - doc => x('Allow Unicode alternatives in student answers'), - doc2 => x( - 'Set to true to allow students to enter Unicode versions of some characters (like U+2212 for the ' - . 'minus sign) in their answers. One reason to allow this is that copying and pasting output ' - . 'from MathJax can introduce these characters, but it is also getting easier to enter these ' - . 'characters directory from the keyboard.' - ), - type => 'boolean' - }, - { - var => 'pg{specialPGEnvironmentVars}{convertFullWidthCharacters}', - doc => x('Automatically convert Full Width Unicode characters to their ASCII equivalents'), - doc2 => x( - 'Set to true to have Full Width Unicode character (U+FF01 to U+FF5E) converted to their ASCII ' - . 'equivalents (U+0021 to U+007E) automatically in MathObjects. This may be valuable for Chinese ' - . 'keyboards, for example, that automatically use Full Width characters for parentheses and ' - . 'commas.' - ), - type => 'boolean' - }, - { - var => 'pg{ansEvalDefaults}{numRelPercentTolDefault}', - doc => x('Allowed error, as a percentage, for numerical comparisons'), - doc2 => x( - 'When numerical answers are checked, most test if the student\'s answer is close enough to the ' - . 'programmed answer be computing the error as a percentage of the correct answer. This value ' - . 'controls the default for how close the student answer has to be in order to be marked correct.' - . '

A value such as 0.1 means 0.1 percent error is allowed.

' - ), - type => 'number' - }, - { - var => 'pg{specialPGEnvironmentVars}{waiveExplanations}', - doc => x('Skip explanation essay answer fields'), - doc2 => x( - 'Some problems have an explanation essay answer field, typically following a simpler answer field. ' - . 'For example, find a certain derivative using the definition. An answer blank would be present ' - . 'for the derivative to be automatically checked, and then there would be a separate essay answer ' - . 'field to show the steps of actually using the definition of the derivative, to be scored ' - . 'manually. With this setting, the essay explanation fields are supperessed. Instructors may ' - . 'use the exercise without incurring the manual grading.' - ), - type => 'boolean' - }, - ], - [ - x('E-Mail'), - { - var => 'mail{feedbackSubjectFormat}', - doc => x('Format for the subject line in feedback e-mails'), - doc2 => x( - 'When students click the Email Instructor button to send feedback, WeBWorK fills in the ' - . 'subject line. Here you can set the subject line. In it, you can have various bits of ' - . 'information filled in with the following escape sequences.

  • %c = course ID
  • ' - . '
  • %u = user ID
  • %s = set ID
  • %p = problem ID
  • %x = section
  • ' - . '
  • %r = recitation
  • %% = literal percent sign
' - ), - width => 45, - type => 'text' - }, - { - var => 'mail{feedbackVerbosity}', - doc => x('E-mail verbosity level'), - doc2 => x( - 'The e-mail verbosity level controls how much information is automatically added to feedback e-mails. ' - . 'Levels are
  1. Simple: send only the feedback comment and context link
  2. ' - . '
  3. Standard: as in Simple, plus user, set, problem, and PG data
  4. ' - . '
  5. Debug: as in Standard, plus the problem environment (debugging data)
  6. ' - . '
' - ), - labels => { - '0' => 'Simple', - '1' => 'Standard', - '2' => 'Debug' - }, - values => [qw(0 1 2)], - type => 'popuplist' - - }, - { - var => 'mail{allowedRecipients}', - doc => x('E-mail addresses which can receive e-mail from a pg problem'), - doc2 => x( - 'List of e-mail addresses to which e-mail can be sent by a problem. Professors need to be added to ' - . 'this list if questionaires are used, or other WeBWorK problems which send e-mail as part of ' - . 'their answer mechanism.' - ), - type => 'list' - }, - { - var => 'permissionLevels{receive_feedback}', - doc => x('E-mail feedback from students automatically sent to this permission level and higher'), - doc2 => x( - 'Users with this permssion level or greater will automatically be sent feedback from students ' - . '(generated when they use the "Contact instructor" button on any problem page). In addition ' - . 'the feedback message will be sent to addresses listed below. To send ONLY to addresses listed ' - . 'below set permission level to "nobody".' - ), - type => 'permission' - }, - { - var => 'mail{feedbackRecipients}', - doc => x('Additional addresses for receiving feedback e-mail'), - doc2 => x( - 'By default, feedback is sent to all users above who have permission to receive feedback. Feedback ' - . 'is also sent to any addresses specified in this blank. Separate email address entries by ' - . 'commas.' - ), - type => 'list' - }, - { - var => 'feedback_by_section', - doc => x('Feedback by Section.'), - doc2 => x( - 'By default, feedback is always sent to all users specified to recieve feedback. This variable sets ' - . 'the system to only email feedback to users who have the same section as the user initiating the ' - . 'feedback. I.e., feedback will only be sent to section leaders.' - ), - type => 'boolean' - }, - ], -]; - -################################################################################ -# Site wide overrides are entered into the file localOverrides.conf -################################################################################ -#include("conf/localOverrides.conf"); - -1; #final line of the file to reassure perl that it was read properly. diff --git a/lib/WeBWorK/conf/site.conf b/lib/WeBWorK/conf/site.conf deleted file mode 100644 index 5b3f04c44..000000000 --- a/lib/WeBWorK/conf/site.conf +++ /dev/null @@ -1,337 +0,0 @@ -#!perl -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/conf/site.conf.dist,v 1.225 2010/05/18 18:03:31 apizer Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -# This file is used to set up the default WeBWorK course environment for all -# requests. Values may be overwritten by the course.conf for a specific course. -# All package variables set in this file are added to the course environment. -# If you wish to set a variable here but omit it from the course environment, -# use the "my" keyword. The $webwork_dir variable is set in the WeBWorK Apache -# configuration file (webwork.apache-config) and is available for use here. In -# addition, the $courseName variable holds the name of the current course. - -# This file is used to set up the basic paths and URLs specific to your -# installation of WeBWorK, with the exception of the $webwork_dir variable which -# is set in the WeBWorK Apache configuration file (webwork.apache2-config). -# Any customization of global WeBWorK settings should be done in localOverrides.conf. - -################################################################################ -# site.conf -- this file -################################################################################ - -# site.conf includes all of the information specific to your server required -# to run WeBWorK. - -################################################################################ -# Seed variables -################################################################################ - -# Set these variables to correspond to your configuration. It is not -# recommended to change any of the settings in this file once your -# web server has been initially configured. - -# URL of WeBWorK handler. If WeBWorK is to be on the web server root, use "". Note -# that using "" may not work so we suggest sticking with "/webwork2". -$webwork_url = '/webwork2'; -$server_root_url = $ENV{SITE_HOST} || 'http://localhost:3000'; # e.g. 'https://webwork.yourschool.edu' or 'http://localhost' - # Note, if running a secure (ssl) server, you probably need 'https://...' - -# The following two variables must match the user ID and group ID respectively -# under which apache is running. -# In the apache configuration file (often called httpd.conf) you will find -# User www-data --- this is the $server_userID -- of course it may be wwhttpd or some other name -# Group wwdata --- this is the $server_groupID -- this will have different names also - -$server_userID = 'www-data'; -$server_groupID = 'wwdata'; - - -# Uncomment out the following line to set your apache version number manually. -# WeBWorK will automatically get the apache version directly from the server -# banner. If you remove the version from the server banner you will have to -# set it directly here - -#$server_apache_version = ''; # e.g. '2.22.1' - -# The following variable is the address that will be listed in server error -# messages that come from WeBWorK: -# "An error occured while processing your request. -# For help, please send mail to this site's webmaster -# (mail link to ), including all of the following -# information as well as what what you were doing when the error occurred... etc..." -# Make sure that your webwork.apacheX-config file is up to date with the distributed version -# and that the line $ENV{WEBWORK_SERVER_ADMIN} = $ce->{webwork_server_admin_email}; -# is present in the file. -# If $webwork_server_admin_email is not defined then the -# ServerAdmin address defined in httpd.conf is used. -# Be sure to use single quotes for the address or the @ sign will be interpreted as an array. - - -$webwork_server_admin_email =''; -################################################################################ -# Paths to external programs -################################################################################ - -# These applications are often found in /bin, but sometimes in /usr/bin -# or even in /opt/local/bin. -# You can use "which tar" for example to find out where the "tar" program is located - -#################################################### -# system utilities -#################################################### -$externalPrograms{mv} = "/bin/mv"; -$externalPrograms{cp} = "/bin/cp"; -$externalPrograms{rm} = "/bin/rm"; -$externalPrograms{mkdir} = "/bin/mkdir"; -$externalPrograms{tar} = "/bin/tar"; -$externalPrograms{gzip} = "/bin/gzip"; -$externalPrograms{git} = "/usr/bin/git"; - -#################################################### -# equation rendering/hardcopy utiltiies -#################################################### -$externalPrograms{latex} ="/usr/bin/latex"; - -$externalPrograms{pdflatex} ="/usr/bin/pdflatex --shell-escape"; -# Consider using xelatex instead of pdflatex for multilingual use, and -# use polyglossia and fontspec packages (which require xelatex or lualatex). -#$externalPrograms{pdflatex} ="/usr/bin/xelatex --shell-escape"; - -$externalPrograms{dvipng} ="/usr/bin/dvipng"; - -# In order to use imagemagick convert you need to change the rights for PDF files from -# "none" to "read" in the policy file /etc/ImageMagick-6/policy.xml. This has possible -# security implications for the server. -$externalPrograms{convert} = "/usr/bin/convert"; - -$externalPrograms{dvisvgm} = "/usr/bin/dvisvgm"; -$externalPrograms{pdf2svg} = "/usr/bin/pdf2svg"; - -#################################################### -# NetPBM - basic image manipulation utilities -# Most sites only need to configure $netpbm_prefix. -#################################################### -my $netpbm_prefix = "/usr/bin"; -$externalPrograms{giftopnm} = "$netpbm_prefix/giftopnm"; -$externalPrograms{ppmtopgm} = "$netpbm_prefix/ppmtopgm"; -$externalPrograms{pnmtops} = "$netpbm_prefix/pnmtops"; -$externalPrograms{pnmtopng} = "$netpbm_prefix/pnmtopng"; -$externalPrograms{pngtopnm} = "$netpbm_prefix/pngtopnm"; - -#################################################### -# url checker -#################################################### -# set timeout time (-t 40 sec) to be less than timeout for problem (usually 60 seconds) -$externalPrograms{checkurl} = "/usr/bin/curl -Is -m 30 "; # or "/usr/local/bin/w3c -head " -$externalPrograms{curl} = "/usr/bin/curl"; - -#################################################### -# image conversions utiltiies -# the source file is given on stdin, and the output expected on stdout. -#################################################### - -$externalPrograms{gif2eps} = "$externalPrograms{giftopnm} | $externalPrograms{ppmtopgm} | $externalPrograms{pnmtops} -noturn 2>/dev/null"; -$externalPrograms{png2eps} = "$externalPrograms{pngtopnm} | $externalPrograms{ppmtopgm} | $externalPrograms{pnmtops} -noturn 2>/dev/null"; -$externalPrograms{gif2png} = "$externalPrograms{giftopnm} | $externalPrograms{pnmtopng}"; - -#################################################### -# mysql clients -#################################################### - -$externalPrograms{mysql} ="/usr/bin/mysql"; -$externalPrograms{mysqldump} ="/usr/bin/mysqldump"; - - -#################################################### -# End paths to external utilities. -#################################################### - -################################################################################ -# Database options -################################################################################ - - -# Standard permissions command used to initialize the webwork database -# GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX, LOCK TABLES ON webwork.* TO webworkWrite@localhost IDENTIFIED BY 'passwordRW'; -# where webworkWrite and passwordRW must match the corresponding variables in the next section. - -################################################################################ -# these variables are used by database.conf. we define them here so that editing -# database.conf isn't necessary. - -# You must initialize the database and set the password for webworkWrite. -# Edit the $database_password line and replace 'passwordRW' by the actual password used in the GRANT command above -################################################################################ - -# The database dsn is the path to the WeBWorK database which you have created. -# Unless you have given the database a different name or the database resides on another -# server you do not need to change this first value. -# The format is dbi:mysql:[databasename] for databases on the local machine -# For a remote database the format is dbi:mysql:[databasename]:[hostname]:[port] -$database_dsn ="dbi:Pg:dbname=webwork;host=localhost"; -$database_storage_engine = 'myisam'; - -######################### -# MYSQL compatibility settings for handling international Unicode characters (utf8 and utf8mb) -######################### -# These set the way characters are encoded in mysql and will depend on the version of mysqld being used. -# the default is to use latin1. With version 2.15 we will move to -# encoding utf8mb4 which allows the encoding of characters from many languages -# including chinese, arabic and hebrew. - -$ENABLE_UTF8MB4 =1; # setting this to 1 enables utf8mb4 encoding, setting this to - # 0 sets this for older mysql (pre 5.3) which cannot - # handle utf8mb4 characters. - -$database_character_set=($ENABLE_UTF8MB4) ? 'utf8mb4' : 'utf8'; - - -# DATABASE login information -# The following two variables must match the GRANT statement run on the mysql server as described above. -$database_username ="postgres"; -$database_password ="postgres"; - -################################################################################# -# These variables describe the locations of various components of WeBWorK on your -# server. You may use the defaults unless you have things in different places. -################################################################################# - -# Root directory of PG. -$pg_dir = "$ENV{RENDER_ROOT}/lib/PG"; - -# URL and path to htdocs directory. -$webwork_htdocs_url = "$ENV{baseURL}/webwork2_files"; -$webwork_htdocs_dir = "$webwork_dir/htdocs"; - -# URL and path to courses directory. -$webwork_courses_url = "$ENV{baseURL}/webwork2_course_files"; -$webwork_courses_dir = "$ENV{RENDER_ROOT}"; # standalone renderer has no courses - - -################################################################################ -# Mail settings -################################################################################ - -# The following directives need to be configured in order for your webwork -# server to be able to send mail. - -# Mail sent by the PG system and the mail merge and feedback modules will be -# sent via this SMTP server. localhost may work if your server is capable -# of sending email, otherwise type the name of your School's outgoing email -# server. -$mail{smtpServer} = ''; # e.g. 'mail.yourschool.edu' or 'localhost' - -# When connecting to the above server, WeBWorK will send this address in the -# MAIL FROM command. This has nothing to do with the "From" address on the mail -# message. It can really be anything, but some mail servers require it contain -# a valid mail domain, or at least be well-formed. -$mail{smtpSender} = ''; # e.g. 'webwork@yourserver.yourschool.edu' - -# Be sure to use single quotes for the address or the @ sign will be interpreted as an array. - -# Seconds to wait before timing out when connecting to the SMTP server. -# the default is 120 seconds. -# Change it by uncommenting the following line -# set it to 5 for testing, 30 or larger for production - -$mail{smtpTimeout} = 30; - - -# TLS is a method for providing secure connections to the smtp server. -# https://en.wikipedia.org/wiki/Transport_Layer_Security -# At some sites coordinating the certificates properly is tricky -# Set this value to 0 to avoid checking certificates. -# Set it to 0 to trouble shoot an inability to verify certificates with the smtp server - -$mail{tls_allowed} = 0; - -#$tls_allowed=0; #old method -- this variable no longer works. - - -# errors of the form -# unable to establish SMTP connection to smtp-gw.rochester.edu port 465 -# indicate that there is a mismatch between the port number and the use of ssl -# use port 25 when ssl is off and use port 465 when ssl is on (tls_allowed=1) - - -# Set the SMTP port manually. Typically this does not need to be done it will use -# port 25 if no SSL is on and 465 if ssl is on - -#$mail{smtpPort} = 25; - -# Debugging tutorial for sending email using ssl/tls -# https://maulwuff.de/research/ssl-debugging.html - -################################################################################ -# Problem library options -################################################################################ -# -# The problemLibrary configuration data should now be set in localOverrides.conf - -# For configuration instructions, see: -# http://webwork.maa.org/wiki/National_Problem_Library -# The directory containing the Open Problem Library files. -# Set the root to "" if no problem -# library is installed. Use version 2.0 for the NPL and use the version 2.5 for the OPL. -# When changing from the NPL to the OPL it is important to change the version number -# because the names of the tables in the database have changed. - -# RE-CONFIGURE problemLibrary values in the localOverrides.conf file. -# The settings in site.conf are overridden by settings in default.config -################################################# -#$problemLibrary{root} ="/opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary"; -########################################################### - -################################################################################ -#Time Zone -################################################################################ - -# Set the default timezone of courses on this server. To get a list of valid -# timezones, run: -# -# perl -MDateTime::TimeZone -e 'print join "\n", DateTime::TimeZone::all_names' -# -# To get a list of valid timezone "links" (deprecated names), run: -# -# perl -MDateTime::TimeZone -e 'print join "\n", DateTime::TimeZone::links' -# -# If left blank, the system timezone will be used. This is usually what you -# want. You might want to set this if your server is NOT in the same timezone as -# your school. If just a few courses are in a different timezone, set this in -# course.conf for the affected courses instead. -# -$siteDefaults{timezone} = "America/New_York"; - -# Locale for time format localization -# Set the following variable to localize the format of things like days -# of the week and month names (i.e. translate them) -# This variable must match one of the locales available on your system -# To show the current locale in use on the system, type 'locale' at the -# command prompt. For a list of installed locales, type 'locale -a' and -# enter one of the listed values here. -# If you do not fill this in, the system will default to "en_US" -$siteDefaults{locale}=""; - -################################################################################ -# Search Engine Indexing Enable/Disable -################################################################################ -# sets the default meta robots content for individual course pages -# this will not stop your main course listing page from being indexed -# valid contents: index, noindex, follow, nofollow, noarchive, and -# unavailable_after (example: "index, unavailable_after: 23-Jul-2007 18:00:00 EST") -$options{metaRobotsContent}='noindex, nofollow'; - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/Constants.pm b/lib/WeBWorK/lib/WeBWorK/Constants.pm deleted file mode 100644 index ee889ead4..000000000 --- a/lib/WeBWorK/lib/WeBWorK/Constants.pm +++ /dev/null @@ -1,120 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/Constants.pm,v 1.62 2010/02/01 01:57:56 apizer Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::Constants; - -=head1 NAME - -WeBWorK::Constants - provide constant values for other WeBWorK modules. - -=cut - -use strict; -use warnings; - -$WeBWorK::Constants::WEBWORK_DIRECTORY = $ENV{RENDER_ROOT}."/lib/WeBWorK" unless defined($WeBWorK::Constants::WEBWORK_DIRECTORY); - - -################################################################################ -# WeBWorK::Debug -################################################################################ - -# If true, WeBWorK::Debug will print debugging output. -# -$WeBWorK::Debug::Enabled = 0; - -# If non-empty, debugging output will be sent to the file named rather than STDERR. -# -$WeBWorK::Debug::Logfile = $WeBWorK::Constants::WEBWORK_DIRECTORY . "/logs/debug.log"; - -# If defined, prevent subroutines matching the following regular expression from -# logging. -# -# For example, this pattern prevents the dispatch() function from logging: -# $WeBWorK::Debug::DenySubroutineOutput = qr/^WeBWorK::dispatch$/; -# -$WeBWorK::Debug::DenySubroutineOutput = undef; -#$WeBWorK::Debug::DenySubroutineOutput = qr/^WeBWorK::dispatch$/; - -# If defined, allow only subroutines matching the following regular expression -# to log. -# -# For example, this pattern allow only some function being worked on to log: -# $WeBWorK::Debug::AllowSubroutineOutput = qr/^WeBWorK::SomePkg::myFunc$/; -# -# $WeBWorK::Debug::AllowSubroutineOutput = undef; -# $WeBWorK::Debug::AllowSubroutineOutput =qr/^WeBWorK::Authen::get_credentials$/; - -################################################################################ -# WeBWorK::ContentGenerator::Hardcopy -################################################################################ - -# If true, don't delete temporary files -# -$WeBWorK::ContentGenerator::Hardcopy::PreserveTempFiles = 0; - -################################################################################ -# WeBWorK::PG::Local -################################################################################ -# The maximum amount of time (in seconds) to work on a single problem. -# At the end of this time a timeout message is sent to the browser. - -$WeBWorK::PG::Local::TIMEOUT = 60; - -################################################################################ -# WeBWorK::PG::ImageGenerator -################################################################################ - -# Arguments to pass to dvipng. This is dependant on the version of dvipng. -# -# For dvipng versions 0.x -# $WeBWorK::PG::ImageGenerator::DvipngArgs = "-x4000.5 -bgTransparent -Q6 -mode toshiba -D180"; -# For dvipng versions 1.0 to 1.5 -# $WeBWorK::PG::ImageGenerator::DvipngArgs = "-bgTransparent -D120 -q -depth"; -# -# For dvipng versions 1.6 (and probably above) -# $WeBWorK::PG::ImageGenerator::DvipngArgs = "-bgtransparent -D120 -q -depth"; -# Note: In 1.6 and later, bgTransparent gives alpha-channel transparency while -# bgtransparent gives single-bit transparency. If you use alpha-channel transparency, -# the images will not be viewable with MSIE. bgtransparent works for version 1.5, -# but does not give transparent backgrounds. It does not work for version 1.2. It has not -# been tested with other versions. -# -$WeBWorK::PG::ImageGenerator::DvipngArgs = "-bgTransparent -D120 -q -depth"; - -# If true, don't delete temporary files -# -$WeBWorK::PG::ImageGenerator::PreserveTempFiles = 0; -# TeX to prepend to equations to be processed. -# -$WeBWorK::PG::ImageGenerator::TexPreamble = <<'EOF'; -\documentclass[12pt]{article} -\nonstopmode -\usepackage{amsmath,amsfonts,amssymb} -\def\gt{>} -\def\lt{<} -\usepackage[active,textmath,displaymath]{preview} -\begin{document} -EOF - -# TeX to append to equations to be processed. -# -$WeBWorK::PG::ImageGenerator::TexPostamble = <<'EOF'; -\end{document} -EOF - - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/CourseEnvironment.pm b/lib/WeBWorK/lib/WeBWorK/CourseEnvironment.pm deleted file mode 100644 index 789cd5164..000000000 --- a/lib/WeBWorK/lib/WeBWorK/CourseEnvironment.pm +++ /dev/null @@ -1,381 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2019 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/CourseEnvironment.pm,v 1.37 2007/08/10 16:37:10 sh002i Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::CourseEnvironment; - -=head1 NAME - -WeBWorK::CourseEnvironment - Read configuration information from defaults.config -and course.conf files. - -=head1 SYNOPSIS - - use WeBWorK::CourseEnvironment; - $ce = WeBWorK::CourseEnvironment->new({ - webwork_url => "/webwork2", - webwork_dir => "/opt/webwork2", - pg_dir => "/opt/pg", - webwork_htdocs_url => "/webwork2_files", - webwork_htdocs_dir => "/opt/webwork2/htdocs", - webwork_courses_url => "/webwork2_course_files", - webwork_courses_dir => "/opt/webwork2/courses", - courseName => "name_of_course", - }); - - my $timeout = $courseEnv->{sessionKeyTimeout}; - my $mode = $courseEnv->{pg}->{options}->{displayMode}; - # etc... - -=head1 DESCRIPTION - -The WeBWorK::CourseEnvironment module reads the system-wide F and -course-specific F files used by WeBWorK to calculate and store -settings needed throughout the system. The F<.conf> files are perl source files -that can contain any code allowed under the default safe compartment opset. -After evaluation of both files, any package variables are copied out of the -safe compartment into a hash. This hash becomes the course environment. - -=cut - -use strict; -use warnings; -use Carp; -use WWSafe; -use WeBWorK::Utils qw(readFile); -use WeBWorK::Debug; -use Opcode qw(empty_opset); - -=head1 CONSTRUCTION - -=over - -=item new(HASHREF) - -HASHREF is a reference to a hash containing scalar variables with which to seed -the course environment. It must contain at least a value for the key -C. - -The C method finds the file F relative to the given -C directory. After reading this file, it uses the -C<$courseFiles{environment}> variable, if present, to locate the course -environment file. If found, the file is read and added to the environment. - -=item new(ROOT URLROOT PGROOT COURSENAME) - -A deprecated form of the constructor in which four seed variables are given -explicitly: C, C, C, and C. - -=cut - -# NEW SYNTAX -# -# new($invocant, $seedVarsRef) -# $invocant implicitly set by caller -# $seedVarsRef reference to hash containing scalar variables with which to -# seed the course environment -# -# OLD SYNTAX -# -# new($invocant, $webworkRoot, $webworkURLRoot, $pgRoot, $courseName) -# $invocant implicitly set by caller -# $webworkRoot directory that contains the WeBWorK distribution -# $webworkURLRoot URL that points to the WeBWorK system -# $pgRoot directory that contains the PG distribution -# $courseName name of the course being used -sub new { - my ($invocant, @rest) = @_; - my $class = ref($invocant) || $invocant; - - # contains scalar symbols/values with which to seed course environment - my %seedVars; - - # where do we get the seed variables? - if (ref $rest[0] eq "HASH") { - %seedVars = %{$rest[0]}; - } else { - debug __PACKAGE__, ": deprecated four-argument form of new() used.", caller(1),"\n", caller(2),"\n"; - $seedVars{webwork_dir} = $rest[0]; - $seedVars{webwork_url} = $rest[1]; - $seedVars{pg_dir} = $rest[2]; - $seedVars{courseName} = $rest[3]; - } - $seedVars{courseName} = $seedVars{courseName}||"___"; # prevents extraneous error messages - my $safe = WWSafe->new; - $safe->permit('rand'); - # to avoid error messages make sure that courseName is defined - $seedVars{courseName} = $seedVars{courseName}//"foobar_course"; - # seed course environment with initial values - while (my ($var, $val) = each %seedVars) { - $val = "" if not defined $val; - $safe->reval("\$$var = '$val';"); - } - - # Compile the "include" function with all opcodes available. - my $include = q[ sub include { - my ($file) = @_; - my $fullPath = "].$seedVars{webwork_dir}.q[/$file"; - # This regex matches any string that begins with "../", - # ends with "/..", contains "/../", or is "..". - if ($fullPath =~ m!(?:^|/)\.\.(?:/|$)!) { - die "Included file $file has potentially insecure path: contains \"..\""; - } else { - local @INC = (); - my $result = do $fullPath; - if ($!) { - die "Failed to read include file $fullPath (has it been created from the corresponding .dist file?): $!"; - } elsif ($@) { - die "Failed to compile include file $fullPath: $@"; - } elsif (not $result) { - die "Include file $fullPath did not return a true value."; - } - } - } ]; - - my $maskBackup = $safe->mask; - $safe->mask(empty_opset); - $safe->reval($include); - $@ and die "Failed to reval include subroutine: $@"; - $safe->mask($maskBackup); - - # determine location of globalEnvironmentFile - my $globalEnvironmentFile; - if (-r "$seedVars{webwork_dir}/conf/defaults.config") { - $globalEnvironmentFile = "$seedVars{webwork_dir}/conf/defaults.config"; - } else { - croak "Cannot read global environment file $globalEnvironmentFile"; - } - - # read and evaluate the global environment file - my $globalFileContents = readFile($globalEnvironmentFile); - # warn "about to evaluate defaults.conf $seedVars{courseName}\n"; - # warn join(" | ", (caller(1))[0,1,2,3,4] ), "\n"; - $safe->share_from('main', [qw(%ENV)]); - $safe->reval($globalFileContents); - # warn "end the evaluation\n"; - - - - - # if that evaluation failed, we can't really go on... - # we need a global environment! - $@ and croak "Could not evaluate global environment file $globalEnvironmentFile: $@"; - - # determine location of courseEnvironmentFile and simple configuration file - # pull it out of $safe's symbol table ad hoc - # (we don't want to do the hash conversion yet) - no strict 'refs'; - my $courseEnvironmentFile = ${*{${$safe->root."::"}{courseFiles}}}{environment}; - my $courseWebConfigFile = $seedVars{web_config_filename} || - ${*{${$safe->root."::"}{courseFiles}}}{simpleConfig}; - use strict 'refs'; - - # make sure the course environment file actually exists (it might not if we don't have a real course) - # before we try to read it - if(-r $courseEnvironmentFile){ - # read and evaluate the course environment file - # if readFile failed, we don't bother trying to reval - my $courseFileContents = eval { readFile($courseEnvironmentFile) }; # catch exceptions - $@ or $safe->reval($courseFileContents); - my $courseWebConfigContents = eval { readFile($courseWebConfigFile) }; # catch exceptions - $@ or $safe->reval($courseWebConfigContents); - } - - # get the safe compartment's namespace as a hash - no strict 'refs'; - my %symbolHash = %{$safe->root."::"}; - use strict 'refs'; - - # convert the symbol hash into a hash of regular variables. - my $self = {}; - foreach my $name (keys %symbolHash) { - # weed out internal symbols - next if $name =~ /^(INC|_.*|__ANON__|main::|include)$/; - # pull scalar, array, and hash values for this symbol - my $scalar = ${*{$symbolHash{$name}}}; - my @array = @{*{$symbolHash{$name}}}; - my %hash = %{*{$symbolHash{$name}}}; - # for multiple variables sharing a symbol, scalar takes precedence - # over array, which takes precedence over hash. - if (defined $scalar) { - $self->{$name} = $scalar; - } elsif (@array) { - $self->{$name} = \@array; - } elsif (%hash) { - $self->{$name} = \%hash; - } - } - # now that we know the name of the pg_dir we can get the pg VERSION file - my $PG_version_file = $self->{'pg_dir'}."/VERSION"; - - # Try a fallback location - if ( !-r $PG_version_file ) { - $PG_version_file = $self->{'webwork_dir'}."/../PG/VERSION"; - } - # # We'll get the pg version here and read it into the safe symbol table - if (-r $PG_version_file){ - #print STDERR ( "\n\nread PG_version file $PG_version_file\n\n"); - my $PG_version_file_contents = readFile($PG_version_file)//''; - $safe->reval($PG_version_file_contents); - #print STDERR ("\n contents: $PG_version_file_contents"); - - no strict 'refs'; - my %symbolHash2 = %{$safe->root."::"}; - #print STDERR "symbolHash".join(' ', keys %symbolHash2); - use strict 'refs'; - $self->{PG_VERSION}=${*{$symbolHash2{PG_VERSION}}}; - } else { - $self->{PG_VERSION}="unknown"; - #croak "Cannot read PG version file $PG_version_file"; - warn "Cannot read PG version file $PG_version_file"; - } - - - bless $self, $class; - - # here is where we can do evil things to the course environment *sigh* - # anything changed has to be done here. after this, CE is considered read-only - # anything added must be prefixed with an underscore. - - # create reverse-lookup hash mapping status abbreviations to real names - $self->{_status_abbrev_to_name} = { - map { my $name = $_; map { $_ => $name } @{$self->{statuses}{$name}{abbrevs}} } - keys %{$self->{statuses}} - }; - - # now that we're done, we can go ahead and return... - return $self; -} - -=back - -=head1 ACCESS - -There are no formal accessor methods. However, since the course environemnt is -a hash of hashes and arrays, is exists as the self hash of an instance -variable: - - $ce->{someKey}{someOtherKey}; - -=head1 EXPERIMENTAL ACCESS METHODS - -This is an experiment in extending CourseEnvironment to know a little more about -its contents, and perform useful operations for me. - -There is a set of operations that require certain data from the course -environment. Most of these are un Utils.pm. I've been forced to pass $ce into -them, so that they can get their data out. But some things are so intrinsically -linked to the course environment that they might as well be methods in this -class. - -=head2 STATUS METHODS - -=over - -=item status_abbrev_to_name($status_abbrev) - -Given the abbreviation for a status, return the name. Returns undef if the -abbreviation is not found. - -=cut - -sub status_abbrev_to_name { - my ($ce, $status_abbrev) = @_; - if (not defined $status_abbrev or $status_abbrev eq "") { - carp "status_abbrev_to_name: status_abbrev (first argument) must be defined and non-empty"; - return; - } - - return $ce->{_status_abbrev_to_name}{$status_abbrev}; -} - -=item status_name_to_abbrevs($status_name) - -Returns the list of abbreviations for a given status. Returns an empty list if -the status is not found. - -=cut - -sub status_name_to_abbrevs { - my ($ce, $status_name) = @_; - if (not defined $status_name or $status_name eq "") { - carp "status_name_to_abbrevs: status_name (first argument) must be defined and non-empty"; - return; - } - - return unless exists $ce->{statuses}{$status_name}; - return @{$ce->{statuses}{$status_name}{abbrevs}}; -} - -=item status_has_behavior($status_name, $behavior) - -Return true if $status_name lists $behavior. - -=cut - -sub status_has_behavior { - my ($ce, $status_name, $behavior) = @_; - if (not defined $status_name or $status_name eq "") { - carp "status_has_behavior: status_name (first argument) must be defined and non-empty"; - return; - } - if (not defined $behavior or $behavior eq "") { - carp "status_has_behavior: behavior (second argument) must be defined and non-empty"; - return; - } - - if (exists $ce->{statuses}{$status_name}) { - if (exists $ce->{statuses}{$status_name}{behaviors}) { - my $num_matches = grep { $_ eq $behavior } @{$ce->{statuses}{$status_name}{behaviors}}; - return $num_matches > 0; - } else { - return 0; # no behaviors - } - } else { - warn "status '$status_name' not found in \%statuses -- assuming no behaviors.\n"; - return 0; - } -} - -=item status_abbrev_has_behavior($status_abbrev, $behavior) - -Return true if the status abbreviated by $status_abbrev lists $behavior. - -=cut - -sub status_abbrev_has_behavior { - my ($ce, $status_abbrev, $behavior) = @_; - if (not defined $status_abbrev or $status_abbrev eq "") { - carp "status_abbrev_has_behavior: status_abbrev (first argument) must be defined and non-empty"; - return; - } - if (not defined $behavior or $behavior eq "") { - carp "status_abbrev_has_behavior: behavior (second argument) must be defined and non-empty"; - return; - } - - my $status_name = $ce->status_abbrev_to_name($status_abbrev); - if (defined $status_name) { - return $ce->status_has_behavior($status_name, $behavior); - } else { - warn "status abbreviation '$status_abbrev' not found in \%statuses -- assuming no behaviors.\n"; - } -} - -=back - -=cut - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/Debug.pm b/lib/WeBWorK/lib/WeBWorK/Debug.pm deleted file mode 100644 index e30abf9e2..000000000 --- a/lib/WeBWorK/lib/WeBWorK/Debug.pm +++ /dev/null @@ -1,146 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/Debug.pm,v 1.10 2006/06/28 16:20:39 sh002i Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::Debug; -use base qw(Exporter); -use Date::Format; -our @EXPORT = qw(debug); - -=head1 NAME - -WeBWorK::Debug - Print (or don't print) debugging output. - -=head1 SYNOPSIS - - use WeBWorK::Debug; - - # Enable debugging - $WeBWorK::Debug::Enabled = 1; - - # Log to a file instead of STDERR - $WeBWorK::Debug::Logfile = "/path/to/debug.log"; - - # log some debugging output - debug("Generated 5 widgets."); - -=cut - -use strict; -use warnings; -use Time::HiRes qw/gettimeofday/; -use WeBWorK::Constants; -use WeBWorK::Utils qw/undefstr/; - -################################################################################ - -=head1 CONFIGURATION VARIABLES - -=over - -=item $Enabled - -If true, debugging messages will be output. If false, they will be ignored. - -=cut - -our $Enabled = 0 unless defined $Enabled; - -=item $Logfile - -If non-empty, debugging output will be sent to the file named rather than STDERR. - -=cut - -our $Logfile = "" unless defined $Logfile; - -=item $DenySubroutineOutput - -If defined, prevent subroutines matching the following regular expression from -logging. - -=cut - -our $DenySubroutineOutput; - -=item $AllowSubroutineOutput - -If defined, allow only subroutines matching the following regular expression to -log. - -=cut - -our $AllowSubroutineOutput; - -=back - -=cut - -################################################################################ - -=head1 FUNCTIONS - -=over - -=item debug(@messages) - -Write @messages to the debugging log. - -=cut - -sub debug { - my (@message) = undefstr("###UNDEF###", @_); - - #print STDERR "in ww::debug\n"; - #print STDERR $WeBWorK::Constants::WEBWORK_DIRECTORY . "\n"; - #print STDERR $Logfile . "\n"; - - if ($Enabled) { - my ($package, $filename, $line, $subroutine) = caller(1); - return if defined $AllowSubroutineOutput and not $subroutine =~ m/$AllowSubroutineOutput/; - return if defined $DenySubroutineOutput and $subroutine =~ m/$DenySubroutineOutput/; - - my ($sec, $msec) = gettimeofday; - my $date = time2str("%a %b %d %H:%M:%S.$msec %Y", $sec); - my $finalMessage = "[$date] $subroutine: " . join("", @message); - $finalMessage .= "\n" unless $finalMessage =~ m/\n$/; - - if ($WeBWorK::Debug::Logfile ne "") { - if (open my $fh, ">>", $Logfile) { - print $fh $finalMessage; - close $fh; - } else { - warn "Failed to open debug log '$Logfile' in append mode: $!"; - print STDERR $finalMessage; - } - } else { - print STDERR $finalMessage; - } - } -} - -=back - -=cut - -################################################################################ - -=head1 AUTHOR - -Written by Sam Hathaway, sh002i (at) math.rochester.edu. - -=cut - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/PG.pm b/lib/WeBWorK/lib/WeBWorK/PG.pm deleted file mode 100644 index edba44011..000000000 --- a/lib/WeBWorK/lib/WeBWorK/PG.pm +++ /dev/null @@ -1,532 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.76 2009/07/18 02:52:51 gage Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::PG; - -=head1 NAME - -WeBWorK::PG - Invoke one of several PG rendering methods using an easy-to-use -API. - -=cut - -use strict; -use warnings; -no warnings qw( redefine ); -use WeBWorK::Debug; -use WeBWorK::PG::ImageGenerator; -use WeBWorK::Utils qw(runtime_use formatDateTime makeTempDirectory); -use WeBWorK::Utils::RestrictedClosureClass; #likely removable... -use WeBWorK::Localize; -use DateTime; -use DateTime::Duration; - -use constant DISPLAY_MODES => { - # display name # mode name - tex => "TeX", - plainText => "HTML", - images => "HTML_dpng", - MathJax => "HTML_MathJax", - PTX => "PTX", -}; - -sub new { - shift; # throw away invocant -- we don't need it - my ($ce, $user, $key, $set, $problem, $psvn, $formFields, - $translationOptions) = @_; - - my $renderer = "WeBWorK::PG::Local"; - - runtime_use $renderer; - - return $renderer->new(@_); -} - -sub free { - my $self = shift; - # - # If certain MathObjects (e.g. LimitedPolynomials) are left in the PG structure, then - # freeing them later can cause "Can't locate package ..." errors in the log during - # perl garbage collection. So free them here. - # - $self->{pgcore}{OUTPUT_ARRAY} = []; - $self->{answers} = {}; - undef $self->{translator}{safe}; - foreach (keys %{$self->{pgcore}{PG_ANSWERS_HASH}}) {undef $self->{pgcore}{PG_ANSWERS_HASH}{$_}} -} - -sub defineProblemEnvir { - my ( - $self, - $ce, - $user, - $key, - $set, - $problem, - $psvn, - $formFields, - $translationOptions, - $extras, - ) = @_; - - my %envir = %main::envir; - - debug("in WEBWORK::PG"); - - # ---------------------------------------------------------------------- - - # PG environment variables - # from docs/pglanguage/pgreference/environmentvariables as of 06/25/2002 - # any changes are noted by "ADDED:" or "REMOVED:" - - # Vital state information - # ADDED: displayModeFailover, displayHintsQ, displaySolutionsQ, - # refreshMath2img, texDisposition - - $envir{psvn} = $psvn; #'problem set version number' (associated with homework set) - $envir{psvn} = $envir{psvn}//$set->psvn; # use set value of psvn unless there is an explicit override. - # update problemUUID from submitted form, and fall back to the earlier name problemIdentifierPrefix if necessary - $envir{problemUUID} = $formFields->{problemUUID} // - $formFields->{problemIdentifierPrefix} // - $envir{problemUUID}// - 0; - $envir{psvnNumber} = "psvnNumber-is-deprecated-Please-use-psvn-Instead"; #FIXME - $envir{probNum} = $problem->{problem_id}; - $envir{questionNumber} = $envir{probNum}; - $envir{fileName} = $problem->{source_file}; - $envir{probFileName} = $envir{fileName}; - $envir{problemSeed} = $problem->{problem_seed}; - $envir{displayMode} = translateDisplayModeNames($translationOptions->{displayMode}); -# $envir{languageMode} = $envir{displayMode}; # don't believe this is ever used. - $envir{outputMode} = $envir{displayMode}; - $envir{displayHintsQ} = $translationOptions->{showHints}; - $envir{displaySolutionsQ} = $translationOptions->{showSolutions}; - $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex - - # Problem Information - # ADDED: courseName, formatedDueDate, enable_reduced_scoring - -# $envir{openDate} = $set->open_date; -# $envir{formattedOpenDate} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}); -# $envir{OpenDateDayOfWeek} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%A", $ce->{siteDefaults}{locale}); -# $envir{OpenDateDayOfWeekAbbrev} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%a", $ce->{siteDefaults}{locale}); -# $envir{OpenDateDay} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%d", $ce->{siteDefaults}{locale}); -# $envir{OpenDateMonthNumber} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%m", $ce->{siteDefaults}{locale}); -# $envir{OpenDateMonthWord} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%B", $ce->{siteDefaults}{locale}); -# $envir{OpenDateMonthAbbrev} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%b", $ce->{siteDefaults}{locale}); -# $envir{OpenDateYear2Digit} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%y", $ce->{siteDefaults}{locale}); -# $envir{OpenDateYear4Digit} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%Y", $ce->{siteDefaults}{locale}); -# $envir{OpenDateHour12} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%I", $ce->{siteDefaults}{locale}); -# $envir{OpenDateHour24} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%H", $ce->{siteDefaults}{locale}); -# $envir{OpenDateMinute} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%M", $ce->{siteDefaults}{locale}); -# $envir{OpenDateAMPM} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%P", $ce->{siteDefaults}{locale}); -# $envir{OpenDateTimeZone} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%Z", $ce->{siteDefaults}{locale}); -# $envir{OpenDateTime12} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%I:%M%P", $ce->{siteDefaults}{locale}); -# $envir{OpenDateTime24} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone}, "%R", $ce->{siteDefaults}{locale}); -# $envir{dueDate} = $set->due_date; -# $envir{formattedDueDate} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}); -# $envir{formatedDueDate} = $envir{formattedDueDate}; # typo in many header files -# $envir{DueDateDayOfWeek} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%A", $ce->{siteDefaults}{locale}); -# $envir{DueDateDayOfWeekAbbrev} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%a", $ce->{siteDefaults}{locale}); -# $envir{DueDateDay} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%d", $ce->{siteDefaults}{locale}); -# $envir{DueDateMonthNumber} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%m", $ce->{siteDefaults}{locale}); -# $envir{DueDateMonthWord} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%B", $ce->{siteDefaults}{locale}); -# $envir{DueDateMonthAbbrev} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%b", $ce->{siteDefaults}{locale}); -# $envir{DueDateYear2Digit} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%y", $ce->{siteDefaults}{locale}); -# $envir{DueDateYear4Digit} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%Y", $ce->{siteDefaults}{locale}); -# $envir{DueDateHour12} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%I", $ce->{siteDefaults}{locale}); -# $envir{DueDateHour24} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%H", $ce->{siteDefaults}{locale}); -# $envir{DueDateMinute} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%M", $ce->{siteDefaults}{locale}); -# $envir{DueDateAMPM} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%P", $ce->{siteDefaults}{locale}); -# $envir{DueDateTimeZone} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%Z", $ce->{siteDefaults}{locale}); -# $envir{DueDateTime12} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%I:%M%P", $ce->{siteDefaults}{locale}); -# $envir{DueDateTime24} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone}, "%R", $ce->{siteDefaults}{locale}); - $envir{answerDate} = ($formFields->{showSolutions})?DateTime->now->subtract(days=>1)->epoch():DateTime->now->add(days=>1)->epoch(); -# $envir{formattedAnswerDate} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}); -# $envir{AnsDateDayOfWeek} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%A", $ce->{siteDefaults}{locale}); -# $envir{AnsDateDayOfWeekAbbrev} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%a", $ce->{siteDefaults}{locale}); -# $envir{AnsDateDay} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%d", $ce->{siteDefaults}{locale}); -# $envir{AnsDateMonthNumber} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%m", $ce->{siteDefaults}{locale}); -# $envir{AnsDateMonthWord} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%B", $ce->{siteDefaults}{locale}); -# $envir{AnsDateMonthAbbrev} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%b", $ce->{siteDefaults}{locale}); -# $envir{AnsDateYear2Digit} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%y", $ce->{siteDefaults}{locale}); -# $envir{AnsDateYear4Digit} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%Y", $ce->{siteDefaults}{locale}); -# $envir{AnsDateHour12} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%I", $ce->{siteDefaults}{locale}); -# $envir{AnsDateHour24} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%H", $ce->{siteDefaults}{locale}); -# $envir{AnsDateMinute} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%M", $ce->{siteDefaults}{locale}); -# $envir{AnsDateAMPM} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%P", $ce->{siteDefaults}{locale}); -# $envir{AnsDateTimeZone} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%Z", $ce->{siteDefaults}{locale}); -# $envir{AnsDateTime12} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%I:%M%P", $ce->{siteDefaults}{locale}); -# $envir{AnsDateTime24} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone}, "%R", $ce->{siteDefaults}{locale}); - my $ungradedAttempts = ($formFields->{submitAnswers})?1:0; # is an attempt about to be graded? - $envir{numOfAttempts} = ($problem->{num_correct} || 0) + ($problem->{num_incorrect} || 0) +$ungradedAttempts; - $envir{problemValue} = $problem->{value}; - $envir{sessionKey} = $key; - $envir{courseName} = $ce->{courseName}; - $envir{enable_reduced_scoring} = 1; #$ce->{pg}{ansEvalDefaults}{enableReducedScoring} && $set->enable_reduced_scoring; - - $envir{language} = $ce->{language}; - $envir{language_subroutine} = WeBWorK::Localize::getLoc($envir{language}); -# $envir{reducedScoringDate} = $set->reduced_scoring_date; - - # Student Information - # ADDED: studentID - - $envir{sectionName} = $user->{section}; - $envir{sectionNumber} = $envir{sectionName}; - $envir{recitationName} = $user->{recitation}; - $envir{recitationNumber} = $envir{recitationName}; - $envir{setNumber} = $set->{set_id}; - $envir{studentLogin} = $user->{user_id}; - $envir{studentName} = $user->{first_name} . " " . $user->{last_name}; - $envir{studentID} = $user->{student_id}; - $envir{permissionLevel} = $translationOptions->{permissionLevel}; # permission level of actual user - $envir{effectivePermissionLevel} = $translationOptions->{effectivePermissionLevel}; # permission level of user assigned to this question - - - # Answer Information - # REMOVED: refSubmittedAnswers - - $envir{inputs_ref} = $formFields; - - # External Programs - # ADDED: externalLaTeXPath, externalDvipngPath, - # externalGif2EpsPath, externalPng2EpsPath - -# $envir{externalLaTeXPath} = $ce->{externalPrograms}->{latex}; -# $envir{externalDvipngPath} = $ce->{externalPrograms}->{dvipng}; -# $envir{externalGif2EpsPath} = $ce->{externalPrograms}->{gif2eps}; -# $envir{externalPng2EpsPath} = $ce->{externalPrograms}->{png2eps}; -# $envir{externalGif2PngPath} = $ce->{externalPrograms}->{gif2png}; - $envir{externalCheckUrl} = $ce->{externalPrograms}->{checkurl}; - $envir{externalCurlCommand} = $ce->{externalPrograms}->{curl}; - # Directories and URLs - # REMOVED: courseName - # ADDED: dvipngTempDir - # ADDED: jsMathURL - # ADDED: MathJaxURL - # ADDED: asciimathURL - # ADDED: macrosPath - # REMOVED: macrosDirectory, courseScriptsDirectory - # ADDED: LaTeXMathML - -# $envir{cgiDirectory} = undef; -# $envir{cgiURL} = undef; -# $envir{classDirectory} = undef; - $envir{macrosPath} = $ce->{pg}->{directories}{macrosPath}; - $envir{appletPath} = $ce->{pg}->{directories}{appletPath}; - $envir{htmlPath} = $ce->{pg}->{directories}{htmlPath}; - $envir{imagesPath} = $ce->{pg}->{directories}{imagesPath}; - $envir{pdfPath} = $ce->{pg}->{directories}{pdfPath}; - $envir{pgDirectories} = $ce->{pg}->{directories}; - $envir{webworkHtmlDirectory} = $ce->{webworkDirs}->{htdocs}."/"; - $envir{webworkHtmlURL} = $ce->{webworkURLs}->{htdocs}."/"; - $envir{htmlDirectory} = $ce->{courseDirs}->{html}."/"; - $envir{htmlURL} = $ce->{courseURLs}->{html}."/"; - $envir{templateDirectory} = $ce->{courseDirs}->{templates}."/"; - $envir{tempDirectory} = $ce->{courseDirs}->{html_temp}."/"; - $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/"; - $envir{scriptDirectory} = undef; - $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; - $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; - $envir{MathJaxURL} = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js?config=TeX-MML-AM_HTMLorMML-full'; - $envir{server_root_url} = $ce->{server_root_url} || 'http://localhost/failed-lib-webwork-lib-webwork-pg.pm'; - - # Information for sending mail - -# $envir{mailSmtpServer} = $ce->{mail}->{smtpServer}; -# $envir{mailSmtpSender} = $ce->{mail}->{smtpSender}; -# $envir{ALLOW_MAIL_TO} = $ce->{mail}->{allowedRecipients}; - - # Default values for evaluating answers - - my $ansEvalDefaults = $ce->{pg}->{ansEvalDefaults}; - $envir{$_} = $ansEvalDefaults->{$_} foreach (keys %$ansEvalDefaults); - - # ---------------------------------------------------------------------- - - # ADDED: ImageGenerator for images mode - if (defined $extras->{image_generator}) { - #$envir{imagegen} = $extras->{image_generator}; - # only allow access to the add() method -# $envir{imagegen} = new WeBWorK::Utils::RestrictedClosureClass($extras->{image_generator}, 'add','addToTeXPreamble', 'refresh'); - } - - if (defined $extras->{mailer}) { - #my $rmailer = new WeBWorK::Utils::RestrictedClosureClass($extras->{mailer}, - # qw/Open SendEnc Close Cancel skipped_recipients error error_msg/); - #my $safe_hole = new Safe::Hole {}; - #$envir{mailer} = $safe_hole->wrap($rmailer); -# $envir{mailer} = new WeBWorK::Utils::RestrictedClosureClass($extras->{mailer}, "add_message"); - } - # ADDED use_opaque_prefix and use_site_prefix - - $envir{use_site_prefix} = $translationOptions->{use_site_prefix}; - $envir{use_opaque_prefix} = $translationOptions->{use_opaque_prefix}; - - # Other things... - $envir{QUIZ_PREFIX} = $translationOptions->{QUIZ_PREFIX}//''; # used by quizzes - $envir{PROBLEM_GRADER_TO_USE} = "avg_problem_grader"; - $envir{PRINT_FILE_NAMES_FOR} = "professor"; - $envir{useMathQuill} = $translationOptions->{useMathQuill}; - $envir{useMathView} = $translationOptions->{useMathView}; - $envir{mathViewLocale} = $ce->{pg}{options}{mathViewLocale}; - $envir{useWirisEditor} = $translationOptions->{useWirisEditor}; - - # ADDED: __files__ - # an array for mapping (eval nnn) to filenames in error messages - $envir{__files__} = { - root => $ce->{webworkDirs}{root}, # used to shorten filenames - pg => $ce->{pg}{directories}{root}, # ditto - tmpl => $ce->{courseDirs}{templates}, # ditto - }; - - # variables for interpreting capa problems and other things to be - # seen in a pg file - my $specialPGEnvironmentVarHash = $ce->{pg}->{specialPGEnvironmentVars}; - for my $SPGEV (keys %{$specialPGEnvironmentVarHash}) { - $envir{$SPGEV} = $specialPGEnvironmentVarHash->{$SPGEV}; - } - - #%main::envir = %envir; - - return \%envir; -} - -sub translateDisplayModeNames($) { - my $name = shift; - return DISPLAY_MODES()->{$name}; -} - -sub oldSafetyFilter { - my $answer = shift; # accepts one answer and checks it - my $submittedAnswer = $answer; - $answer = '' unless defined $answer; - my ($errorno); - $answer =~ tr/\000-\037/ /; - # Return if answer field is empty - unless ($answer =~ /\S/) { - #$errorno = "
No answer was submitted."; - $errorno = 0; ## don't report blank answer as error - return ($answer,$errorno); - } - # replace ^ with ** (for exponentiation) - # $answer =~ s/\^/**/g; - # Return if forbidden characters are found - unless ($answer =~ /^[a-zA-Z0-9_\-\+ \t\/@%\*\.\n^\[\]\(\)\,\|]+$/ ) { - $answer =~ tr/a-zA-Z0-9_\-\+ \t\/@%\*\.\n^\(\)/#/c; - $errorno = "
There are forbidden characters in your answer: $submittedAnswer
"; - return ($answer,$errorno); - } - $errorno = 0; - return($answer, $errorno); -} - -sub nullSafetyFilter { - return shift, 0; # no errors -} - -1; - -__END__ - -=head1 SYNOPSIS - - $pg = WeBWorK::PG->new( - $ce, # a WeBWorK::CourseEnvironment object - $user, # a WeBWorK::DB::Record::User object - $sessionKey, - $set, # a WeBWorK::DB::Record::UserSet object - $problem, # a WeBWorK::DB::Record::UserProblem object - $psvn, - $formFields # in &WeBWorK::Form::Vars format - { # translation options - displayMode => "images", # (plainText|formattedText|images|MathJax) - showHints => 1, # (0|1) - showSolutions => 0, # (0|1) - refreshMath2img => 0, # (0|1) - processAnswers => 1, # (0|1) - }, - ); - $translator = $pg->{translator}; # WeBWorK::PG::Translator - $body = $pg->{body_text}; # text string - $header = $pg->{head_text}; # text string - $post_header_text = $pg->{post_header_text}; # text string - $answerHash = $pg->{answers}; # WeBWorK::PG::AnswerHash - $result = $pg->{result}; # hash reference - $state = $pg->{state}; # hash reference - $errors = $pg->{errors}; # text string - $warnings = $pg->{warnings}; # text string - $flags = $pg->{flags}; # hash reference - -=head1 DESCRIPTION - -WeBWorK::PG is a factory for modules which use the WeBWorK::PG API. Notable -modules which use this API (and exist) are WeBWorK::PG::Local and -WeBWorK::PG::Remote. The course environment key $pg{renderer} is consulted to -determine which render to use. - -=head1 THE WEBWORK::PG API - -Modules which support this API must implement the following method: - -=over - -=item new ENVIRONMENT, USER, KEY, SET, PROBLEM, PSVN, FIELDS, OPTIONS - -The C method creates a translator, initializes it using the parameters -specified, translates a PG file, and processes answers. It returns a reference -to a blessed hash containing the results of the translation process. - -=back - -=head2 Parameters - -=over - -=item ENVIRONMENT - -a WeBWorK::CourseEnvironment object - -=item USER - -a WeBWorK::User object - -=item KEY - -the session key of the current session - -=item SET - -a WeBWorK::Set object - -=item PROBLEM - -a WeBWorK::DB::Record::UserProblem object. The contents of the source_file -field can specify a PG file either by absolute path or path relative to the -"templates" directory. I - -=item PSVN - -the problem set version number: use variable $psvn - -=item FIELDS - -a reference to a hash (as returned by &WeBWorK::Form::Vars) containing form -fields submitted by a problem processor. The translator will look for fields -like "AnSwEr[0-9]" containing submitted student answers. - -=item OPTIONS - -a reference to a hash containing the following data: - -=over - -=item displayMode - -one of "plainText", "formattedText", "MathJax" or "images" - -=item showHints - -boolean, render hints - -=item showSolutions - -boolean, render solutions - -=item refreshMath2img - -boolean, force images created by math2img (in "images" mode) to be recreated, -even if the PG source has not been updated. FIXME: remove this option. - -=item processAnswers - -boolean, call answer evaluators and graders - -=back - -=back - -=head2 RETURN VALUE - -The C method returns a blessed hash reference containing the following -fields. More information can be found in the documentation for -WeBWorK::PG::Translator. - -=over - -=item translator - -The WeBWorK::PG::Translator object used to render the problem. - -=item head_text - -HTML code for the EheadE block of an resulting web page. Used for -JavaScript features. - -=item body_text - -HTML code for the EbodyE block of an resulting web page. - -=item answers - -An C object containing submitted answers, and results of answer -evaluation. - -=item result - -A hash containing the results of grading the problem. - -=item state - -A hash containing the new problem state. - -=item errors - -A string containing any errors encountered while rendering the problem. - -=item warnings - -A string containing any warnings encountered while rendering the problem. - -=item flags - -A hash containing PG_flags (see the Translator docs). - -=back - -=head1 METHODS PROVIDED BY THE BASE CLASS - -The following methods are provided for use by subclasses of WeBWorK::PG. - -=over - -=item defineProblemEnvir ENVIRONMENT, USER, KEY, SET, PROBLEM, PSVN, FIELDS, OPTIONS - -Generate a problem environment hash to pass to the renderer. - -=item translateDisplayModeNames NAME - -NAME contains - -=back - -=head1 AUTHOR - -Written by Sam Hathaway, sh002i (at) math.rochester.edu. - -=cut diff --git a/lib/WeBWorK/lib/WeBWorK/PG/Local.pm b/lib/WeBWorK/lib/WeBWorK/PG/Local.pm deleted file mode 100644 index 0069d91f7..000000000 --- a/lib/WeBWorK/lib/WeBWorK/PG/Local.pm +++ /dev/null @@ -1,566 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/PG/Local.pm,v 1.28 2009/10/17 15:50:33 apizer Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::PG::Local; -use base qw(WeBWorK::PG); - -=head1 NAME - -WeBWorK::PG::Local - Use the WeBWorK::PG API to invoke a local -WeBWorK::PG::Translator object. - -=head1 DESCRIPTION - -WeBWorK::PG::Local encapsulates the PG translation process, making multiple -calls to WeBWorK::PG::Translator. Much of the flexibility of the Translator is -hidden, instead making choices that are appropriate for the webwork2 -system - -It implements the WeBWorK::PG interface and uses a local -WeBWorK::PG::Translator to perform problem rendering. See the documentation for -the WeBWorK::PG module for information about the API. - -=cut - -use strict; -use warnings; -use WeBWorK::Constants; -use File::Path qw(rmtree); -use WeBWorK::PG::Translator; -use WeBWorK::Utils qw(readFile writeTimingLogEntry); - - -#BEGIN{ -# unless (exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2) { -# require "mod_perl.pm"; # used only for mod_perl1 should we continue to support this? -# } -# -# use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 ); -#} -# Problem processing will time out after this number of seconds. -use constant TIMEOUT => $WeBWorK::PG::Local::TIMEOUT || 10; - -BEGIN { - # This safe compartment is used to read the large macro files such as - # PG.pl, PGbasicmacros.pl and PGanswermacros and cache the results so that - # future calls have preloaded versions of these large files. This saves a - # significant amount of time. - # $WeBWorK::PG::Local::safeCache = new WWSafe; -} - -sub alarm_handler { - my $msg = - "Timeout after processing this problem for " - . TIMEOUT - . " seconds. Check for infinite loops in problem source.\n"; - warn $msg; - CORE::die $msg; -} - -sub new { - my $invocant = shift; - local $SIG{ALRM} = \&alarm_handler; - alarm TIMEOUT; - my $result = eval { $invocant->new_helper(@_) }; - alarm 0; - die $@ if $@; - return $result; -} - -sub new_helper { - my $invocant = shift; - my $class = ref($invocant) || $invocant; - my ( - $ce, - $user, - $key, - $set, - $problem, - $psvn, #FIXME -- not used - $formFields, # in CGI::Vars format - $translationOptions, # hashref containing options for the - # translator, such as whether to show - # hints and the display mode to use - ) = @_; - -# install a local warn handler to collect warnings FIXME -- figure out what I meant to do here. - my $warnings = ""; - - local $SIG{__WARN__} = sub { $warnings .= shift()."
\n"} - if $ce->{pg}->{options}->{catchWarnings}; - - # create a Translator - #warn "PG: creating a Translator\n"; - my $translator = WeBWorK::PG::Translator->new; - - ############################################################################ - # evaluate modules and "extra packages" - ############################################################################ - - #warn "PG: evaluating modules and \"extra packages\"\n"; - my @modules = @{ $ce->{pg}->{modules} }; - - foreach my $module_packages_ref (@modules) { - my ( $module, @extra_packages ) = @$module_packages_ref; - - # the first item is the main package - $translator->evaluate_modules($module); - - # the remaining items are "extra" packages - $translator->load_extra_packages(@extra_packages); - } - - ############################################################################ - # prepare an imagegenerator object (if we're in "images" mode) - ############################################################################ - my $image_generator; - my $site_prefix = ( $translationOptions->{use_site_prefix} ) // ''; - if ( $translationOptions->{displayMode} eq "images" - || $translationOptions->{displayMode} eq "opaque_image" ) - { - my %imagesModeOptions = %{ $ce->{pg}{displayModeOptions}{images} }; - $image_generator = WeBWorK::PG::ImageGenerator->new( - tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir - latex => $ce->{externalPrograms}->{latex}, - dvipng => $ce->{externalPrograms}->{dvipng}, - useCache => 1, - cacheDir => $ce->{webworkDirs}{equationCache}, - cacheURL => $site_prefix . $ce->{webworkURLs}{equationCache}, - cacheDB => $ce->{webworkFiles}{equationCacheDB}, - useMarkers => ( - $imagesModeOptions{dvipng_align} - && $imagesModeOptions{dvipng_align} eq 'mysql' - ), - dvipng_align => $imagesModeOptions{dvipng_align}, - dvipng_depth_db => $imagesModeOptions{dvipng_depth_db}, - ); - } - - ############################################################################ -# create a "delayed mailer" object that will send emails after the page is finished. - ############################################################################ - - my $mailer = {}; #new WeBWorK::Utils::DelayedMailer( - -# smtp_server => $ce->{mail}{smtpServer}, -# smtp_sender => $ce->{mail}{smtpSender}, -# smtp_timeout => $ce->{mail}{smtpTimeout}, -# # FIXME I'd like to have an X-Remote-Host header, but before I do that I have to -# # factor out the remote host/remote port code from Feedback.pm and Authen.pm and -# # put it in Utils! (or maybe in WW::Request?) -# headers => "X-WeBWorK-Module: " . __PACKAGE__ . "\n" -# . "X-WeBWorK-Course: " . $ce->{courseName} . "\n" -# # can't add user-related information because this is used for anonymous questionnaires -# #. "X-WeBWorK-User: " . $user->user_id . "\n" -# #. "X-WeBWorK-Section: " . $user->section . "\n" -# #. "X-WeBWorK-Recitation: " . $user->recitation . "\n" -# . "X-WeBWorK-Set: " . $set->set_id . "\n" -# . "X-WeBWorK-Problem: " . $problem->problem_id . "\n" -# . "X-WeBWorK-PGSourceFile: " . $problem->source_file . "\n", -# allowed_recipients => $ce->{mail}{allowedRecipients}, -# on_illegal_rcpt => "carp", -# ); - - ############################################################################ - # set the environment (from defineProblemEnvir) - ############################################################################ - - #warn "PG: setting the environment (from defineProblemEnvir)\n"; - my $envir = $class->defineProblemEnvir( - $ce, - $user, - $key, - $set, - $problem, - $psvn, #FIXME -- not used - $formFields, - $translationOptions, - { #extras (this is kind of a hack, but not a serious one) - image_generator => $image_generator, - mailer => $mailer, - problemUUID => 0, - }, - ); - $translator->environment($envir); - - ############################################################################ - # initialize the Translator - ############################################################################ - #warn "PG: initializing the Translator\n"; - $translator->initialize(); - - ############################################################################ - # preload macros - ############################################################################ - # This is in transition. here are the old instructions - -# Preload the macros files which are used routinely: PG.pl, -# dangerousMacros.pl, IO.pl, PGbasicmacros.pl, and PGanswermacros.pl -# (Preloading the last two files safes a significant amount of time.) -# -# IO.pl, PG.pl, and dangerousMacros.pl are loaded using -# unrestricted_load This is hard wired into the -# Translator::pre_load_macro_files subroutine. I'd like to change this -# at some point to have the same sort of interface to defaults.config that -# the module loading does -- have a list of macros to load -# unrestrictedly. -# -# This has been replaced by the pre_load_macro_files subroutine. It -# loads AND caches the files. While PG.pl and dangerousMacros are not -# large, they are referred to by PGbasicmacros and PGanswermacros. -# Because these are loaded into the cached name space (e.g. -# Safe::Root1::) all calls to, say NEW_ANSWER_NAME are actually calls -# to Safe::Root1::NEW_ANSWER_NAME. It is useful to have these names -# inside the Safe::Root1: cached safe compartment. (NEW_ANSWER_NAME -# and all other subroutine names are also automatically exported into -# the current safe compartment Safe::Rootx:: -# -# The headers of both PGbasicmacros and PGanswermacros has code that -# insures that the constants used are imported into the current safe -# compartment. This involves evaluating references to, say -# $main::displayMode, at runtime to insure that main refers to -# Safe::Rootx:: and NOT to Safe::Root1::, which is the value of main:: -# at compile time. -# -# TO ENABLE CACHEING UNCOMMENT THE FOLLOWING: -- this has not been used in some time -# eval{$translator->pre_load_macro_files( -# $WeBWorK::PG::Local::safeCache, -# $ce->{pg}->{directories}->{macros}, -# #'PG.pl', 'dangerousMacros.pl','IO.pl','PGbasicmacros.pl','PGanswermacros.pl' -# )}; -# warn "Error while preloading macro files: $@" if $@; - - ############################################################################ - # Here are the new instructions for preloading the macros - ############################################################################ - - # STANDARD LOADING CODE: for cached script files, this merely - # initializes the constants. - #2010 -- in the new scheme PG.pl is the only file guaranteed - # initialization -- it reads in everything that dangerous macros - # and IO.pl - # did before. Mostly it just defines access to the PGcore object - -# 2021 -- for the standaloneRenderer, PG.pl is pre-cached in Translator.pm - # foreach (qw(PG.pl )) { # dangerousMacros.pl IO.pl - # my $macroPath = $WeBWorK::Constants::PG_DIRECTORY . "/macros/$_"; - # my $err = $translator->unrestricted_load($macroPath); - # warn "Error while loading $macroPath: $err" if $err; - # } - - ############################################################################ - # set the opcode mask (using default values) - ############################################################################ - #warn "PG: setting the opcode mask (using default values)\n"; - $translator->set_mask(); - - ############################################################################ - # get the problem source - # FIXME -- this operation can be moved out of the translator. - ############################################################################ - #warn "PG: storing the problem source\n"; - my $source = ''; - my $sourceFilePath = ''; - my $readErrors = undef; - if ( ref( $translationOptions->{r_source} ) ) { - - # the source for the problem is already given to us as a reference to a string - $source = ${ $translationOptions->{r_source} }; - } - else { - # the source isn't given to us so we need to read it - # from a file defined by the problem - - # we grab the sourceFilePath from the problem - $sourceFilePath = $problem->source_file; - - # the path to the source file is usually given relative to the - # the templates directory. Unless the path starts with / assume - # that it is relative to the templates directory - - $sourceFilePath = $ce->{courseDirs}->{templates} . "/" . $sourceFilePath - unless ( $sourceFilePath =~ /^\// ); - - #now grab the source - eval { $source = readFile($sourceFilePath) }; - $readErrors = $@ if $@; - } - - ############################################################################ - # put the source into the translator object - ############################################################################ - - eval { $translator->source_string($source) } unless $readErrors; - $readErrors .= "\n $@ " if $@; - if ($readErrors) { - - # well, we couldn't get the problem source, for some reason. - return bless { - translator => $translator, - head_text => "", - post_header_text => "", - body_text => < {}, - result => {}, - state => {}, - errors => "Failed to read the problem source file.", - warnings => "$warnings", - flags => { error_flag => 1 }, - pgcore => $translator->{rh_pgcore}, - }, $class; - } - - ############################################################################ - # install a safety filter - # FIXME -- I believe that since MathObjects this is no longer operational - ############################################################################ - #warn "PG: installing a safety filter\n"; - #$translator->rf_safety_filter(\&oldSafetyFilter); - $translator->rf_safety_filter( \&WeBWorK::PG::nullSafetyFilter ); - - ############################################################################ - # write timing log entry -- the translator is now all set up - ############################################################################ - # writeTimingLogEntry($ce, "WeBWorK::PG::new", - # "initialized", - # "intermediate"); - - ############################################################################ - # translate the PG source into text - ############################################################################ - - #warn "PG: translating the PG source into text\n"; - $translator->translate(); - - ############################################################################ - # !!!!!!!! IMPORTANT: $envir shouldn't be trusted after problem code runs! - ############################################################################ - - my ( $result, $state ); # we'll need these on the other side of the if block! - if ( $translationOptions->{processAnswers} ) { - - ############################################################################ - # process student answers - ############################################################################ - - #warn "PG: processing student answers\n"; - $translator->process_answers($formFields); - - ############################################################################ - # retrieve the problem state and give it to the translator - ############################################################################ - #warn "PG: retrieving the problem state and giving it to the translator\n"; - - $translator->rh_problem_state( - { - recorded_score => $problem->{status}, - sub_recorded_score => $problem->{sub_status}, - num_of_correct_ans => $problem->{num_correct}, - num_of_incorrect_ans => $problem->{num_incorrect}, - } - ); - - ############################################################################ - # determine an entry order -- the ANSWER_ENTRY_ORDER flag is built by - # the PG macro package (PG.pl) - ############################################################################ - #warn "PG: determining an entry order\n"; - - my @answerOrder = - $translator->rh_flags->{ANSWER_ENTRY_ORDER} - ? @{ $translator->rh_flags->{ANSWER_ENTRY_ORDER} } - : keys %{ $translator->rh_evaluated_answers }; - - ############################################################################ - # install a grader -- use the one specified in the problem, - # or fall back on the default from the course environment. - # (two magic strings are accepted, to avoid having to - # reference code when it would be difficult.) - ############################################################################ - #warn "PG: installing a grader\n"; - - my $grader = $translator->rh_flags->{PROBLEM_GRADER_TO_USE} - || "avg_problem_grader"; - $grader = $translator->rf_std_problem_grader - if $grader eq "std_problem_grader"; - $grader = $translator->rf_avg_problem_grader - if $grader eq "avg_problem_grader"; - die "Problem grader $grader is not a CODE reference." - unless ref $grader eq "CODE"; - $translator->rf_problem_grader($grader); - - ############################################################################ - # grade the problem - ############################################################################ - #warn "PG: grading the problem\n"; - - ( $result, $state ) = $translator->grade_problem( - answers_submitted => $translationOptions->{processAnswers}, - ANSWER_ENTRY_ORDER => \@answerOrder, - %{$formFields} - , #FIXME? this is used by sequentialGrader is there a better way - ); - - } - - ############################################################################ - # after we're done translating, we may have to clean up after the - # translator: - ############################################################################ - - ############################################################################ - # HTML_dpng uses an ImageGenerator. We have to render the queued equations. - ############################################################################ - my $body_text_ref = $translator->r_text; - if ($image_generator) { - my $sourceFile = - $ce->{courseDirs}->{templates} . "/" . $problem->source_file; - my %mtimeOption = - -e $sourceFile ? ( mtime => ( stat $sourceFile )[9] ) : (); - - $image_generator->render( - refresh => $translationOptions->{refreshMath2img}, - %mtimeOption, - body_text => $body_text_ref, - ); - } - - ############################################################################ - # send any queued mail messages - ############################################################################ - - # if ($mailer) { - # $mailer->send_messages; - # } - - ############################################################################ - # end of cleanup phase - ############################################################################ - - ############################################################################ - # write timing log entry - ############################################################################ - # writeTimingLogEntry($ce, "WeBWorK::PG::new", "", "end"); - - ############################################################################ - # return an object which contains the translator and the results of - # the translation process. - ############################################################################ - - return bless { - translator => $translator, - head_text => ${ $translator->r_header }, - post_header_text => ${ $translator->r_post_header }, - body_text => ${$body_text_ref}, # from $translator->r_text - answers => $translator->rh_evaluated_answers, - result => $result, - state => $state, - errors => $translator->errors, - warnings => $warnings, - flags => $translator->rh_flags, - pgcore => $translator->{rh_pgcore}, - }, $class; -} - -1; - -__END__ - -=head1 OPERATION - -WeBWorK::PG::Local goes through the following operations when constructed: - -=over - -=item Create a translator - -Instantiate a WeBWorK::PG::Translator object. - -=item Set the directory hash - -Set the translator's directory hash (courseScripts, macros, templates, and temp -directories) from the course environment. - -=item Evaluate PG modules - -Using the module list from the course environment (pg->modules), perform a -"use"-like operation to evaluate modules at runtime. - -=item Set the problem environment - -Use data from the user, set, and problem, as well as the course -environemnt and translation options, to set the problem environment. The -default subroutine, &WeBWorK::PG::defineProblemEnvir, is used. - -=item Initialize the translator - -Call &WeBWorK::PG::Translator::initialize. What more do you want? - -=item Load IO.pl, PG.pl and dangerousMacros.pl - -These macros must be loaded without opcode masking, so they are loaded here. - -=item Set the opcode mask - -Set the opcode mask to the default specified by WeBWorK::PG::Translator. - -=item Load the problem source - -Give the problem source to the translator. - -=item Install a safety filter - -The safety filter is used to preprocess student input before evaluation. The -default safety filter, &WeBWorK::PG::safetyFilter, is used. - -=item Translate the problem source - -Call &WeBWorK::PG::Translator::translate to render the problem source into the -format given by the display mode. - -=item Process student answers - -Use form field inputs to evaluate student answers. - -=item Load the problem state - -Use values from the database to initialize the problem state, so that the -grader will have a point of reference. - -=item Determine an entry order - -Use the ANSWER_ENTRY_ORDER flag to determine the order of answers in the -problem. This is important for problems with dependancies among parts. - -=item Install a grader - -Use the PROBLEM_GRADER_TO_USE flag, or a default from the course environment, -to install a grader. - -=item Grade the problem - -Use the selected grader to grade the problem. - -=back - -=head1 AUTHOR - -Written by Sam Hathaway, sh002i (at) math.rochester.edu. - -=cut diff --git a/lib/WeBWorK/lib/WeBWorK/Utils.pm b/lib/WeBWorK/lib/WeBWorK/Utils.pm deleted file mode 100644 index fb15f06c3..000000000 --- a/lib/WeBWorK/lib/WeBWorK/Utils.pm +++ /dev/null @@ -1,292 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/Utils.pm,v 1.83 2009/07/12 23:48:00 gage Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::Utils; -use base qw(Exporter); - -use strict; -use warnings; -use DateTime; -use DateTime::TimeZone; -use Date::Format; -use Encode qw(encode_utf8 decode_utf8); -use File::Spec::Functions qw(canonpath); - -use constant DATE_FORMAT => "%m/%d/%Y at %I:%M%P %Z"; -use constant MKDIR_ATTEMPTS => 10; - -our @EXPORT = (); -our @EXPORT_OK = qw( - wwRound - undefstr - runtime_use - formatDateTime - makeTempDirectory - readFile - writeTimingLogEntry - constituency_hash - writeLog - surePathToFile - path_is_subdir - getAssetURL -); - -sub force_eoln($) { - my ($string) = @_; - $string = $string//''; - $string =~ s/\015\012?/\012/g; - return $string; -} - -sub writeLog($$@) { - my ($ce, $facility, @message) = @_; - unless ($ce->{webworkFiles}->{logs}->{$facility}) { - warn "There is no log file for the $facility facility defined.\n"; - return; - } - my $logFile = $ce->{webworkFiles}->{logs}->{$facility}; - surePathToFile($ce->{webworkDirs}->{root}, $logFile); - local *LOG; - if (open LOG, ">>", $logFile) { - print LOG "[", time2str("%a %b %d %H:%M:%S %Y", time), "] @message\n"; - close LOG; - } else { - warn "failed to open $logFile for writing: $!"; - } -} - -sub surePathToFile($$) { - # constructs intermediate directories enroute to the file - # the input path must be the path relative to this starting directory - my $start_directory = shift; - my $path = shift; - my $delim = "/"; - unless ($start_directory and $path ) { - warn "missing directory
surePathToFile start_directory path "; - return ''; - } - # use the permissions/group on the start directory itself as a template - my ($perms, $groupID) = (stat $start_directory)[2,5]; - # warn "&urePathToTmpFile: perms=$perms groupID=$groupID\n"; - - # if the path starts with $start_directory (which is permitted but optional) remove this initial segment - $path =~ s|^$start_directory|| if $path =~ m|^$start_directory|; - - - # find the nodes on the given path - my @nodes = split("$delim",$path); - - # create new path - $path = $start_directory; #convertPath("$tmpDirectory"); - - while (@nodes>1) { # the last node is the file name - $path = $path . shift (@nodes) . "/"; #convertPath($path . shift (@nodes) . "/"); - #FIXME this make directory command may not be fool proof. - unless (-e $path) { - mkdir($path, $perms) - or warn "Failed to create directory $path with start directory $start_directory "; - } - - } - - $path = $path . shift(@nodes); #convertPath($path . shift(@nodes)); - return $path; -} - -sub constituency_hash { - my $hash = {}; - @$hash{@_} = (); - return $hash; -} - -sub wwRound(@) { -# usage wwRound($places,$float) -# return $float rounded up to number of decimal places given by $places - my $places = shift; - my $float = shift; - my $factor = 10**$places; - return int($float*$factor+0.5)/$factor; -} - -sub undefstr($@) { - map { defined $_ ? $_ : $_[0] } @_[1..$#_]; -} - -sub runtime_use($;@) { - my ($module, @import_list) = @_; - my $package = (caller)[0]; # import into caller's namespace - - my $import_string; - if (@import_list == 1 and ref $import_list[0] eq "ARRAY" and @{$import_list[0]} == 0) { - $import_string = ""; - } else { - # \Q = quote metachars \E = end quoting - $import_string = "import $module " . join(",", map { qq|"\Q$_\E"| } @import_list); - } - eval "package $package; require $module; $import_string"; - die $@ if $@; -} - -sub formatDateTime($;$;$;$) { - my ($dateTime, $display_tz, $format_string, $locale) = @_; - warn "Utils::formatDateTime is not a method. ", join(" ",caller(2)) if ref($dateTime); # catch bad calls to Utils::formatDateTime - warn "not defined formatDateTime('$dateTime', '$display_tz') ",join(" ",caller(2)) unless $display_tz; - $dateTime = $dateTime ||0; # do our best to provide default values - $display_tz ||= "local"; # do our best to provide default vaules - $display_tz = verify_timezone($display_tz); - - $format_string ||= DATE_FORMAT; # If a format is not provided, use the default WeBWorK date format - my $dt; - if($locale) { - $dt = DateTime->from_epoch(epoch => $dateTime, time_zone => $display_tz, locale=>$locale); - } - else { - $dt = DateTime->from_epoch(epoch => $dateTime, time_zone => $display_tz); - } - #warn "\t\$dt = ", $dt->strftime(DATE_FORMAT), "\n"; - return $dt->strftime($format_string); -} - -sub makeTempDirectory($$) { - my ($parent, $basename) = @_; - # Loop until we're able to create a directory, or it fails for some - # reason other than there already being something there. - my $triesRemaining = MKDIR_ATTEMPTS; - my ($fullPath, $success); - do { - my $suffix = join "", map { ('A'..'Z','a'..'z','0'..'9')[int rand 62] } 1 .. 8; - $fullPath = "$parent/$basename.$suffix"; - $success = mkdir $fullPath; - } until ($success or not $!{EEXIST}); - die "Failed to create directory $fullPath: $!" - unless $success; - return $fullPath; -} - -sub readFile($) { - my $fileName = shift; - # debugging code: found error in CourseEnvironment.pm with this -# if ($fileName =~ /___/ or $fileName =~ /the-course-should-be-determined-at-run-time/) { -# print STDERR "File $fileName not found.\n Usually an unnecessary call to readFile from\n", -# join("\t ", caller()), "\n"; -# return(); -# } - local $/ = undef; # slurp the whole thing into one string - my $result=''; # need this initialized because the file (e.g. simple.conf) may not exist - if (-r $fileName) { - eval{ - # CODING WARNING: - # if (open my $dh, "<", $fileName){ - # will cause a utf8 "\xA9" does not map to Unicode warning if © is in latin-1 file - # use the following instead - if (open my $dh, "<:raw", $fileName){ - $result = <$dh>; - decode_utf8($result) or die "failed to decode $fileName"; - close $dh; - } else { - print STDERR "File $fileName cannot be read."; # this is not a fatal error. - } - }; - if ($@) { - print STDERR "reading $fileName: error in Utils::readFile: $@\n"; - } - my $prevent_error_message = utf8::decode($result) or warn "Non-fatal warning: file $fileName contains at least one character code which ". - "is not valid in UTF-8. (The copyright sign is often a culprit -- use '&copy;' instead.)\n". - "While this is not fatal you should fix it\n"; - # FIXME - # utf8::decode($result) raises an error about the copyright sign - # decode_utf8 and Encode::decode_utf8 do not -- which is doing the right thing? - } - # returns the empty string if the file cannot be read - return force_eoln($result); -} - -sub writeTimingLogEntry($$$$) { - my ($ce, $function, $details, $beginEnd) = @_; - $beginEnd = ($beginEnd eq "begin") ? ">" : ($beginEnd eq "end") ? "<" : "-"; - writeLog($ce, "timing", "$$ ".time." $beginEnd $function [$details]"); -} - -sub path_is_subdir($$;$) { - my ($path, $dir, $allow_relative) = @_; - - unless ($path =~ /^\//) { - if ($allow_relative) { - $path = "$dir/$path"; - } else { - return 0; - } - } - - $path = canonpath($path); - $path .= "/" unless $path =~ m|/$|; - return 0 if $path =~ m#(^\.\.$|^\.\./|/\.\./|/\.\.$)#; - - $dir = canonpath($dir); - $dir .= "/" unless $dir =~ m|/$|; - return 0 unless $path =~ m|^$dir|; - - return 1; -} - -my $staticPGAssets; - -# Get the url for static assets. -sub getAssetURL { - my ($language, $file, $isThemeFile) = @_; - - # Load the static files list generated by `npm install` the first time this method is called. - if (!$staticPGAssets) { - my $staticAssetsList = "$WeBWorK::Constants::PG_DIRECTORY/htdocs/static-assets.json"; - if (-r $staticAssetsList) { - my $data = do { - open(my $fh, "<:encoding(UTF-8)", $staticAssetsList) - or die "FATAL: Unable to open '$staticAssetsList'!"; - local $/; - <$fh>; - }; - - $staticPGAssets = JSON->new->decode($data); - } else { - warn "ERROR: '$staticAssetsList' not found!\n" - . "You may need to run 'npm install' from '$WeBWorK::Constants::PG_DIRECTORY/htdocs'."; - } - } - - # If a right-to-left language is enabled (Hebrew or Arabic) and this is a css file that is not a third party asset, - # then determine the rtl varaint file name. This will be looked for first in the asset lists. - my $rtlfile = $file =~ s/\.css$/.rtl.css/r - if ($language =~ /^(he|ar)/ && $file !~ /node_modules/ && $file =~ /\.css$/); - - # Now check to see if this is a file in the pg htdocs location with a rtl variant. - # These also can only be local files. - return "/pg_files/$staticPGAssets->{$rtlfile}" if defined $rtlfile && defined $staticPGAssets->{$rtlfile}; - - # Next check to see if this is a file in the pg htdocs location. - if (defined $staticPGAssets->{$file}) { - # File served by cdn. - return $staticPGAssets->{$file} if $staticPGAssets->{$file} =~ /^https?:\/\//; - # File served locally. - return "/pg_files/$staticPGAssets->{$file}"; - } - - # If the file was not found in the lists, then just use the given file and assume its path is relative to the pg - # htdocs location. - return "/pg_files/$file"; -} - - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/Utils/DelayedMailer.pm b/lib/WeBWorK/lib/WeBWorK/Utils/DelayedMailer.pm deleted file mode 100644 index c4127bace..000000000 --- a/lib/WeBWorK/lib/WeBWorK/Utils/DelayedMailer.pm +++ /dev/null @@ -1,167 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/Utils/DelayedMailer.pm,v 1.2 2007/08/13 22:59:59 sh002i Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -# This should be expendable - -package WeBWorK::Utils::DelayedMailer; - -use strict; -use warnings; -use Carp; -use Net::SMTP; -use WeBWorK::Utils qw/constituency_hash/; - -sub new { - my ($invocant, %options) = @_; - my $class = ref $invocant || $invocant; - my $self = bless {}, $class; - - # messages get queued here. format: hashref, safe arguments to MailMsg - $$self{msgs} = []; - - # SMTP settings - $$self{smtp_server} = $options{smtp_server}; - $$self{smtp_sender} = $options{smtp_sender}; - $$self{smtp_timeout} = $options{smtp_timeout}; - - # extra headers - $$self{headers} = $options{headers}; - - # recipients are checked against this list before sending - # these should be bare rfc822 addresses, not "Name " - $$self{allowed_recipients} = constituency_hash(@{$options{allowed_recipients}}); - - # what to do if an illegal recipient is specified - # "croak" (default), "carp", or "ignore" - $$self{on_illegal_rcpt} = $options{on_illegal_rcpt}; - - return $self; -} - -# %msg format: -# $msg{to} = either a single address or an arrayref containing multiple addresses -# $msg{subject} = string subject -# $msg{msg} = string body of email (this is what Email::Sender::MailMsg uses) -sub add_message { - my ($self, %msg) = @_; - - # make sure recipients are allowed - $msg{to} = $self->_check_recipients($msg{to}); - - push @{$$self{msgs}}, \%msg; -} - -sub _check_recipients { - my ($self, $rcpts) = @_; - my @rcpts = ref $rcpts eq "ARRAY" ? @$rcpts : $rcpts; - - my @legal; - foreach my $rcpt (@rcpts) { - my ($base) = $rcpt =~ /<([^<>]*)>\s*$/; # works for addresses generated by Record::User - $base ||= $rcpt; # if it doesn't match, it's a plain address - if (exists $$self{allowed_recipients}{$base}) { - push @legal, $rcpt; - } else { - if (not defined $$self{on_illegal_rcpt} or $$self{on_illegal_rcpt} eq "croak") { - die "can't address message to illegal recipient '$rcpt'"; - } elsif ($$self{on_illegal_rcpt} eq "carp") { - warn "can't address message to illegal recipient '$rcpt'"; - } - } - } - - return \@legal; -} - -sub send_messages { - my ($self) = @_; - - return unless @{$$self{msgs}}; - - my $smtp = new Net::SMTP($$self{smtp_server}, Timeout=>$$self{smtp_timeout}) - or die "failed to create Net::SMTP object"; - - my @results; - foreach my $msg (@{$$self{msgs}}) { - push @results, $self->_send_msg($smtp, $msg); - } - - return @results; -} - -sub _send_msg { - my ($self, $smtp, $msg) = @_; - - my $sender = $$self{smtp_sender}; - my @recipients = @{$$msg{to}}; - my $message = $self->_format_msg($msg); - - # reduce "Foo " to "bar@bar" - foreach my $rcpt (@recipients) { - my ($base) = $rcpt =~ /<([^<>]*)>\s*$/; - $rcpt = $base if defined $base; - } - - my %result; - - $smtp->mail($sender); - my @good_rcpts = $smtp->recipient(@recipients, {SkipBad=>1}); - if (@good_rcpts) { - my $data_sent = $smtp->data($message); - unless ($data_sent) { - $result{error} = "(Error number not available with Net::SMTP)"; - $result{error_msg} = "Unknown error sending message data to SMTP server"; - } - } else { - $result{error} = "(Error number not available with Net::SMTP)"; - $result{error_msg} = "No recipient addresses were accepted by SMTP server"; - } - - # figure out which recipients were rejected - my %bad_rcpts; - @bad_rcpts{@recipients} = (); - delete @bad_rcpts{@good_rcpts}; - my @bad_rcpts = keys %bad_rcpts; - if (@bad_rcpts) { - $result{skipped_recipients} = - { map { $_ => "(Server message not available with Net::SMTP)" } @bad_rcpts }; - } - - return \%result; -} - -sub _format_msg { - my ($self, $msg) = @_; - - my $from = $$self{smtp_sender}; - my $to = join(", ", @{$$msg{to}}); - my $subject = $$msg{subject}; - my $headers = $$self{headers}; - my $body = $$msg{msg}; - - my $formatted_msg = "From: $from\n" - . "To: $to\n" - . "Subject: $subject\n"; - if (defined $headers) { - $formatted_msg .= $headers; - $formatted_msg .= "\n" unless $formatted_msg =~ /\n$/; - } - $formatted_msg .= "\n$body"; - - return $formatted_msg; -} - -1; diff --git a/lib/WeBWorK/lib/WeBWorK/Utils/RestrictedClosureClass.pm b/lib/WeBWorK/lib/WeBWorK/Utils/RestrictedClosureClass.pm deleted file mode 100644 index 61e592e34..000000000 --- a/lib/WeBWorK/lib/WeBWorK/Utils/RestrictedClosureClass.pm +++ /dev/null @@ -1,116 +0,0 @@ -################################################################################ -# WeBWorK Online Homework Delivery System -# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/lib/WeBWorK/Utils/RestrictedClosureClass.pm,v 1.4 2007/08/10 00:27:14 sh002i Exp $ -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of either: (a) the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version, or (b) the "Artistic License" which comes with this package. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the -# Artistic License for more details. -################################################################################ - -package WeBWorK::Utils::RestrictedClosureClass; - -=head1 NAME - -WeBWorK::Utils::RestrictedClosureClass - Protect instance data and only allow -calling of specified methods. - -=head1 SYNPOSIS - - package MyScaryClass; - - sub new { return bless { @_[1..$#_] }, ref $_[0] || $_[0] } - sub get_secret { return $_[0]->{secret_data} } - sub set_secret { $_[0]->{secret_data} = $_[1] } - sub use_secret { print "Secret length is ".length($_[0]->get_secret) } - sub call_for_help { print "HELP!!" } - - package main; - use WeBWorK::Utils::RestrictedClosureClass; - - my $unlocked = new MyScaryClass(secret_data => "pErL iS gReAt"); - my $locked = new WeBWorK::Utils::RestrictedClosureClass($obj, qw/use_secret call_for_help/); - - $unlocked->get_secret; # OK - $unlocked->set_secret("fOoBaR"); # OK - $unlocked->use_secret; # OK - $unlocked->call_for_help; # OK - print $unlocked->{secret_data}; # OK - $unlocked->{secret_data} = "WySiWyG"; # OK - - $locked->get_secret; # NG (not in method list) - $locked->set_secret("fOoBaR"); # NG (not in method list) - $locked->use_secret; # OK - $locked->call_for_help; # OK - print $locked->{secret_data}; # NG (not a hash reference) - $locked->{secret_data} = "WySiWyG"; # NG (not a hash reference) - -=head1 DESCRIPTION - -RestrictedClosureClass generates a wrapper object for a given object that -prevents access to the objects instance data and only allows specified method -calls. The wrapper object is a closure that calls methods of the underlying -object, if permitted. - -This is great for exposing a limited API to an untrusted environment, i.e. the -PG Safe compartment. - -=head1 CONSTRUCTOR - -=over - -=item $wrapper_object = CLASS->new($object, @methods) - -Generate a wrapper object for the given $object. Only calls to the methods -listed in @methods will be permitted. - -=back - -=head1 LIMITATIONS - -You can't call SUPER methods, or methods with an explicit class given: - - $locked->SUPER::call_for_help # NG, would be superclass of RestrictedClosureClass - -=head1 SEE ALSO - -L - -=cut - -use strict; -use warnings; -use Carp; -use Scalar::Util qw/blessed/; - -sub new { - my ($invocant, $object, @methods) = @_; - croak "wrapper class with no methods is dumb" unless @methods; - my $class = ref $invocant || $invocant; - croak "object is not a blessed reference" unless blessed $object; - my %methods; @methods{@methods} = (); - my $self = sub { # CLOSURE over $object, %methods; - my $method = shift; - if (not exists $methods{$method}) { - croak "Can't locate object method \"$method\" via package \"".ref($object)."\" fnord"; - } - return $object->$method(@_); - }; - return bless $self, $class; -} - -sub AUTOLOAD { - my $self = shift; - my $name = our $AUTOLOAD; - $name =~ s/.*:://; - return if $name eq "DESTROY"; # real obj's DESTROY method called when closure goes out of scope - return $self->($name, @_); -} - -1; diff --git a/lib/WeBWorK/lib/WebworkClient/classic_format.pl b/lib/WebworkClient/classic_format.pl similarity index 98% rename from lib/WeBWorK/lib/WebworkClient/classic_format.pl rename to lib/WebworkClient/classic_format.pl index 7b3fed610..fd8376ec4 100644 --- a/lib/WeBWorK/lib/WebworkClient/classic_format.pl +++ b/lib/WebworkClient/classic_format.pl @@ -41,13 +41,13 @@ $problemText $scoreSummary - $LTIGradeMessage +

diff --git a/lib/WeBWorK/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl similarity index 98% rename from lib/WeBWorK/lib/WebworkClient/json_format.pl rename to lib/WebworkClient/json_format.pl index 7e57099f7..0daa9ef9e 100644 --- a/lib/WeBWorK/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -128,7 +128,6 @@ push( @pairs_for_json, "hidden_input_field_userID", '$userID' ); push( @pairs_for_json, "hidden_input_field_course_password", '$course_password' ); push( @pairs_for_json, "hidden_input_field_displayMode", '$displayMode' ); -push( @pairs_for_json, "hidden_input_field_session_key", '$session_key' ); push( @pairs_for_json, "hidden_input_field_outputFormat", 'json' ); push( @pairs_for_json, "hidden_input_field_language", '$formLanguage' ); push( @pairs_for_json, "hidden_input_field_showSummary", '$showSummary' ); diff --git a/lib/WeBWorK/lib/WebworkClient/jwe_secure_format.pl b/lib/WebworkClient/jwe_secure_format.pl similarity index 99% rename from lib/WeBWorK/lib/WebworkClient/jwe_secure_format.pl rename to lib/WebworkClient/jwe_secure_format.pl index 0bf30f52f..c13914fb9 100644 --- a/lib/WeBWorK/lib/WebworkClient/jwe_secure_format.pl +++ b/lib/WebworkClient/jwe_secure_format.pl @@ -41,7 +41,6 @@ $problemText $scoreSummary - $LTIGradeMessage

diff --git a/lib/WeBWorK/lib/WebworkClient/nosubmit_format.pl b/lib/WebworkClient/nosubmit_format.pl similarity index 99% rename from lib/WeBWorK/lib/WebworkClient/nosubmit_format.pl rename to lib/WebworkClient/nosubmit_format.pl index fd67e5500..1dd80d03a 100644 --- a/lib/WeBWorK/lib/WebworkClient/nosubmit_format.pl +++ b/lib/WebworkClient/nosubmit_format.pl @@ -38,7 +38,6 @@ $problemText $scoreSummary - $LTIGradeMessage diff --git a/lib/WeBWorK/lib/WebworkClient/practice_format.pl b/lib/WebworkClient/practice_format.pl similarity index 98% rename from lib/WeBWorK/lib/WebworkClient/practice_format.pl rename to lib/WebworkClient/practice_format.pl index d431f76c6..303dc099b 100644 --- a/lib/WeBWorK/lib/WebworkClient/practice_format.pl +++ b/lib/WebworkClient/practice_format.pl @@ -41,12 +41,12 @@ $problemText $scoreSummary - $LTIGradeMessage +

diff --git a/lib/WeBWorK/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl similarity index 96% rename from lib/WeBWorK/lib/WebworkClient/simple_format.pl rename to lib/WebworkClient/simple_format.pl index 4aeb774ec..630490c3a 100644 --- a/lib/WeBWorK/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -41,14 +41,14 @@ $problemText $scoreSummary - $LTIGradeMessage - + +

diff --git a/lib/WeBWorK/lib/WebworkClient/single_format.pl b/lib/WebworkClient/single_format.pl similarity index 98% rename from lib/WeBWorK/lib/WebworkClient/single_format.pl rename to lib/WebworkClient/single_format.pl index d279547f3..3aac0e498 100644 --- a/lib/WeBWorK/lib/WebworkClient/single_format.pl +++ b/lib/WebworkClient/single_format.pl @@ -40,13 +40,13 @@ $problemText $scoreSummary - $LTIGradeMessage +

diff --git a/lib/WeBWorK/lib/WebworkClient/standard_format.pl b/lib/WebworkClient/standard_format.pl similarity index 97% rename from lib/WeBWorK/lib/WebworkClient/standard_format.pl rename to lib/WebworkClient/standard_format.pl index 5fb4c4f52..b1fdd507c 100644 --- a/lib/WeBWorK/lib/WebworkClient/standard_format.pl +++ b/lib/WebworkClient/standard_format.pl @@ -40,7 +40,6 @@ $problemText $scoreSummary - $LTIGradeMessage @@ -55,11 +54,9 @@ - -

Show:   diff --git a/lib/WeBWorK/lib/WebworkClient/static_format.pl b/lib/WebworkClient/static_format.pl similarity index 98% rename from lib/WeBWorK/lib/WebworkClient/static_format.pl rename to lib/WebworkClient/static_format.pl index 680875c09..443a05a5f 100644 --- a/lib/WeBWorK/lib/WebworkClient/static_format.pl +++ b/lib/WebworkClient/static_format.pl @@ -38,13 +38,13 @@ $problemText $scoreSummary - $LTIGradeMessage + diff --git a/lib/WeBWorK/lib/WebworkClient/ww3_format.pl b/lib/WebworkClient/ww3_format.pl similarity index 95% rename from lib/WeBWorK/lib/WebworkClient/ww3_format.pl rename to lib/WebworkClient/ww3_format.pl index 97ba23b78..7801b40c2 100644 --- a/lib/WeBWorK/lib/WebworkClient/ww3_format.pl +++ b/lib/WebworkClient/ww3_format.pl @@ -1,7 +1,6 @@ { answerTemplate => '$answerTemplate', scoreSummary => '$scoreSummary', - LTIGradeMessage => '$LTIGradeMessage', problemText => <<'ENDPROBLEMTEMPLATE' $problemHeadText diff --git a/public/Rederly-50.png b/public/Rederly-50.png deleted file mode 100644 index d551faf44d66af1d2ce891616a5edd1cf5002b19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4072 zcmaJ^c{r3|_kPDZ$d)xrCS*4=)--m;mMmGuP-HL|%ZwPA5JF|&DQjd+)+sG^Nm&vi zOO$LSQI-^nelyiqU0vVzd#>ww&w0IGPkD#98e5qGK(GV=L_`C?4kZ+^2mpa_09bMc0K`=Q z;PcCCJfT5Jq+rn|?q+6y48;cn3?K%8mg0c`8p>n;FCRql1psPgiU*)Tg1>zykklXi zWgI~F3*%0))MHG!RL)OJTL}77v5@9BTCtG!k58pNO$|?=7$!es`v3r7;i6s;kdwy` z05orKHfSQ+>^Q=e;0wjL5nQlPlCK|?1!#~E6xSC^#6U>CKKK9xNmKL(0zvVqVVEf7 z2ZZRYDT+3;gy<9eu@DugG88VV#SDQ!H2mG%5mrdUUv$cwrl=>8=!by8f`WpeK}t}9 zzXwd==+UDvxFSqZQJ#X34>*S>Vo37%0I{D%{!<5u4RH0x`4MphJcL>o<3b1|YKn?d zg?^u(eG+l*f0Xb6zs8~r2%~0T3Q#!gztONH-2b3aGe2oR=K3k8K`n-`^dt}ol#k($ zb2Y&evHpJkln+B~QcF?ehur^z_|y8&S{D8|EM@o~Y=vL!zhnR6^$ETdxqtww+JEqW z$Nt4zVFL(0fzR+lp!H3{) z?T2y2Qv3Ts`787<`iBtue+&JU`bE`%Q8(eQ&G@-?KcbYq(_+?u{oY|MW@q`L49e;c znjm#;Jn35;OcR9dIIBN=$q$#RJ=Gc1%b=%|B6WD4l;Y=R(8~Nn`H70O{4;rlaLcufpz5YYa4> z>zI0Y{$q9JN!#+Jy~b(e`bL#_GBUQV+5hwV6TF%-I8{Cq4X#+Xv}4f%)yCHoSnX~N z9P}zBGn~GG5ngBPeeWrl+b7UJ84!F!g~pd>>ed;V0r{|n*TWg&3>&kh8^cz3Al+3SLz}qk#~f#uuDW^4*2b2w(++N;134ec1NDv1 z5(E zDwr+hn6rt4>sT7B)t(Ur=;_X{Lcj)rbjmt$<)24~H%o`HRTqs)V{c@bY?ocAOZgq&lV(`ezKnoI33A14tiX1{H*KXMkwEsGMGd$+Gri?()l2vH zo=4+magO8J(8E|h(c7#sy8fE3P;!yj`3o~POy#wktDo2|yK43)7s1b)2X^Mm7)g&{ zIC=7xl=y3yma$fhZHAg&-SSA8H)<$&@9bmTq*@92{ozvj^W!rHLBfc4!ev4`PS>7y z829c(s+Nz|=-3nns{{%(lk3G zrL5Ac9Bo384Gb;&u8f`#i5Ig!CWg};@p$we1GaVYu0+zh!kKowQt8gVnarL7!5pCR zpDYM*^R&reCY-zgAZqoLGise zj*KpBsYRyWlQvY~J03a9FTBw1FlZ9=g1@5I^dp&^aIa%G+fv1RCafEJ+iJUy_Urtf zdYLoF#uKPQ*@RpOS4Cjq+)#dHG8k`A#fyqli|~7G}bi9UA~ADnGFfzs6>dL3v$8T^ZxrZm%6JNy4aX z6@5*awY`}moFo-dM{+*)x;ITccMY!tx3(*EW`jKSDO-OOGFFebGD)Y?UHd*bFj=zs zrA27UKvi(1W;vI8d*&sNJwE1%3*+mj-Ol4gmk&Q{|dCMibXyVztK=@T{&a5TFLM&P?fW_;MXqt{2ov>@e8qlu$P zZE$ZU98asx`{k*&qp4fNP*#tZT(d`#m0D$D_XlC4n*u$ybR{$nLHrzEgXGAsJb95x zQ#c9b<+sdC`O--xQNaQyLb(zX-R&ODq7i`0ei_wIQ95w-(#Q@Gef0Nz`9Ve1jTt7O zfUN4!Bg5v&PVV7HAU?wi^k)1^XPdV8Fdg~>VB--xH$JZvw>P=;aSRvW7G`uH+kg*e z<`VXGM>FbvI`!$xT#MY({W!5Wrt1i14$UFc>{EnC{;emo&JX&==kI+Mb)o_}8FTEo zI}eN=0Xp~xSNV%00{#8v(kqFjT`Y?+7k7@Wep@#*Kyjq7+XBZ{*lB56T{Y^RQM32C zz?qx=&C1t-?(^xf4{;|~&0_X;O<+-1jsir0-5lIdFoZ!pVhl<-yK5)8t_?erk^Kjgyi5yy;Xo-*mMKl=? zP*1cpQShl#qS^GmTCod)>ApwNFCR`ZOz*v2b>zt}TR^^Y%E>zIRNJkY$$i8-Xj(?? zAkFpI!U3q8yjYYDU3Q@y;}zY`_``Ru7$0m6G)se$Qy&%1A5tDFDtO`|BU_CwxUXD1 z(a!U<W zWV#cJZ{cdb*!z`yL!s4qmzqqgbLTLp3QiSd&GAfeaO*63j-yt*%%058hihetyY_a%BeF}Rji3J4ZLJMz1Ku-@YvYbiBTLj zDsWUsnzhP#@0ET0!pXO}>#yR3g{19dqaVoCy__yrJ*~I*nB8u^?`z*W?}(ZGw@Zwe zvZ7I)S%Hs=ue}@i2ge^5vN0SFNba(oz5BNICU<&yT%=h3u<2=Uv+IK>++z=p-g^h~ zv|_E9g7T#=5yy{v^4jFyk7&h4I}%4=(-LrQ^{aKA5pB_5M_vWXoo*V;SV)AP6|Q08 zncVD*+MQ3$3B}(L4>v%q-pN%j1Fbtezm)5AL33j;I{3hl7MeruxJrctf8|Vh?&Q@> zLy20a!Mpp-0Gcj5+lUuPv zYgg$Yl=HJR_)$2qCRR3dN9&f$xQK>Bx;|H`oXZOouJ6iD&Id$*#dOjSZle_nynr^_vxZuiQuN#mr*sC*DY%3u=v zcq-F;>xJP9suLP@J{!mE@x9DGMD#ea{gR4X- z>fVRD-r21zYdxOwrYxNiLu=L{5b@->==NHhy8q`i;gn*07rv;MksUSPWYoJglF=i- zWd8ww+BvUQi{^D>0v)7XC?l4GPJckQ<=`^99+uZ&VBt-t)T`Ypb1U?n_-Dh=tc8$d zhLnfxn2V@I>voZtUQ0X2M!BU*aB~<($#}!zv=Bd?FhZ*siyb0{Sxs!O(?e1Ii*QXZ zmyygmulZM#MH%-A#woW>NoeA7^>WM>Jh|Xgc4}taP7OznWw{$uz8NQ=O zF0qlrzNh=UZDeUC5l&uf6vj9hm&6^OJLfefJ9QoShztokYr^g!^8#;n)edT1Ie5ME zK!-@!o-WMN0(3F|Y1sh%iz2ckd!Eo?mHkpi)>*ZUB-26MO?RpHZny12UmuY@HNMI@ z*>WqYssBMMCwOW8>!GmOl%}HEi#P98=jvSRi$*NJAo`h#Xgrf>pG&H!W%VS`>YaOf zcVF8f(Sv)nf`u{rUi4kSp*jWC?dU!A=;p>by&ZG$-CAbro*6as}~@&oK%( zkyVV}RHU&aPcfD=9+=V0FpbN+_4bxEfC=`eUzH>17tq5}S^&@7>xlc^1BYs}i$w#QC*)?GC7 zoe~miE&w46%MjJEwjbXC?2HT%PnEuNyR0F`N0L$}n6~!}VC7kLLnto=#S;=S=C11* zl`P*^m)ke4Sj^2$yIP*--f>q#T87V;h)LbII=d+TPC5R?q~y)PAXgJqc44@fz&knm wkQ~@P^9331miStQ0cdEzjy=yqk%C=5$M{Tv4em2R)PGhJ19N1Jo^#~?0Rj2PMF0Q* diff --git a/public/filebrowser.js b/public/filebrowser.js index 41489f783..f9b9141aa 100644 --- a/public/filebrowser.js +++ b/public/filebrowser.js @@ -7,10 +7,10 @@ function updateBrowser(formId, updateBackNav) { var option = select.options[select.selectedIndex]; var value = option.value; var formData = new FormData(); - var processData; + var processData; if (value.startsWith('/')) { value = value.replace('/', '') } // replaces first instance only - if (value.match(/\/$/)) { + if (value.match(/\/$/)) { formData.set('maxDepth', 1); formData.set('basePath', value); processData = function (data) { @@ -23,8 +23,9 @@ function updateBrowser(formId, updateBackNav) { formData.set('problemSeed', 1234); formData.set('outputFormat', 'static'); formData.set('_format', 'json'); - formData.set('permissionLevel', 20); - formData.set('includeTags', 1); + formData.set('isInstructor', 1); + formData.set('forceScaffoldsOpen', 1); + formData.set('includeTags', 1); formData.set('showComments', 1); processData = function (data) { updateIframe(data.renderedHTML); diff --git a/public/navbar.js b/public/navbar.js index 94eb1e890..014136829 100644 --- a/public/navbar.js +++ b/public/navbar.js @@ -108,7 +108,7 @@ renderbutton.addEventListener("click", event => { outputFormat = selectedformat.id; } let formData = new FormData(); - formData.set("permissionLevel", 20); + formData.set("isInstructor", 1); formData.set("includeTags", 1); formData.set("showComments", 1); formData.set("sourceFilePath", document.getElementById('sourceFilePath').value); @@ -183,7 +183,7 @@ function insertListener() { } else { outputFormat = selectedformat.id; } - formData.set("permissionLevel", 20); + formData.set("isInstructor", 1); formData.set("includeTags", 1); formData.set("showComments", 1); formData.set("sourceFilePath", document.getElementById('sourceFilePath').value); @@ -220,6 +220,9 @@ function insertListener() { } }).then( function(data) { console.log("render data: ", data) + if (data.debug.perl_warn !== "") { + alert(data.debug.perl_warn.replace(//g,"")); + } problemiframe.srcdoc = data.renderedHTML }).catch( function(error) { document.getElementById("rendered-problem").innerHTML = error.message diff --git a/templates/columns/tags.html.ep b/templates/columns/tags.html.ep index 3be1617de..cdd2e2997 100644 --- a/templates/columns/tags.html.ep +++ b/templates/columns/tags.html.ep @@ -1,7 +1,7 @@ %= stylesheet '/tags.css' % my $taxo = '[]'; -% if (open(TAXONOMY, "<:encoding(utf8)", $ENV{WEBWORK_ROOT}.'/htdocs/DATA/tagging-taxonomy.json') ) { +% if (open(TAXONOMY, "<:encoding(utf8)", $c->app->home->child('tmp/tagging-taxonomy.json') ) { % $taxo = join("", ); % close TAXONOMY; % } @@ -87,4 +87,4 @@ %= javascript begin taxo = <%== $taxo %>; %= end -%= javascript '/tags.js' \ No newline at end of file +%= javascript '/tags.js'