Skip to content

Commit 80f2324

Browse files
committed
Merge branch 'iss1703' into dev
2 parents 495e19b + ea8501d commit 80f2324

9 files changed

Lines changed: 45 additions & 38 deletions

File tree

doc/en/AbInitio/Authoring_quick_start_1.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ There are lots of fields, but only a few are compulsory:
2222

2323
1. The "question name",
2424
2. The "question text", which is shown to the student,
25-
3. The teacher's "model answer" `ta` using a variable in the "question variables",
25+
3. The teacher's "model answer" `ta1` using a variable in the "question variables",
2626
4. A test of "correctness" (defaults to Algebraic equivalence).
2727

2828
By default a new question automatically has one [input](../Authoring/Inputs/index.md), and one algorithm to test correctness of the answer.
@@ -39,10 +39,10 @@ You must give the question a name, for example `question1`.
3939

4040
There should be text in question variables by default.
4141

42-
ta:?;
42+
ta1:?;
4343
We should replace `?` with the model answer to the question. In this case, this wil be the derivative of \((x-1)^3\), which is \(3(x-1)^2\). So we should replace `?` with `3*(x-1)^2`.
4444

45-
ta:3*(x-1)^2;
45+
ta1:3*(x-1)^2;
4646

4747

4848
### Question text ###
@@ -110,7 +110,7 @@ Each branch can then
110110
We can leave the default settings for a minimal question, which is the following:
111111

112112
1. Specify the variable `ans1` in the `SAns` setting.
113-
2. Specify the correct answer in the `TAns` setting: `ta`.
113+
2. Specify the correct answer in the `TAns` setting: `ta1`.
114114
3. `AlgEquiv` in the _Answer test_ drop-down menu.
115115

116116
## Saving the question
@@ -123,7 +123,7 @@ To recap, we have
123123

124124
1. The "question name",
125125
2. The "question text",
126-
3. The teacher's "model answer", (`ta` in the question variables).
126+
3. The teacher's "model answer", (`ta1` in the question variables).
127127
4. A test of "correctness" (set to Algebraic equivalence).
128128

129129
Next we should try out our question by pressing the `Preview` link at the bottom of the page.

doc/en/AbInitio/Authoring_quick_start_2.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ We make more use of the question text field. For instance, we can start to use t
2525
Add the following to the question variables
2626

2727
```
28-
exp: 3*(x-1)^(-4);
29-
ta: int(exp,x)+c;
28+
ex1: 3*(x-1)^(-4);
29+
ta1: int(ex1,x)+c;
3030
```
3131

3232
The coding in question variables is based on Maxima, which has an unusual syntax for assignment. In particular, the colon `:` is used to assign a value to a variable. So to assign the value of `5` to `a1`, we use the syntax `a1:5`. In general, it is good practice to give variables multi-character names, as single-character names are meant for student input. This is because multi-character variables the author defined cannot by default be input by students. Additionally, adding semicolons to the end of each line is optional, but good practice.
@@ -35,21 +35,21 @@ Notice we are using the CAS to determine the model answer by calling the `int()`
3535

3636
Now it will be a lot faster to fill out the rest of the question. Add the following to the question text:
3737

38-
<p>Find \(\int{@exp@} \mathrm{d}x\)</p>
38+
<p>Find \(\int{@ex1@} \mathrm{d}x\)</p>
3939
<p>[[input:ans1]] [[validation:ans1]]</p>
4040

41-
Notice that we have defined a local variable `exp`, and used the value of this in the Question text. There is a difference between mathematics enclosed between `\(..\)` symbols and `{@..@}` symbols. All the text-based fields in the question, including feedback, are [CAS text](../Authoring/CASText.md). This is HTML into which mathematics can be inserted. LaTeX is placed between `\(..\)`s, and CAS expressions (including your variables) between matching `{@..@}` symbols. The CAS expressions are evaluated in the context of the question variables and displayed as LaTeX.
41+
Notice that we have defined a local variable `ex1`, and used the value of this in the Question text. There is a difference between mathematics enclosed between `\(..\)` symbols and `{@..@}` symbols. All the text-based fields in the question, including feedback, are [CAS text](../Authoring/CASText.md). This is HTML into which mathematics can be inserted. LaTeX is placed between `\(..\)`s, and CAS expressions (including your variables) between matching `{@..@}` symbols. The CAS expressions are evaluated in the context of the question variables and displayed as LaTeX.
4242

