You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/Authoring/Inclusions.md
+15-13
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,25 @@
1
1
# Inclusions
2
2
3
-
This is an expert level topic, please avoid this feature unless you feel that you understand the implications and consequences of it. Note that using this feature goes against the self-contained material principle present in [the future proof guidelines](../STACK_question_admin/Future_proof.md).
3
+
STACK provides a mechanism for sharing code between questions. For example, you can include small libraries of Maxima functions, dedicated to specific topics, in the question variables.
4
4
5
-
That being said, a common request on the wish-list has been to provide some means of sharing code between questions. The inclusion-feature is the first step towards such a feature, however, it is not perfect nor do we expect it to be the solution that will finally be selected. But we provide it now that the back-end has the tools to provide it, for those adventurous enough.
5
+
There is a tension between (i) reusing libraries of functions between questions and (ii) the self-contained material principle present in [the future proof guidelines](../STACK_question_admin/Future_proof.md).
6
+
7
+
This is an expert level topic, please avoid this feature unless you feel that you understand the implications and consequences of it.
6
8
7
9
Technical note: Currently, inclusions within inclusions are not supported, due to loop detection and security validation reasons.
8
10
9
11
## Inclusions life-cycle
10
12
11
-
For all current types of inclusions the inclusion happens at the time of compilation,
12
-
which means that the source will be fetched when the question gets compiled and will
13
-
stay in the cached compilation product. Compilation happens during the first use of
14
-
the question after it has been saved or the cache has been purged.
13
+
For all current types of inclusions the inclusion happens at the time of question compilation,
14
+
which means that the source will be fetched when the question gets compiled and will stay in the cached compilation product.
15
+
Compilation happens during _the first use_ of the question after it has been saved or the cache has been purged.
15
16
16
-
The logic will not track changes to the source material, if one wants to fetch it
17
-
again one must re-compile the question, either by purging the caches or by editing
17
+
The inclusion logic will not track changes to the source material.
18
+
If one wants to fetch it again one must re-compile the question, either by purging the caches or by editing
18
19
the question.
19
20
20
-
Note that in the current solution during export we export only the source address
21
-
and the exported material will only work if the address is accessible at the end
22
-
that imports it.
21
+
Note that in the current solution during export we export only the _source address_
22
+
and the exported material will only work if the address is accessible at the end that imports it.
23
23
24
24
25
25
## Inclusions within text
@@ -58,7 +58,8 @@ math-mode is not quite ready to understand all of these context switches.
58
58
## Inclusions within CAS-logic
59
59
60
60
You can also include code into keyvals, i.e. question-variables or into feedback-variables.
61
-
This type of an inclusion will again act just as if written directly by the question author at that place in the code. If one writes this type of an inclusion within an if-statement it will simply get written open within
61
+
This type of an inclusion will act just as if written directly by the question author at that place in the code.
62
+
If one writes this type of an inclusion within an if-statement it will simply get written open within
62
63
an if-statement, the `if` will only decide if it executes, but it will still take that space and bandwidth.
63
64
64
65
The included material must follow all the rules of normal STACK keyvals.
@@ -70,7 +71,7 @@ The included material must follow all the rules of normal STACK keyvals.
70
71
71
72
Note that we do not do "tree-shaking" at this point to remove unnecessary code. If you include a massive library of functions that you do not use the question will still have to load those functions into the CAS and that may take some time. If you have libraries, used in many questions, please consider contributing these to the core of STACK.
72
73
73
-
To include external CAS code call the `stack_include()`-function with a string argument. The argument must be a raw string, containing the URL of the code. You cannot reference a variable containing such a string. For example,
74
+
To include external CAS code call the `stack_include()` - function with a string argument. The argument must be a raw string, containing the URL of the code. You cannot reference a variable containing such a string. For example,
74
75
75
76
```
76
77
a: rand(3)+2;
@@ -99,6 +100,7 @@ Notes.
99
100
1. We will try to keep files in the contrib folder small, and stable.
100
101
2. We intend to move commonly used contributed code into the core in due course. At that point we will localise language strings for automatic translation.
101
102
3. Please contact the developers about naming conventions. For example, external validators should start the function name with `validator_`.
103
+
4. If you wish to use the libraries locally, on your server, prepend the file name with `contribl://`, e.g. `stack_include_contrib("matchlib.mac");` will load the local file, not the file on github. This is mostly for local development, before code is pushed to the master branch. We advise against this for live questions.
This page documents the use of matrices in STACK. There is a topics page for setting [linear algebra](../Topics/Linear_algebra.md) STACK questions.
3
+
This page documents the use of matrices in STACK. There is a topics page for setting [linear algebra](../Topics/Linear_algebra/index.md) STACK questions.
4
4
5
5
## Matrices ##
6
6
7
-
Note that in Maxima, the operator `.` represents noncommutative multiplication and scalar product. The star `A*B` gives element-wise multiplication.
7
+
The operator `.` represents noncommutative multiplication and scalar product. The star `A*B` gives element-wise multiplication.
8
8
9
+
Maxima functions `addrow` and `addcol` appends rows/columns onto the matrix.
9
10
10
-
The following functions are part of Maxima, but are very useful for us.
11
+
Maxima functions perform row operations
11
12
12
13
rowswap(m,i,j)
13
14
rowadd(m,i,j,k)
@@ -17,13 +18,10 @@ Where ` m[i]: m[i] + k * m[j]`.
17
18
rowmul(m,i,k)
18
19
19
20
Where `m[i]: k * m[i]`.
20
-
And a function to compute reduced row echelon form
21
21
22
-
rref(m)
23
-
24
-
(Note the Maxima functions `addrow` and `addcol` appends rows/columns onto the matrix.)
22
+
STACK provides a function to compute reduced row echelon form
25
23
26
-
STACK has a library for creating [structured random matrices](Random.md).
24
+
rref(m)
27
25
28
26
## Assigning individual elements ##
29
27
@@ -82,41 +80,6 @@ Now it makes no sense to include the point wise multiplication of elements as a
82
80
83
81
There must be a more elegant way to do this!
84
82
85
-
## Matrices and answer tests
86
-
87
-
Some answer tests accept matrices as arguments. E.g. algebraic equivalence (`ATAlgEquiv`) will accept matrices, even of different sizes, and return feedback underlining which elements are different. This is a rather blunt tool, since it is all or nothing. And, it's often necessary to apply other answer tests to corresponding elements of matrices.
88
-
89
-
1. Every answer test in STACK has a corresponding function in Maxima. The Maxima function name of AlgEquiv is `ATAlgEquiv`, et.
90
-
2. The Maxima code for every answer in STACK returns a list of four elements. The _second_ element is the result of the test. See the [documentation](../Authoring/Answer_Tests/index.md) for details of the other elements. For example `second(ATComAss(x+y,y+x))` is `true` because \(x+y=y+x\) up to commutativity etc (using `ATComAss`).
91
-
3. Some answer tests take an optional agument, e.g. numerical accuracy. to use `zip_with_matrix` we need to create an un-named (lambda) function of two arguments. E.g. `lambda([ex1,ex2], ATNumAbsolute(ex1,ex2,0.01)` can be used to test corresponding matrix elements are within \(0.01\) of each other.
92
-
93
-
Once you have a matrix `M` of boolean values, you could count the number which are false.
You can set the type of parentheses used to surround matrices in a number of ways. Firstly, the admin user should set the site default in the qtype_stack options page.
@@ -151,74 +114,3 @@ To change to right aligned columns, switch `"c"` to `"r"`. This function takes
151
114
152
115
For this function to take effect in the whole question, including validation of students' input, place the redefinition before `%_stack_preamble_end;` in the question variables.
153
116
154
-
## Vectors ## {#vectors}
155
-
156
-
If you are trying to use the vector notation such as \(3i+4j\) you will probably want to redefine \(i\) to be an abstract symbol, not a complex number.
157
-
More information on this is given under [Numbers](Numbers.md). In particular, use the question level option "Meaning and display of sqrt(-1)" value `symi` to stop interpreting `i` with `i^2=-1` and return it to being an abstract symbol.
158
-
159
-
Another way to do this is to create matrices as follows:
160
-
161
-
ordergreat(i,j,k);
162
-
%_stack_preamble_end;
163
-
p:matrix([-7],[2],[-3]);
164
-
q:matrix([i],[j],[k]);
165
-
166
-
Now we can use the dot product to create the vector. The STACK function `texboldatoms` wraps all atomic variable names in the ephemeral function `stackvector`, which is typeset in bold.
167
-
168
-
v:texboldatoms(dotproduct(p,q));
169
-
170
-
If you turn the option "Multiplication sign" to none, this should display as
171
-
\[-7\,{\bf{i}}+2\,{\bf{j}}-3\,{\bf{k}}\]
172
-
Notice the use of the function `ordergreat`. `ordergreat` can only be used once at the beginning of the question.
173
-
174
-
If you use the special constant `%_stack_preamble_end;` then anything before this constant will be available everywhere in the question, including the inputs.
175
-
176
-
The vector `stackvector(a)` and the atom `a` are different, and are not considered algebraically equivalent. While students may type in `stackvector(a)` as an answer, they are likely to type in `a`. The teacher can either (1) add in `stackvector` ephemeral forms to the student's answer in the feedback variables using `texboldatoms` or (2) remove all `stackvector` forms from the teacher's answer by using the `destackvector(ex)` function on their answer. In the future we may have an option in the input to apply texboldatoms to student's expressions.
177
-
178
-
The display of the ephemeral form of `stackvector` is controlled by the function `stackvectortex`, e.g. you can display vectors differently using the following examples.
Any `texput` commands in the question variables now become "context variables" and will be available to the inputs. So, if in the context of your question you would like a variable such as `x` to be considered as a vector and displayed as a vector you can add one of the following to the question variables.
186
-
187
-
texput(x, "\\mathbf{\\vec{x}}");
188
-
texput(x, "\\mathbf{\\underline{x}}");
189
-
190
-
Whenever `x` is then displayed in any part of the question, including the student's input validation or feedback generated by the answer tests, we will have the updated tex for this atom. E.g.
191
-
192
-
texput(x, "\\mathbf{\\vec{x}}");
193
-
texput(y, "\\mathbf{\\vec{y}}");
194
-
195
-
and a student types in `a*x+b*y` then the tex output will be \(a\cdot \mathbf{\vec{x}}+b\cdot \mathbf{\vec{y}}\).
196
-
197
-
### Vector cross product ###
198
-
199
-
The wedge product operator is denoted by the tilde `~`. This is the `itensor` package. This package is not normally loaded by STACK, and in any case the package takes lists and not matrices. For convenience, the following function has been added which requires `3*1` matrices.
200
-
201
-
crossproduct(a,b);
202
-
203
-
Another advantage of this function is the ability to return an un-simplified version with `simp:false`.
204
-
205
-
## Student input ##
206
-
207
-
Students do find typing in matrices very tedious. Some teachers have asked for a convenient notation such as
208
-
209
-
c(1,2,3)
210
-
211
-
for column vectors and
212
-
213
-
v(1,2,3,4)
214
-
215
-
For row vectors. This is not a core part of STACK currently, but in individual questions you can convert such notation easily into mainstream Maxima using code such as the following.
216
-
217
-
ta1:c(1,2,3);
218
-
ta2:v(1,2,3);
219
-
vec_convert(sa) := if op(sa)=c then transpose(matrix(args(sa))) elseif op(sa)=v then matrix(args(sa));
220
-
vec_convert(ta1);
221
-
vec_convert(ta2);
222
-
223
-
Once converted into Matrices, the student's answer will be evaluated by PRTs as matrices. Of course, this will not be reflected in the valuation. If there is sufficient demand for this contact the developers.
Copy file name to clipboardExpand all lines: doc/en/CAS/Maxima_background.md
-1
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,6 @@ By default, the list does not contain multiplicities. If the list should contain
92
92
| `comp_square(ex,v)` | Returns a quadratic `ex` in the variable `v` in completed square form.
93
93
| `degree(ex,v)` | Returns the degree of the expanded form of `ex` in the variable `v`. See also Maxima's `hipow` command.
94
94
| `unary_minus_sort(ex)` | Tidies up the way unary minus is represented within expressions when `simp:false`. See also [simplification](Simplification.md).
95
-
| `texboldatoms(ex)` | Displays all non-numeric atoms in bold. Useful for vector questions.
Copy file name to clipboardExpand all lines: doc/en/Developer/Development_track.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,13 @@ We use the [github issue tracker](https://github.com/maths/moodle-qtype_stack/is
7
7
8
8
## Version 4.9.0
9
9
10
-
Done.
11
10
1. Introduce `ta` as the default teacher's answer in the question variables, and use this in the input and default prt. Allow addition of multiple nodes in a PRT with one click.
12
-
2. Support `allowrmpty` for dropdown, radio and checkbox inputs.
13
-
3.Include the `rand_matrix.mac` contributed library, a collection of matrix randomisation functions for use in linear algebra, with the local STACK source code. See the [random](../CAS/Random.md) documentation for details.
11
+
2. Support `allowempty` for dropdown, radio and checkbox inputs.
12
+
3.Add in the `space` option, i.e. `make_multsgn("space")`in the [options](../Authoring/Question_options.md).
14
13
4. Convert input "syntax hint" to castext.
15
-
5. Add in the `space` option, i.e. `make_multsgn("space")` in the [options](../Authoring/Question_options.md).
16
-
14
+
5. Include the `rand_matrix.mac` contributed library, a collection of matrix randomisation functions for use in linear algebra, with the local STACK source code. See the [random](../Topics/Linear_algebra/Random_Matrices.md) documentation for details.
15
+
6. Add in a substantial library for dealing with [linear algebra problems](../Topics/Linear_algebra/index.md).
16
+
7. Load Maxima's `eigen` library.
17
17
18
18
Issues with [github milestone 4.9.0](https://github.com/maths/moodle-qtype_stack/issues?q=is%3Aissue+milestone%3A4.9.0) include
0 commit comments