diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..c5ebe9a905 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,26 @@ +# This is a basic workflow to help you get started with Actions + +name: Coverage + +on: + push: + workflow_dispatch: + +jobs: + code_coverage: + runs-on: ubuntu-latest + container: eltenedor/pg-no-ww:latest + steps: + - uses: actions/checkout@v2 + - name: Adapt configuration and run tests + env: + HARNESS_PERL_SWITCHES: -MDevel::Cover + run: | + ln -s -t /opt/webwork/ `pwd` + prove -r t + - name: push coverage analysis + if: always() + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: cover -report codecov + diff --git a/.gitignore b/.gitignore index 9efdf335e0..68e887d01b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ -lib/chromatic/color \ No newline at end of file +lib/chromatic/color +conf/pg_defaults.yml +*.bak +cover_db/ + +htdocs/package-lock.json +htdocs/node_modules +htdocs/static-assets.json +htdocs/**/*.min.js +htdocs/**/*.min.css diff --git a/.perltidyrc b/.perltidyrc new file mode 100644 index 0000000000..8314b7c173 --- /dev/null +++ b/.perltidyrc @@ -0,0 +1,22 @@ +# PBP .perltidyrc file +-l=120 # Max line width is 120 cols +-et=4 # Use tabs instead of spaces. +-i=4 # Indent level is 4 cols +-ci=4 # Continuation indent is 4 cols +-b # Write the file inline and create a .bak file +-vt=0 # Minimal vertical tightness +-cti=0 # No extra indentation for closing brackets +-pt=2 # Maximum parenthesis tightness +-bt=1 # Medium brace tightness +-sbt=1 # Medium square bracket tightness +-bbt=1 # Medium block brace tightness +-nsfs # No space before semicolons +-nolq # Don't outdent long quoted strings +-mbl=1 # Do not allow multiple empty lines +-ce # Cuddled else +-cb # Cuddled blocks +-nbbc # Do not add blank lines before full length comments +-nbot # No line break on ternary +-nlop # No logical padding (this causes mixed tabs and spaces) +-wn # Weld nested containers +-xci # Extended continuation indentation diff --git a/LICENSE b/LICENSE index 8df1667545..980aae59d3 100644 --- a/LICENSE +++ b/LICENSE @@ -2,7 +2,7 @@ Online Homework Delivery System Version 2.* - Copyright 2000-2018, The WeBWorK Project + Copyright 2000-2022, The WeBWorK Project All rights reserved. This program is free software; you can redistribute it and/or modify diff --git a/README b/README index 2326906afb..45ed6d2993 100644 --- a/README +++ b/README @@ -6,6 +6,6 @@ http://webwork.maa.org/wiki/Category:Release_Notes - Copyright 2000-2017, The WeBWorK Project + Copyright 2000-2022, The WeBWorK Project http://webwork.maa.org All rights reserved. diff --git a/README.md b/README.md index 6603452793..d40515112f 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,27 @@ -#Welcome to WeBWorK +# Welcome to WeBWorK + +![main workflow](https://github.com/pstaabp/pg/actions/workflows/coverage.yml/badge.svg) +[![codecov](https://codecov.io/gh/pstaabp/pg/branch/unit-test/graph/badge.svg?token=H7WYHBDB9S)](https://codecov.io/gh/pstaabp/pg) +![GitHub last commit](https://img.shields.io/github/last-commit/pstaabp/pg/unit-test) WeBWorK is an open-source online homework system for math and sciences courses. WeBWorK is supported by the MAA and the NSF and comes with an Open Problem Library (OPL) of over 30,000 homework problems. Problems in the OPL target most lower division undergraduate math courses and some advanced courses. Supported courses include college algebra, discrete mathematics, probability and statistics, single and multivariable calculus, differential equations, linear algebra and complex analysis. Find out more at the main WeBWorK [webpage](http://webwork.maa.org). ## Information for Users -New users interested in getting started with their own WeBWorK server, or instructors looking to learn more about how to use WeBWorK in their classes, should take a look at one of the following resources: -* [WeBWorK wiki](http://webwork.maa.org/wiki/Main_Page) - The main WeBWorK wiki - * [Instructors](http://webwork.maa.org/wiki/Instructors) - Information for Instructors - * [Problem Authors](http://webwork.maa.org/wiki/Authors) - Information for Problem Authors -* [WW_Install](http://github.com/aubreyja/ww_install) - Information for using the WW_install script -* [Forum](http://webwork.maa.org/moodle/mod/forum/index.php?id=3) - The WeBWorK Forum -* [Frequently Asked Questions](https://github.com/openwebwork/webwork2/wiki/Frequently-Asked-Questions) - A list of frequently asked questions. +New users interested in getting started with their own WeBWorK server, or instructors looking to learn more about how to use WeBWorK in their classes, should take a look at one of the following resources: + +* [WeBWorK wiki](http://webwork.maa.org/wiki/Main_Page) - The main WeBWorK wiki + * [Instructors](http://webwork.maa.org/wiki/Instructors) - Information for Instructors + * [Problem Authors](http://webwork.maa.org/wiki/Authors) - Information for Problem Authors +* [WW_Install](http://github.com/aubreyja/ww_install) - Information for using the WW_install script +* [Forum](http://webwork.maa.org/moodle/mod/forum/index.php?id=3) - The WeBWorK Forum +* [Frequently Asked Questions](https://github.com/openwebwork/webwork2/wiki/Frequently-Asked-Questions) - A list of frequently asked questions. -##Information For Developers +## Information For Developers People interested in developing new features for WeBWorK should take a look at the following resources. People interested in developing new problems for WeBWorK should visit [Problem Authors](http://webwork.maa.org/wiki/Authors). -* [First Time Setup](https://github.com/openwebwork/webwork2/wiki/First-Time-Setup) - Setting up your clone of this github repo for the first time. -* [Coding and Workflow](https://github.com/openwebwork/webwork2/wiki/Coding-and-Workflow) - Our suggested workflow processes. Following this will make it much easier to get code accepted into the repo. -* [Creating Pull Requests](https://github.com/openwebwork/webwork2/wiki/Creating-Pull-Requests) - Instructions on how to submit a pull request. -* [More Information](https://github.com/openwebwork/webwork2/wiki/) - Our Github wiki has additional information for developers, including information about WeBWorK3. + +* [First Time Setup](https://github.com/openwebwork/webwork2/wiki/First-Time-Setup) - Setting up your clone of this github repo for the first time. +* [Coding and Workflow](https://github.com/openwebwork/webwork2/wiki/Coding-and-Workflow) - Our suggested workflow processes. Following this will make it much easier to get code accepted into the repo. +* [Creating Pull Requests](https://github.com/openwebwork/webwork2/wiki/Creating-Pull-Requests) - Instructions on how to submit a pull request. +* [More Information](https://github.com/openwebwork/webwork2/wiki/) - Our Github wiki has additional information for developers, including information about WeBWorK3. diff --git a/VERSION b/VERSION index d59de1c529..0048b529d4 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ -$PG_VERSION ='2.16'; -$PG_COPYRIGHT_YEARS = '1996-2021'; +$PG_VERSION ='2.17'; +$PG_COPYRIGHT_YEARS = '1996-2022'; 1; diff --git a/conf/pg_defaults.dist.yml b/conf/pg_defaults.dist.yml new file mode 100644 index 0000000000..fe31876a56 --- /dev/null +++ b/conf/pg_defaults.dist.yml @@ -0,0 +1,19 @@ +# This file is loaded if PG is loaded without a webwork2 lib +# +# The following are configuration options that are needed by PG +# and are a slimmed down list from those of WEBWORK_ROOT/conf/defaults.config + +options: + webworkDirs: + tmp: /tmp + 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 + pdf2svf: /usr/bin/pdf2svg + convert: /usr/bin/convert diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..a846604f96 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,63 @@ +# Docker Instructions + +These are instructions to get the docker image running for running the unit tests in `/t`. + +Note: You may need sudo privileges in order to run the commands starting with `docker ...`. + +## Using the Image from Docker Hub + +The following Docker command will execute the command `prove -r t` inside the Docker container from the image [`eltenedor/pg-no-ww:latest`](https://hub.docker.com/r/eltenedor/pg-no-ww). +Make sure to run the commands from your `pg` folder. +The first time, this may take a couple of minutes. + +### Running the Test Suite + +```bash +docker run -it --rm --name pg-unit-test -v `pwd`:/opt/webwork/pg -w /opt/webwork/pg eltenedor/pg-no-ww prove -r t +``` + +### Code Coverage + +As above, run one of the following Docker commands from you `pg` folder. + +#### HTML Output + +This runs the command `cover -report html` in the Docker container. + +```bash +docker run -it --rm --name pg-unit-test -v `pwd`:/opt/webwork/pg -w /opt/webwork/pg eltenedor/pg-no-ww cover -report html +``` + +Check the HTML output written to `./pg/cover_db/coverage.html`. + +#### Publish Results to [`codecov.io`](https://about.codecov.io/) + +```bash +docker run -it --rm --name pg-unit-test -v `pwd`:/opt/webwork/pg -w /opt/webwork/pg -e CODECOV_TOKEN=xxxx-xxxx-xxxx eltenedor/pg-no-ww cover -report codecov +``` + +Here, `CODECOV_TOKEN=xxxx-xxxx-xxxx` should be adapted to your actual [token](https://docs.codecov.com/docs/quick-start). It is passed to the docker container as argument to the `-e` option. + +HTTP Code `200` means that the data was sent successfully to codecov and is availablle at [https://app.codecov.io/gh/pstaabp/pg](https://app.codecov.io/gh/pstaabp/pg) + +### Using the Shell + +You can also just open up the `bash` of the Docker container via + +```bash +docker run -it --rm --name pg-unit-test -v `pwd`:/opt/webwork/pg -w /opt/webwork/pg eltenedor/pg-no-ww +``` + +At the prompt, just run the commands `prove -r t` and `cover -report html` as indicated above. + +## Building the Docker Image Locally + +Execute the following command from your `pg/docker` folder + +```bash +docker build -t pg-no-ww -f pg-no-dww.Dockerfile +``` + +### Running the Test Suite Locally + +Same as above for the image from Docker Hub. Just replace the name `eltenedor/pg-no-ww` by `pg-no-ww`. diff --git a/docker/pg-no-ww.Dockerfile b/docker/pg-no-ww.Dockerfile new file mode 100644 index 0000000000..14b2396c7c --- /dev/null +++ b/docker/pg-no-ww.Dockerfile @@ -0,0 +1,28 @@ +FROM perl:5.32 +# set metadata +LABEL maintainer="fabian.gabel@tuhh.de" +LABEL hub.docker.com="eltenedor/pg-no-ww" +# install needed perl modules +RUN cpanm -fi --notest \ + Class::Accessor \ + Date::Parse \ + DateTime \ + Devel::Cover \ + Devel::Cover::Report::Codecov \ + HTML::Entities \ + HTML::TagParser \ + JSON \ + Test::Exception \ + Tie::IxHash \ + UUID::Tiny module \ + YAML::XS +# create webwork environment +RUN mkdir -p /opt/webwork +# rename config file at startup +RUN echo "cp -f /opt/webwork/pg/conf/pg_defaults.yml.dist /opt/webwork/pg/conf/pg_defaults.yml" >> ~/.bashrc +WORKDIR /opt/webwork +ENV PG_ROOT /opt/webwork/pg +ENV WEBWORK_ROOT /opt/webwork/webwork2 +ENV WEBWORK_TOPLEVEL /opt/webwork +ENV HARNESS_PERL_SWITCHES -MDevel::Cover +CMD ["/bin/bash"] diff --git a/docker/test-docker.Dockerfile b/docker/test-docker.Dockerfile new file mode 100644 index 0000000000..009a7db1f4 --- /dev/null +++ b/docker/test-docker.Dockerfile @@ -0,0 +1,25 @@ +FROM perl:5.32 +# install needed perl modules +RUN cpanm -fi --notest \ + Class::Accessor \ + Date::Parse \ + DateTime \ + Devel::Cover \ + Devel::Cover::Report::Codecov \ + HTML::Entities \ + HTML::TagParser \ + JSON \ + Test::Exception \ + Tie::IxHash \ + UUID::Tiny module \ + YAML::XS +# create webwork environment +RUN mkdir -p /opt/webwork +# rename config file at startup +# RUN echo "cp -f /opt/webwork/pg/conf/pg_defaults.yml.dist /opt/webwork/pg/conf/pg_defaults.yml" >> ~/.bashrc +WORKDIR /opt/webwork/pg +ENV PG_ROOT /opt/webwork/pg +# ENV WEBWORK_ROOT /opt/webwork/webwork2 +# ENV WEBWORK_TOPLEVEL /opt/webwork +# ENV HARNESS_PERL_SWITCHES -MDevel::Cover +CMD ["/bin/bash"] diff --git a/htdocs/generate-assets.js b/htdocs/generate-assets.js new file mode 100755 index 0000000000..b907da0ccd --- /dev/null +++ b/htdocs/generate-assets.js @@ -0,0 +1,234 @@ +#!/usr/bin/env node + +/* eslint-env node */ + +const yargs = require('yargs'); +const chokidar = require('chokidar'); +const path = require('path'); +const { minify } = require('terser'); +const fs = require('fs'); +const crypto = require('crypto'); +const sass = require('sass'); +const autoprefixer = require('autoprefixer'); +const postcss = require('postcss'); +const rtlcss = require('rtlcss'); +const cssMinify = require('cssnano'); +const thirdPartyAssets = require('./third-party-assets.json'); + +const argv = yargs + .usage('$0 Options').version(false).alias('help', 'h').wrap(100) + .option('useCDN', { + alias: 'c', + description: 'Use third party assets from a CDN rather than serving them locally.', + type: 'boolean' + }) + .option('enable-sourcemaps', { + alias: 's', + description: 'Generate source maps. (Not for use in production!)', + type: 'boolean' + }) + .option('watch-files', { + alias: 'w', + description: 'Continue to watch files for changes. (Developer tool)', + type: 'boolean' + }) + .option('clean', { + alias: 'd', + description: 'Delete all generated files.', + type: 'boolean' + }) + .argv; + +const assetFile = path.resolve(__dirname, 'static-assets.json'); +const assets = {}; + +const cleanDir = (dir) => { + for (const file of fs.readdirSync(dir, { withFileTypes: true })) { + if (file.isDirectory()) { + cleanDir(path.resolve(dir, file.name)); + } else { + if (/.[a-z0-9]{8}.min.(css|js)$/.test(file.name)) { + const fullPath = path.resolve(dir, file.name); + console.log(`\x1b[34mRemoving ${fullPath} from previous build.\x1b[0m`); + fs.unlinkSync(fullPath); + } + } + } +} + +// The is set to true after all files are processed for the first time. +let ready = false; + +const processFile = async (file, _details) => { + if (file) { + const baseName = path.basename(file); + + if (/(? { accumulator[file] = file; return accumulator; }, {})); +} + +// Set up the watcher. +if (argv.watchFiles) console.log('\x1b[32mEstablishing watches and performing initial build.\x1b[0m'); +chokidar.watch(['js'], { + ignored: /\.min\.(js|css)$/, + cwd: __dirname, // Make sure all paths are given relative to the htdocs directory. + usePolling: true, // Needed to get changes to symlinks. + interval: 500, + awaitWriteFinish: { stabilityThreshold: 500 }, + persistent: argv.watchFiles ? true : false +}) + .on('add', processFile).on('change', processFile).on('ready', processFile) + .on('unlink', (file) => { + // If a file is deleted, then also delete the corresponding generated file. + if (assets[file]) { + console.log(`\x1b[34mDeleting minified file for ${file}.\x1b[0m`); + fs.unlinkSync(path.resolve(__dirname, assets[file])); + delete assets[file]; + } + }) + .on('error', (error) => console.log(`\x1b[32m${error}\x1b[0m`)); diff --git a/htdocs/helpFiles/Entering-Angles.html b/htdocs/helpFiles/Entering-Angles.html new file mode 100644 index 0000000000..611d879e0c --- /dev/null +++ b/htdocs/helpFiles/Entering-Angles.html @@ -0,0 +1,49 @@ +
+++ For an angle of 60 degrees, enter it in radians as
+pi/3
or +1.04719...
, but not60
. ++ By default, trig functions are evaluated in radians, so +
+cos(pi/3) = 1/2
, but +cos(60) = -0.9524
since it is radians. + You must convert degrees to radians before applying a trig function to an angle. +
+ If asked for units on an angle, enter, for example,+pi/6 rad
+ (including rad) or30 deg
(including deg). +
+pi
,e = e^1
+ Sometimesg+pi/6
is allowed, but0.524
+ is not. +
+ Sometimesg+0.866025403784
is allowed, but +cos(pi/6)
is not. +
+ Typically, if your answer is correct to 5 decimal places it will be marked correct, although the number of + decimal places required may vary from problem to problem. When in doubt, give more decimal places. ++
+ For example, if your answers are+-3/2, 4/3, 2pi, e^3, 5
enter them as +-1.5, 1.3333333, 6.2831853, 20.0855369, 5
. +
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
++y = 5x+2
will be incorrect if the answer is +w = 5y+2
+
+++
+ +32 = 5*x + 2
is the same as30 = 5x
+ orx = 6
++
+y = (x-1)^2 + 3
is the same as +y - 3 = (x-1)^2
++
+x^2 + xy + y^2 = 13x
is the same as +y*(y+x) = 13x - x^2
+
+ Enter+NONE
orDNE
(this may vary from + problem to problem). +
+pi
,e = e^1
++sqrt(x) = sqrt(5)
is valid, but +sqrt(x=5)
is not +
+ For example,+x^2
andx**2
are the same, + as aree^(-x/2)
and1/(e**(x/2))
. +
+ For example, the square root of 2 can be entered as+sqrt(2)
, +2^(1/2)
, or2**(1/2)
, but the cube root + of 2 must be entered as2^(1/3)
or +2**(1/3)
. The parentheses in2^(1/3)
are + required, since2^1/3
will be interpreted as +(2^1)/3 = 2/3
. +
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
. When these operations are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+ For example, a function of time+t
could be +-16t^2 + 12
, while-16x^2 + 12
would be + incorrect. +
+++
+- +
+5*sin((pi*x)/2)
or5 sin(pi x/2)
+- +
+e^(-x)
ore**(-x)
or +1/(e^x)
+- +
+abs(5y)
or|5y|
+- +
+sqrt(9 - z^2)
or(9 - z^2)^(1/2)
+- +
+24
or4!
or +4 * 3 * 2 * 1
+- +
+pi
or4 arctan(1)
or +4 atan(1)
or4 tan^(-1)(1)
+
+ In this question, use+ln(x)
orlog(x)
+ for natural log, andlogten(x)
or +log10(x)
for the base 10 logarithm. Enter log base b as +ln(x)/ln(b)
. +
+pi
,e = e^1
+ Addition++
, subtraction-
, + multiplication*
, division/
, + exponentiation^
(or**
), + factorial!
+
+++
+- +
sqrt(x) = x^(1/2)
- +
abs(x) = |x|
- +
2^x
- +
e^x
- +
ln(x)
- +
log10(x)
- +
sin(x)
- +
cos(x)
- +
tan(x)
- +
csc(x)
- +
sec(x)
- +
cot(x)
- +
arcsin(x) = asin(x) = sin^(-1)(x)
- +
arccos(x) = acos(x) = cos^(-1)(x)
- +
arctan(x) = atan(x) = tan^(-1)(x)
+ For example,+6x + 5 - 2x
should be simplified to +4x + 5
+
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+ For example, a function of time+t
could be +-16t^2 + 12
, while-16x^2 + 12
would be + incorrect. +
+++
+- +
+5*sin((pi*x)/2)
or5 sin(pi x/2)
+- +
+e^(-x)
ore**(-x)
or +1/(e^x)
+- +
+abs(5y)
or|5y|
+- +
+sqrt(9 - z^2)
or(9 - z^2)^(1/2)
+- +
+24
or4!
or +4 * 3 * 2 * 1
+- +
+pi
or4 arctan(1)
or +4 atan(1)
or4 tan^(-1)(1)
+
+ In this question, use+ln(x)
for natural log, and +log(x)
,logten(x)
or +log10(x)
for the base 10 logarithm. Enter log base b as +ln(x)/ln(b)
. +
+pi
,e = e^1
+ Addition++
, subtraction-
, + multiplication*
, division/
, + exponentiation^
(or**
), + factorial!
+
+++
+- +
sqrt(x) = x^(1/2)
- +
abs(x) = |x|
- +
2^x
- +
e^x
- +
ln(x)
- +
log10(x)
- +
sin(x)
- +
cos(x)
- +
tan(x)
- +
csc(x)
- +
sec(x)
- +
cot(x)
- +
arcsin(x) = asin(x) = sin^(-1)(x)
- +
arccos(x) = acos(x) = cos^(-1)(x)
- +
arctan(x) = atan(x) = tan^(-1)(x)
+ For example,+6x + 5 - 2x
should be simplified to +4x + 5
+
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+ 5/2, -1/3, pi/3, 4, sqrt(2)/2
+
+
+ 15/6, (3-4)/3, 2*pi/6, (16/2)/2
+
+ ++Allowed:
+5/2, -1/3, pi/3, 4, sqrt(2)/2, 2^(1/2)
Not allowed:
+2.5, -0.33333, 3.14159/3, 0.707106/2, 2^(0.5)
+ Enter+1 2/3
(for 1 and 2/3) with a space between the 1 and the 2 instead of +5/3
. +
+ Enter+4/1
instead of4
. +
+ For example, if your answers are+-3/2, 4/3, 2pi, e^3, 5
enter +3/2, 4/3, 2*pi, e^3, 5
. +
+ Enter+NONE
orDNE
+ (this may vary from problem to problem). +
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + and exponentiation^
(or**
). When these + operations are not allowed, it is usually because you are expected to be able to simplify your answer, often + without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+++
+- +
<
less than- +
+<=
less than or equal to + (=<
might also work) +- +
=
equals- +
!=
not equal to (uses exclamation point)- +
>
greater than- +
+>=
greater than or equal to + (=>
might also work) +
+++
+- +
+infinity
orinf
+ means positive infinity +- +
+-infinity
or-inf
+ means negative infinity +- +
R
means all real numbers- +
+R
is the same as +-inf < x < inf
or +(-inf,inf)
+- +
{2,4,5}
using curly braces denotes a finite set- +
+NONE
or a pair of curly braces +{}
means the empty set +- +
U
denotes the union of intervals
+++
+ * Some questions may not allow interval notation to be used ++ +Inequality Notation ++ Interval Notation* + +Remarks ++ ++ +x<2
++ +(-infinity,2)
++ Use rounded parentheses +(
or +)
at infinite endpoints. ++ ++ +x>2
++ +(2,infinity)
++ + ++ +x<=2
++ +(-infinity,2]
++ + ++ +x>=2
++ +[2,infinity)
++ + ++ +0<x<=2
++ +(0,2]
++ + ++ +0<x and x<2
++ +(0,2)
++ +and
is special ++ ++ +x<0 or x>2
++ +(-inf,0)U(2,inf)
++ +or
is special, +U
denotes union ++ ++ +x=0 or x=2
++ +{0,2}
++ finite sets are allowed using curly braces +{a,b,c}
++ ++ +x < 3 or x > 3
++ ++
+- +
(-inf,3)U(3,inf)
- +
x != 3
- +
R-{3}
set differences are allowed +
+++
+- + If an interval includes an endpoint, use square brackets:
+[
or +]
+- + If an interval excludes an endpoint or an endpoint is infinite, use rounded parentheses: +
+(
or)
+- + Use curly braces to enclose finite sets and commas to separate elements the set: +
+{ -3, pi, 2/5, 0.75 }
+- + All sets should be expressed in their simplest form in interval notation with no overlapping + intervals. For example,
+[2,4]U[3,5]
is not equivalent to +[2,5]
+- + If you are asked to find the range of a function
+y = f(x)
, your + inequality should be in terms of the variabley
+
[
or ]
.
+ If not, then use (
or )
. For example, the
+ interval from -3 to 7 that includes 7 but not -3 is expressed (-3,7]
.
+ Inf
for
+ ∞
(infinity) and
+ -Inf
for -∞
+ (-Infinity). For example, the infinite interval containing all points greater than or equal to 6 is expressed
+ [6,Inf)
.
+ [-8,-5)U(-3,7]
.
+ { }
+ R
as a shorthand for all real numbers. So, it is equivalent to
+ entering (-Inf, Inf)
.
+ R-{3}
or (-Inf, 3)U(3,Inf)
(they are the
+ same). Similarly, [1,10)-{3,4}
is the same as
+ [1,3)U(3,4)U(4,10)
.
+ [2,4]U[3,5]
as equivalent to
+ [2,5]
, unless a problem tells you otherwise. All sets should be expressed in
+ their simplest interval notation form, with no overlapping intervals.
+
+ For example, limx → ∞ arctan(x) = π/2, so you would enter
+ pi/2
+
+ + Enter+infinity
,inf
, +-infinity
,-inf
+
+ Enter+DNE
orNONE
+ (this may vary from question to question) +
+ Enter the function using appropriate syntax, for example: +++
+- +
sqrt(x) = x^(1/2)
- +
abs(x) = |x|
- +
2^x, e^x, ln(x), log10(x)
- +
sin(x), cos(x), tan(x), csc(x), sec(x), cot(x)
- +
arcsin(x) = asin(x) = sin^(-1)(x)
- +
arccos(x) = acos(x) = cos^(-1)(x)
- +
arctan(x) = atan(x) = tan^(-1)(x)
+ For example,+6x + 5 - 2x + 7
should be simplified to +4x + 12
+
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
ln(x)
or log(x)
.
+ log10(x)
or logten(x)
.
+ ln(x)/ln(b)
or
+ log(x)/log(b)
+ + WeBWorK does not recognize logarithms to other bases, so you must use the change of base formula for + logarithms to enter your answer. For example, enter log base 2 of x as ++ln(x)/ln(2)
orlog(x)/log(2)
. +
++ln(2x+8)
andln2x+8 = ln(2)*x+8
are very + different. +
+ For example, the required answer may be+ln(6) + ln(x)
or +ln(6x)
. +
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
ln(x)
.
+ log(x)
, log10(x)
, or
+ logten(x)
.
+ ln(x)/ln(b)
or
+ log(x)/log(b)
+ + WeBWorK does not recognize logarithms to other bases, so you must use the change of base formula for + logarithms to enter your answer. For example, enter log base 2 of x as ++ln(x)/ln(2)
orlog(x)/log(2)
. +
++ln(2x+8)
andln2x+8 = ln(2)*x+8
are very + different. +
+ For example, the required answer may be+ln(6) + ln(x)
or +ln(6x)
. +
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+
+ 4, 5/2, -1/3, pi/3, e^3, 3.1415926535, sqrt(2) = 2^(1/2), ln(2), sin(2pi/3)
+
+
+ ++For example, enter
+-1.5, 4/3, 2pi, e^3, 5
+ Do not use commas in large numbers: enter
+4321
(not +4,321
) +
+ Enter+NONE
orDNE
+ (this may vary from problem to problem) +
+ Typically, if your answer is correct to 5 decimal places it will be marked correct, although the number of + decimal places required may vary from problem to problem. When in doubt, give more decimal places. ++
+ Usually, the operations that are not allowed include addition++
, + subtraction-
, multiplication*
, + division/
, and exponentiation^
(or +**
). When these operations are not allowed, it is usually because you are + expected to be able to simplify your answer, often without using a calculator. +
+ Usually, the functions that are not allowed include square root+sqrt( )
, + absolute value| |
(orabs( )
), as well + as other named functions such assin( )
, +ln( )
, etc. When these functions are not allowed, it is usually because + you are expected to be able to simplify your answer, often without using a calculator. +
+++
(4.5, 3/7)
is a valid point in 2 dimensions.+
(pi,e,2)
is a valid point in 3 dimensions.
+ Enter your answer as a comma-separated list of points, for example:
+ (4,3), (5,10)
+
+ + Enter+NONE
orDNE
(this may vary from + problem to problem) +
+pi
,e = e^1
++(sqrt(2),sqrt(5))
is valid, but +(sqrt(2,5))
is not. +
+
Addition.-
Subtraction.*
Multiplication. Multiplication can also be indicated by a space or
+ juxtaposition, e.g., 2x
, 2 x
or
+ 2*x
, also 2(3+4)
.
+ /
Division.^
or **
Exponent. You can use either
+ ^
or **
for exponentiation, e.g.,
+ 3^2
or 3**2
.
+ ( )
Parentheses. You can also use square brackets,
+ [ ]
, and braces, { }
, for grouping, e.g.,
+ [1+2]/[3(4+5)]
+ 1+2/3*4
and
+ [1+2]/[3*4]
click the "Preview Button".
+ *
symbol to indicate mutiplication makes things easier to
+ read. For example (1+2)*(3+4)
and (1+2)(3+4)
+ are both valid. So are 3*4
and 3 4
+ (3 space 4
, not 34
) but using a
+ *
makes things clearer.
+ (
's and )
's to make your meaning clear.
+ You can also use [
's and ]
's and
+ {
's and }
's.
+ 2/4+5
(which is 5.5
) when you
+ really want 2/(4+5)
(which is 2/9
).
+ 2/3*4
(which is 8/3
) when you
+ really want 2/(3*4)
(which is 2/12
).
+ [1+2+3+4]/[5+6+7+8]
, is a
+ good practice.
+ sin(t)
instead of sint
or
+ sin t
even though WeBWorK is smart enough to usually accept
+ sin t
or even sint
. For example,
+ sin 2t
is interpreted as sin(2)t
, i.e.
+ (sin(2))*t
so be careful.
+ sin^2(t)
as a short cut although mathematically speaking
+ sin^2(t)
is shorthand for (sin(t))^2
(the
+ square of sin of t). (You can enter it as sin(t)^2
or even
+ sint^2
, but don't try such things unless you really understand the
+ precedence of operations. The "sin
" operation has highest precedence, so it is
+ performed first, using the next token (i.e. t
) as an argument. Then the result
+ is squared.) You can always use the Preview button to see a typeset version of what you entered and check
+ whether what you wrote was what you meant.
+ 2+3sin^2(4x)
will work and is equivalent to
+ 2+3(sin(4x))^2
or 2+3sin(4x)^2
. Why does the
+ last expression work? Because things in parentheses are always done first
+ [ i.e. (4x)
], next all functions, such as sin, are evaluated
+ [giving sin(4x)
], next all exponents are taken
+ [giving sin(4x)^2
], next all multiplications and divisions are performed in
+ order from left to right [giving 3sin(4x)^2
], and finally all additions and
+ subtractions are performed [giving 2+3sin(4x)^2
].
+ -5^2
positive or negative? It's negative. This is because the square
+ operation is done before the negative sign is applied. Use (-5)^2
if you want
+ to square negative 5.
+ 2/3*4 = (2/3)*4 = 8/3
.
+ 1-2+3 = (1-2)+3 = 2.
+ 2^3^4 = 2^(3^4) = 2^81 =
a big number.
+ pi
This gives 3.14159265358979
, e.g.
+ cos(pi)
is -1
+ e
This gives 2.71828182845905
, e.g.
+ ln(e*2)
is 1 + ln(2)
+ 2.1E2
is the same as 210
2.1E-2
is the same as 0.021
+ Note that sometimes one or more of these functions is disabled for a WeBWorK problem because the instructor wants + you to calculate the answer by some means other than just using the function. +
+abs( )
The absolute valuecos( )
Note: Uses radian measure.sin( )
Note: Uses radian measure.tan( )
Note: Uses radian measure.sec( )
Note: Uses radian measure.cot( )
Note: Uses radian measure.csc( )
Note: Uses radian measure.exp( )
The same function as e^x
.log( )
+ This is usually the natural log but your instructor may have redined this to be log base 10.
+ ln( )
The natural log.logten( )
The log to the base 10.arcsin( )
asin( )
or sin^-1( )
+ Another name for arcsin
.
+ arccos( )
acos( )
or cos^-1( )
+ Another name for arccos
.
+ arctan( )
atan( )
or tan^-1( )
+ Another name for arctan
.
+ arccot( )
acot( )
or cot^-1( )
+ Another name for arccot
.
+ arcsec( )
asec( )
or sec^-1( )
+ Another name for arcsec
+ arccsc( )
acsc( )
or csc^-1( )
+ Another name for arccsc
.
+ sinh( )
cosh( )
tanh( )
sech( )
csch( )
coth( )
arcsinh( )
asinh( )
or sinh^-1( )
+ Another name for arcsinh
.
+ arccosh( )
acosh( )
or cosh^-1( )
+ Another name for arccosh
.
+ arctanh( )
atanh( )
or tanh^-1( )
+ Another name for arctanh
.
+ arcsech( )
asech( )
or sech^-1( )
+ Another name for arcsech
.
+ arccsch( )
acsch( )
or csch^-1( )
+ Another name for arccsch
.
+ arccoth( )
acoth( )
or coth^-1( )
+ Another name for arccoth
.
+ sqrt( )
n!
n factorial. This is defined for integers
+ n
such that n ≥ 0
.
+ These functions may not always be available for every problem.
+sgn( )
The sign function. Its value is one of
+ -1
, 0
, or
+ 1
.
+ step( )
The step function. Its value is
+ 0
if x ≤ 0
and
+ 1
if x > 0
.
+ fact(n)
+ The factorial function n!
(defined only for nonnegative integers)
+ P(n,k) = n*(n-1)*(n-2)...(n-k+1)
, the number of ordered sequences of
+ k
elements chosen from n
elements
+ C(n,k) = "n choose k"
, the number of unordered sequences of
+ k
elements chosen from n
elements
+
+ Some WeBWorK problems ask for answers with units. Below is a list of basic units and how they need to be abbreviated
+ in WeBWorK answers. In some problems, you may need to combine units (e.g, velocity might be in
+ ft/s
for feet per second).
+
Unit | +Abbreviation | +
---|---|
Time | +|
Seconds | +s | +
Minutes | +min | +
Hours | +hr | +
Days | +day | +
Years | +yr | +
Milliseconds | +ms | +
Distance | +|
Feet | +ft | +
Inches | +in | +
Miles | +mi | +
Meters | +m | +
Centimeters | +cm | +
Millimeters | +mm | +
Kilometers | +km | +
Angstroms | +A | +
Light years | +light-year | +
Mass | +|
Grams | +g | +
Kilograms | +kg | +
Slugs | +slug | +
Volume | +|
Liters | +L | +
Cubic Centimeters | +cc | +
Milliliters | +ml | +
Force | +|
Newtons | +N | +
Dynes | +dyne | +
Pounds | +lb | +
Tons | +ton | +
Work/Energy | +|
Joules | +J | +
kilo Joule | +kJ | +
ergs | +erg | +
foot pounds | +lbf | +
calories | +cal | +
kilo calories | +kcal | +
electron volts | +eV | +
kilo Watt hours | +kWh | +
Misc | +|
Amperes | +amp | +
Moles | +mol | +
Degrees Centrigrade | +degC | +
Degrees Fahrenheit | +degF | +
Degrees Kelvin | +degK | +
Angle degrees | +deg | +
Angle radians | +rad | +
+ More details on units in WeBWorK +
diff --git a/htdocs/helpFiles/Entering-Vectors.html b/htdocs/helpFiles/Entering-Vectors.html new file mode 100644 index 0000000000..7a1523b13b --- /dev/null +++ b/htdocs/helpFiles/Entering-Vectors.html @@ -0,0 +1,71 @@ +i
, j
, and
+ k
+
+ +++
+i
is the same as<1,0,0>
++
+j
is the same as<0,1,0>
++
+k
is the same as<0,0,1>
+
i
, j
, and
+ k
:
+
+ +++
+<4.5, 3/7>
and4.5i + 3/7j
+ are valid vectors in 2 dimensions. ++
+<pi,e,2>
andpi i + e j + 2 k
+ are valid vectors in 3 dimensions. +
+ Enter your answer as a comma-separated list of vectors, for example:
+ <4,3>, <5,10>
+
+ + Enter+NONE
orDNE
+ (this may vary from problem to problem). +
+pi
,e = e^1
++<sqrt(2),sqrt(5)>
is valid, but +<sqrt(2,5)>
is not. +
[
or ]
.
+ If not, then use (
or )
. For example, the
+ interval from -3 to 7 that includes 7 but not -3 is expressed (-3,7]
.
+ Inf
for
+ ∞
(infinity) and
+ -Inf
for -∞
+ (-Infinity). For example, the infinite interval containing all points greater than or equal to 6 is expressed
+ [6,Inf)
.
+ [-8,-5)U(-3,7]
.
+ { }
+ R
as a shorthand for all real numbers. So, it is equivalent to
+ entering (-Inf, Inf)
.
+ R-{3}
or (-Inf, 3)U(3,Inf)
(they are the
+ same). Similarly, [1,10)-{3,4}
is the same as
+ [1,3)U(3,4)U(4,10)
.
+ [2,4]U[3,5]
as equivalent to
+ [2,5]
, unless a problem tells you otherwise. All sets should be expressed in
+ their simplest interval notation form, with no overlapping intervals.
+ Partial Derivative | +Enter into WeBWork | +
---|---|
\(\frac{\partial u}{\partial x}\) | +ux | +
\(\frac{\partial u}{\partial t}\) | +ut | +
\(\frac{\partial u}{\partial y}\) | +uy | +
\(\frac{\partial^2 u}{\partial x^2}\) | +uxx | +
\(\frac{\partial^2 u}{\partial t^2}\) | +utt | +
\(\frac{\partial^2 u}{\partial y^2}\) | +uyy | +
+ To answer questions that require you to input a PDE you will also need to know the form of the PDE WeBWorK is + expecting. In particular you will need to use the same letters for constants that WeBWorK is expecting. Below is a + table of the PDE's you may encounter. +
+ +Model | +PDE | +
---|---|
heat equation | ++ \(k \frac{\partial^2 u}{\partial x^2} = \frac{\partial u}{\partial t}\) + | +
+ heat equation with lateral heat transfer - \(u_m\) is the temperature of the surrounding medium and will be + given, and h is the constant from Newton's $ + | ++ \(k \frac{\partial^2 u}{\partial x^2}-h (u-u_m) = \frac{\partial u}{\partial t}\) + | +
wave equation | ++ \(a^2 \frac{\partial^2 u}{\partial x^2} = \frac{\partial^2 u}{\partial t^2}\) + | +
wave equation with damping | ++ \(a^2 \frac{\partial^2 u}{\partial x^2} = + \frac{\partial^2 u}{\partial t^2}+c \frac{\partial u}{\partial t}\) + | +
+ wave equation with an external force (f(x,t) will specified in the problem + | ++ \(a^2 \frac{\partial^2 u}{\partial x^2} + f(x,t) = \frac{\partial^2 u}{\partial t^2}\) + | +
Laplace's equation | ++ \(\frac{\partial^2 u}{\partial x^2}+\frac{\partial^2 u}{\partial y^2} = 0\) + | +
For problems with proportional quantities the constant of proportionality is c.
+ ++ Suppose that we want to enter the boundary condition \(\frac{\partial u}{\partial x}\big\vert_{x=0}=0\). You will be + given two answer blanks: the first is to input the partial derivative and the point, \(ux(0,t)\), and the second + will be for the right hand side. In WeBWorK notation the boundary condition would be given as + \(ux(0,t) = 0\). +
diff --git a/htdocs/helpFiles/Syntax.html b/htdocs/helpFiles/Syntax.html new file mode 100644 index 0000000000..a95067272b --- /dev/null +++ b/htdocs/helpFiles/Syntax.html @@ -0,0 +1,249 @@ ++
Addition.-
Subtraction.*
Multiplication. Multiplication can also be indicated by a space or
+ juxtaposition, e.g., 2x
, 2 x
or
+ 2*x
, also 2(3+4)
.
+ /
Division.^
or **
Exponent. You can use either
+ ^
or **
for exponentiation, e.g.,
+ 3^2
or 3**2
.
+ ( )
Parentheses. You can also use square brackets,
+ [ ]
, and braces, { }
, for grouping, e.g.,
+ [1+2]/[3(4+5)]
+ 1+2/3*4
and
+ [1+2]/[3*4]
click the "Preview Button".
+ *
symbol to indicate mutiplication makes things easier to
+ read. For example (1+2)*(3+4)
and (1+2)(3+4)
+ are both valid. So are 3*4
and 3 4
+ (3 space 4
, not 34
) but using a
+ *
makes things clearer.
+ (
's and )
's to make your meaning clear.
+ You can also use [
's and ]
's and
+ {
's and }
's.
+ 2/4+5
(which is 5.5
) when you
+ really want 2/(4+5)
(which is 2/9
).
+ 2/3*4
(which is 8/3
) when you
+ really want 2/(3*4)
(which is 2/12
).
+ [1+2+3+4]/[5+6+7+8]
, is a
+ good practice.
+ sin(t)
instead of sint
or
+ sin t
even though WeBWorK is smart enough to usually accept
+ sin t
or even sint
. For example,
+ sin 2t
is interpreted as sin(2)t
, i.e.
+ (sin(2))*t
so be careful.
+ sin^2(t)
as a short cut although mathematically speaking
+ sin^2(t)
is shorthand for (sin(t))^2
(the
+ square of sin of t). (You can enter it as sin(t)^2
or even
+ sint^2
, but don't try such things unless you really understand the
+ precedence of operations. The "sin
" operation has highest precedence, so it is
+ performed first, using the next token (i.e. t
) as an argument. Then the result
+ is squared.) You can always use the Preview button to see a typeset version of what you entered and check
+ whether what you wrote was what you meant.
+ 2+3sin^2(4x)
will work and is equivalent to
+ 2+3(sin(4x))^2
or 2+3sin(4x)^2
. Why does the
+ last expression work? Because things in parentheses are always done first
+ [ i.e. (4x)
], next all functions, such as sin, are evaluated
+ [giving sin(4x)
], next all exponents are taken
+ [giving sin(4x)^2
], next all multiplications and divisions are performed in
+ order from left to right [giving 3sin(4x)^2
], and finally all additions and
+ subtractions are performed [giving 2+3sin(4x)^2
].
+ -5^2
positive or negative? It's negative. This is because the square
+ operation is done before the negative sign is applied. Use (-5)^2
if you want
+ to square negative 5.
+ 2/3*4 = (2/3)*4 = 8/3
.
+ 1-2+3 = (1-2)+3 = 2.
+ 2^3^4 = 2^(3^4) = 2^81 =
a big number.
+ pi
This gives 3.14159265358979
, e.g.
+ cos(pi)
is -1
+ e
This gives 2.71828182845905
, e.g.
+ ln(e*2)
is 1 + ln(2)
+ 2.1E2
is the same as 210
2.1E-2
is the same as 0.021
+ Note that sometimes one or more of these functions is disabled for a WeBWorK problem because the instructor wants + you to calculate the answer by some means other than just using the function. +
+abs( )
The absolute valuecos( )
Note: Uses radian measure.sin( )
Note: Uses radian measure.tan( )
Note: Uses radian measure.sec( )
Note: Uses radian measure.cot( )
Note: Uses radian measure.csc( )
Note: Uses radian measure.exp( )
The same function as e^x
.log( )
+ This is usually the natural log but your instructor may have redined this to be log base 10.
+ ln( )
The natural log.logten( )
The log to the base 10.arcsin( )
asin( )
or sin^-1( )
+ Another name for arcsin
.
+ arccos( )
acos( )
or cos^-1( )
+ Another name for arccos
.
+ arctan( )
atan( )
or tan^-1( )
+ Another name for arctan
.
+ arccot( )
acot( )
or cot^-1( )
+ Another name for arccot
.
+ arcsec( )
asec( )
or sec^-1( )
+ Another name for arcsec
+ arccsc( )
acsc( )
or csc^-1( )
+ Another name for arccsc
.
+ sinh( )
cosh( )
tanh( )
sech( )
csch( )
coth( )
arcsinh( )
asinh( )
or sinh^-1( )
+ Another name for arcsinh
.
+ arccosh( )
acosh( )
or cosh^-1( )
+ Another name for arccosh
.
+ arctanh( )
atanh( )
or tanh^-1( )
+ Another name for arctanh
.
+ arcsech( )
asech( )
or sech^-1( )
+ Another name for arcsech
.
+ arccsch( )
acsch( )
or csch^-1( )
+ Another name for arccsch
.
+ arccoth( )
acoth( )
or coth^-1( )
+ Another name for arccoth
.
+ sqrt( )
n!
n factorial. This is defined for integers
+ n
such that n ≥ 0
.
+ These functions may not always be available for every problem.
+sgn( )
The sign function. Its value is one of
+ -1
, 0
, or
+ 1
.
+ step( )
The step function. Its value is
+ 0
if x ≤ 0
and
+ 1
if x > 0
.
+ fact(n)
+ The factorial function n!
(defined only for nonnegative integers)
+ P(n,k) = n*(n-1)*(n-2)...(n-k+1)
, the number of ordered sequences of
+ k
elements chosen from n
elements
+ C(n,k) = "n choose k"
, the number of unordered sequences of
+ k
elements chosen from n
elements
+
+ Some WeBWorK problems ask for answers with units. Below is a list of basic units and how they need to be abbreviated
+ in WeBWorK answers. In some problems, you may need to combine units (e.g, velocity might be in
+ ft/s
for feet per second).
+
Unit | +Abbreviation | +
---|---|
Time | +|
Seconds | +s | +
Minutes | +min | +
Hours | +hr | +
Days | +day | +
Years | +yr | +
Milliseconds | +ms | +
Distance | +|
Feet | +ft | +
Inches | +in | +
Miles | +mi | +
Meters | +m | +
Centimeters | +cm | +
Millimeters | +mm | +
Kilometers | +km | +
Angstroms | +A | +
Light years | +light-year | +
Mass | +|
Grams | +g | +
Kilograms | +kg | +
Slugs | +slug | +
Volume | +|
Liters | +L | +
Cubic Centimeters | +cc | +
Milliliters | +ml | +
Force | +|
Newtons | +N | +
Dynes | +dyne | +
Pounds | +lb | +
Tons | +ton | +
Work/Energy | +|
Joules | +J | +
kilo Joule | +kJ | +
ergs | +erg | +
foot pounds | +lbf | +
calories | +cal | +
kilo calories | +kcal | +
electron volts | +eV | +
kilo Watt hours | +kWh | +
Misc | +|
Amperes | +amp | +
Moles | +mol | +
Degrees Centrigrade | +degC | +
Degrees Fahrenheit | +degF | +
Degrees Kelvin | +degK | +
Angle degrees | +deg | +
Angle radians | +rad | +
+ More details on units in WeBWorK +
diff --git a/htdocs/js/apps/AppletSupport/ww_applet_support.js b/htdocs/js/apps/AppletSupport/ww_applet_support.js new file mode 100644 index 0000000000..605f584bc3 --- /dev/null +++ b/htdocs/js/apps/AppletSupport/ww_applet_support.js @@ -0,0 +1,357 @@ +// ################################################################################ +// # 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. +// ################################################################################ + +// List of web applets on the page. +const ww_applet_list = {}; + +// Utility functions + +// Dummy function provided to prevent console errors for problems written for lecacy code. +const applet_loaded = () => {}; + +const getApplet = (appletName) => window[appletName]; + +// Get Question Element in problemMainForm by name +const getQE = (name1) => { + const obj = document.getElementById(name1) ?? document.problemMainForm[name1]; + if (!obj || obj.name != name1) { + console.log(`Can't find element ${name1}`); + } else { + return obj; + } +} + +const getQuestionElement = getQE; + +// WW_Applet class definition +class ww_applet { + constructor(appletName) { + this.appletName = appletName; + this.type = ''; + this.initialState = ''; + this.configuration = ''; + this.getStateAlias = ''; + this.setStateAlias = ''; + this.setConfigAlias = ''; + this.getConfigAlias = ''; + this.submitActionScript = ''; + this.onInit = 0; + this.debug = 0; + } + + // Determine whether an XML string has been base64 encoded. + // This returns false if the string is empty, or if it contains a < or > character. + // The empty string is not a base64 string, and + // base64 can't contain < or > and xml strings contain lots of them. + base64Q(str) { return str && !/[<>]+/.exec(str); } + + // Make sure that the applet has this function available + methodDefined(methodName) { + const applet = getApplet(this.appletName); + if (methodName && typeof(applet[methodName]) == 'function') return true; + if (this.debug) console.log(`${this.appletName}: Method name ${methodName} is not defined`); + return false; + } + + // CONFIGURATIONS + // Configurations are "permanent" + setConfig() { + if (this.debug) console.log(`${this.appletName}: calling setConfig`); + const applet = getApplet(this.appletName); + try { + if (this.methodDefined(this.setConfigAlias)) { + if (this.debug) console.log(`${this.appletName}: calling ${this.setConfigAlias}${ + this.debug > 1 ? `with configuration:\n${this.configuration}` : ''}`); + applet[this.setConfigAlias](this.configuration); + } + } catch(e) { + console.log(`Error configuring ${this.appletName} using command ${this.setConfigAlias}: ${e}`); + } + } + + // Gets the configuration from the applet. + getConfig() { + if (this.debug) console.log(`${this.appletName}: calling getConfig`); + const applet = getApplet(this.appletName); + try { + if (this.methodDefined(this.getConfigAlias)) { + if (this.debug) console.log(`${this.appletName}: calling ${this.getConfigAlias}`); + console.log(applet[this.getConfigAlias]()); + } + } catch(e) { + console.log(`Error getting configuration for ${this.appletName} using command ${this.getConfigAlias}: ${e}`); + } + } + + // Set the state stored on the HTML page + setHTMLAppletState(newState) { + if (this.debug) console.log(`${this.appletName}: setHTMLAppletState${this.debug > 1 ? ` to:\n${newState}` : ''}`); + if (typeof(newState) === 'undefined') newState = '