43-
Since we have used `{@exp@}` here, the user will not see a \(exp\) on the screen when the question is instantiated, but the _displayed value_ of `exp`: \(\frac{3}{(x-1)^{-4}}\)
43+
Since we have used `{@ex1@}` here, the user will not see a \(ex1\) on the screen when the question is instantiated, but the _displayed value_ of `ex1`: \(\frac{3}{(x-1)^{-4}}\)
4444

45-
In the input `ans1`, confirm the default `model answer` is the variable `ta`.
45+
In the input `ans1`, confirm the default `model answer` is the variable `ta1`.
4646

47-
In the potential response tree, confirm the default `Answer test` is `AlgEquiv`, `SAns` is `ans1` and `TAns` is `ta`.
47+
In the potential response tree, confirm the default `Answer test` is `AlgEquiv`, `SAns` is `ans1` and `TAns` is `ta1`.
4848

4949
It is good practice to use question variables often, as they save time and let you change properties of the question easily in the future.
5050

5151
# Next step #
5252

5353
You should now be able to use question variables in STACK.
5454

55-
##### The next part of the authoring quick start guide looks at [improving feedback](Authoring_quick_start_3.md).
55+
##### The next part of the authoring quick start guide looks at [improving feedback](Authoring_quick_start_3.md).

doc/en/AbInitio/Authoring_quick_start_3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This part of the Authoring Quick Start Guide deals with improving feedback. The
99
<iframe width="560" height="315" src="https://www.youtube.com/embed/l6QAMmUA5Pk" frameborder="0" allowfullscreen></iframe>
1010
## Introduction
1111

12-
In the last part we started working with question variables. Specifically, we defined the variable `exp` for the expression to be integrated, and `ta` for the teacher's answer. Then we asked the student to find \(\int 3(x-1)^{-4}dx\).
12+
In the last part we started working with question variables. Specifically, we defined the variable `ex1` for the expression to be integrated, and `ta1` for the teacher's answer. Then we asked the student to find \(\int 3(x-1)^{-4}dx\).
1313

1414
Try previewing this question and typing in `-1*(x-1)^(-3)+c`. The system should accept this as correct. Next type in `-1*(x-1)^(-3)+C`. This will be compared to the teacher's answer `-1*(x-1)^(-3)+c` by algebraic equivalence (recall we specified `AlgEquiv` in the potential response tree), and will not be accepted as equivalent. The reason is that `c` and `C` are different. A reasonable teacher will probably not care which letter is used for the constant of integration. Let us fix this problem.
1515

doc/en/AbInitio/Authoring_quick_start_4.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ In the last part, we worked with a problem about integrating \(3(x-1)^{-4}\) wit
1414
Let's take a look again at the question variables we declared:
1515

1616
```
17-
exp: 3*(x-1)^(-4);
18-
ta: int(exp,x)+c;
17+
ex1: 3*(x-1)^(-4);
18+
ta1: int(ex1,x)+c;
1919
```
2020

21-
We defined two local variables `exp` and `ta`, and used these values in other places such as the question text, input and potential response tree.
21+
We defined two local variables `ex1` and `ta1`, and used these values in other places such as the question text, input and potential response tree.
2222

2323
We are now in a position to generate a random question. To do this, modify the [question variables](../Authoring/Variables.md#Question_variables) to be
2424

2525
```
2626
a1 : 1+rand(6);
2727
a2 : 1+rand(6);
2828
nn : 1+rand(4);
29-
exp : a1*(x-a2)^(-nn);
30-
ta: int(exp, x)+c;
29+
ex1 : a1*(x-a2)^(-nn);
30+
ta1: int(ex1, x)+c;
3131
```
3232

33-
In this new question we are asking the student to find the anti-derivative of a question with a definite form \( a_1(x-a_2)^{-nn} \). `a1`, `a2` and `nn` are all variables which are assigned random positive integers. These are then used to define the variable `exp`, used in the question itself. We also have the CAS integrate the expression `exp` and store the result in the variable `ta`. It is good practice to use variables names with more than one character as single-character variables, like `x`, are meant for student input.
33+
In this new question we are asking the student to find the anti-derivative of a question with a definite form \( a_1(x-a_2)^{-nn} \). `a1`, `a2` and `nn` are all variables which are assigned random positive integers. These are then used to define the variable `ex1`, used in the question itself. We also have the CAS integrate the expression `ex1` and store the result in the variable `ta1`. It is good practice to use variables names with more than one character as single-character variables, like `x`, are meant for student input.
3434

3535
Remember that when generating random questions in STACK we talk about _random numbers_ when we really mean _pseudo-random numbers_. To keep track of which random numbers are generated for each user, there is a special `rand` command in STACK, which you should use instead of [Maxima](../CAS/Maxima_background.md)'s random command. The `rand` command is a general "random thing" generator, see the page on [random generation](../CAS/Random.md) for full details. `rand` can be used to generate random numbers and also to make selections from a list. `rand(n)` will select a random integer from 0 up to, **and not including**, `n`. So `rand(3)` will select a random number from the list `[0,1,2]` .
3636

@@ -40,7 +40,7 @@ Now that as our question contains random numbers, we need to record the actual q
4040
Fill the question note in as
4141

4242
```
43-
\[ \int {@exp@} \mathrm{d}x = {@ta@}.\]
43+
\[ \int {@ex1@} \mathrm{d}x = {@ta1@}.\]
4444
```
4545

4646
Two question variants are considered to be the same if and only if the question note is the same. It is the teacher's responsibility to create sensible notes.

doc/en/AbInitio/Authoring_quick_start_5.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ In the last couple of parts, we have been working with a simple integration ques
1313
a1 : 1+rand(6);
1414
a2 : 1+rand(6);
1515
nn : 2+rand(4);
16-
exp : a1*(x-a2)^(-nn);
17-
ta: int(exp, x)+c;
16+
ex1 : a1*(x-a2)^(-nn);
17+
ta1: int(ex1, x)+c;
1818
```
1919

2020
Testing questions is time consuming and tedious, but important to ensure questions work. To help with this process, STACK enables teachers to define "question tests". The principle is the same as "unit testing" in software engineering.
@@ -30,22 +30,22 @@ The penalty is a number deducted from the total mark for each incorrect attempt
3030
Fill in the following information for your first test case:
3131

3232
```
33-
ans1 = ta
33+
ans1 = ta1
3434
score = 1
3535
penalty = 0
3636
answernote = prt1-2-T
3737
```
3838

3939
I.e., if the student puts in the model answer they should pass the first node (checks if they have integrated correctly) and pass the second node (tests that their answer is factored) and end up with a score of 1 and no penalty.
4040

41-
Note that the input is evaluated before the test is conducted. Students are not allowed to enter the variable `ta` because it is a teacher-defined variable, however the evaluated form, fx. `-1*(x-1)^(-3)+c`, is an allowed input. For each test case, you can see the un-evaluated input under `Test input`, and the actual input tested under `Value entered`.
41+
Note that the input is evaluated before the test is conducted. Students are not allowed to enter the variable `ta1` because it is a teacher-defined variable, however the evaluated form, fx. `-1*(x-1)^(-3)+c`, is an allowed input. For each test case, you can see the un-evaluated input under `Test input`, and the actual input tested under `Value entered`.
4242

4343
You can run the test on all deployed versions by clicking on `Run all tests on all deployed variants` .
4444

4545
You can add as many tests as you think is needed, and it is usually a sensible idea to add one for each case you anticipate. Add in another test case for
4646

4747
```
48-
ans1 = int(exp,x)
48+
ans1 = int(ex1,x)
4949
score = 0
5050
penalty = 0.1
5151
answernote = prt1-1-F

doc/en/Authoring/Question_blocks/Static_blocks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ The template block has two parameters, the first being a name which should be a
9292

9393
Note in the background templates are just functions with CASText values. You can do the same with inline CASText and more importantly building your own functions allows you to use arguments for them and thus makes repetition with varying parameters simpler. For templates no arguments exist, for them the values come from the context where they get placed in, and must therefore be controlled though other means.
9494

95+
Note that if you wish to use a template in both the question text and in the PRT feedback, you will need to define it in the question variables (in particular, if you define the template in the question text, it will not work in the PRT feedback since the PRT feedback is evaluated in a different scope from the question text). For instance:
96+
97+
define_my_template: castext("[[template name="foobar"]]Whatever is {@whatever@}[[/template]]");
98+
99+
You can then use `[[template name="foobar"/]]` throughout the question.
100+
95101
## Entity escape block ##
96102

97103
Sometimes one needs to author content that uses characters that are sensitive in HTML syntax. If one wraps that content in this block those characters will be automatically converted to HTML-entities during output. Can be very useful when including sample blocks of code, that includes certain operators. `[[entityescape]] code with some less than chars [[/entityescape]]`.

doc/en/Developer/Development_track.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,23 @@ Issues with [github milestone 4.13.0](https://github.com/maths/moodle-qtype_stac
1111

1212
1. Remove all "cte" code from Maxima - mostly install.
1313
2. Support for Maxima 5.47.0, 5.48.0, and 5.49.0. This includes a fix for issue #1281 from 5.48.0.
14+
3. Question tests can now test the whole route through a PRT, rather than just the final node. This is a significant improvement on the ability to test questions. This is back-compatible with older questions.
1415

1516
--------------------------------------
16-
## Testing a node, not a whole tree
1717

18-
This section is a detailed design proposal to improve question testing to test a node, not a whole tree, and address issue #1703.
19-
20-
### Change of `expectedanswernote`
21-
22-
Make DB changes to considerably lengthen `expectedanswernote` from 255 chars: https://github.com/maths/moodle-qtype_stack/blob/master/db/install.xml#L178
18+
## Better testing
2319

2420
### Add in a new keyvals field "test variables".
2521

2622
Add in a new keyvals field "test variables". The test execution would then take three CAS sessions.
2723

28-
1. Loading up the seed, question variables, test variables and all input definitions, generating input "strings".
24+
1. Loading up the seed, question variables, test variables and all input definitions, generating input "strings".
2925
2. Those "strings" would then go through PHP side input validation and CAS side validation in the second CAS session.
3026
3. Finally, the valid strings would be fed to the PRT functions in the last session, and logic to check if the PRT output matches would be included in that session, so that we do not need to output the full PRT function output for potentially a large number of tests, instead just booleans.
3127

32-
### Other ideas (later)
28+
Other ideas
3329

3430
1. It would be a fun (student project?!) to graphically illustrate the expected and actual route through the tree by expanding the current PRT graph library, or writing something else. (I get ahead of myself of course....)
35-
3631
2. Introduce new keyword `any` in score/penalty effectiveley ignoring that field for the purposes of this test case.
3732

3833
Currently, the DB fields for score and penalty are numbers, specifically
@@ -42,7 +37,6 @@ Currently, the DB fields for score and penalty are numbers, specifically
4237

4338
So this requires a DB change as well.
4439

45-
4640
--------------------------------------
4741

4842
## Future Adapt block development ideas

stack/maxima/contrib/vectorgeometry.mac

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ vector_parametric_parts(vec, [exclude_params]):=block([simp:true, vars, nonlinva
115115
* @param[list] parts A list with three elements (see vector_parametric_parts) [mx1 matrix of constants, a list of mx1 matrices of constants, a list of variable names]
116116
* @return[string] TeX output of a vector parametric equation in a "standard" form.
117117
*/
118-
vector_parametric_display(parts):= block([simp:false,cons_vec,dir_vecs,vars],
118+
vector_parametric_display(parts):= block([simp:false,cons_vec,dir_vecs,vars,cons_p,dir_p],
119119
[cons_vec,dir_vecs,vars]: parts,
120-
return(sconcat(tex1(cons_vec),"+",tex1(apply("+", zip_with("*", vars, dir_vecs)))))
120+
cons_p: if ev(zeromatrixp(cons_vec),simp) then "" else tex1(cons_vec),
121+
if emptyp(dir_vecs) then dir_p: [] else dir_p: zip_with("*", vars, dir_vecs),
122+
if is(length(dir_p)=0) then dir_p: "" else if is(length(dir_p)=1) then dir_p: tex1(first(dir_p)) else dir_p: tex1(apply("+",dir_p)),
123+
return(sconcat(cons_p,if is(cons_p="") or is(dir_p="") then "" else "+",dir_p))
121124
);
122125

123126
/**

stack/maxima/contrib/vectorgeometry_test.mac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ s_test_case(vector_parametric_parts(matrix([1],[2],[3]) + t*matrix([1],[1],[1])
5959
make_multsgn("dot");
6060
s_test_case(vector_parametric_display([matrix([1],[2],[3]),[matrix([1],[0],[1]),matrix([1],[1],[1])],[s,t]]),"\\left[\\begin{array}{c} 1 \\\\ 2 \\\\ 3 \\end{array}\\right]+s\\cdot \\left[\\begin{array}{c} 1 \\\\ 0 \\\\ 1 \\end{array}\\right]+t\\cdot \\left[\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right]");
6161
s_test_case(vector_parametric_display(vector_parametric_parts(matrix([1+t+s],[2+t],[3+t+s]))),"\\left[\\begin{array}{c} 1 \\\\ 2 \\\\ 3 \\end{array}\\right]+s\\cdot \\left[\\begin{array}{c} 1 \\\\ 0 \\\\ 1 \\end{array}\\right]+t\\cdot \\left[\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right]");
62+
s_test_case(vector_parametric_display(vector_parametric_parts(c(1,2,3))),"\\left[\\begin{array}{c} 1 \\\\ 2 \\\\ 3 \\end{array}\\right]");
63+
s_test_case(vector_parametric_display(vector_parametric_parts(c(1,2,3) + t*c(2,3,4))),"\\left[\\begin{array}{c} 1 \\\\ 2 \\\\ 3 \\end{array}\\right]+t\\cdot \\left[\\begin{array}{c} 2 \\\\ 3 \\\\ 4 \\end{array}\\right]");
64+
s_test_case(vector_parametric_display(vector_parametric_parts(t*c(2,3,4))),"t\\cdot \\left[\\begin{array}{c} 2 \\\\ 3 \\\\ 4 \\end{array}\\right]");
65+
s_test_case(vector_parametric_display(vector_parametric_parts(t*c(2,3,4) + s*c(3,4,5))),"s\\cdot \\left[\\begin{array}{c} 3 \\\\ 4 \\\\ 5 \\end{array}\\right]+t\\cdot \\left[\\begin{array}{c} 2 \\\\ 3 \\\\ 4 \\end{array}\\right]");
6266

6367
s_test_case(point_in_affine_spacep(matrix([1],[1]),[matrix([0],[1]),[matrix([1],[-1])]]),false);
6468
s_test_case(point_in_affine_spacep(matrix([1],[1]),[matrix([0],[1]),[matrix([1],[-1])],[t]]),false);

0 commit comments

Comments
 (0)