Question types: STACK

Maintained by Picture of Christopher Sangwin Christopher Sangwin, Tim at Lone Pine Koala Sanctuary Tim Hunt
The STACK question type adds a sophisticated assessment in mathematics and related disciplines, with emphasis on formative assessment underpinned by computer algebra.
754 sites
26 fans

The STACK system is a computer aided assessment package for mathematics, which provides a question type for the Moodle quiz. In computer aided assessment (CAA), there are two classes of question types.

  • Selected response questions
    In these questions, a student makes a selection from, or interacts with, potential answers which the teacher has selected. Examples include multiple choice, multiple response and so on.
  • Student-provided answer question
    In these questions the student's answer contains the content. It is not a selection. Examples of these are numeric questions.

STACK concentrates on student-provided answers which are mathematical expressions. For example, a student might respond to a question with a polynomial or matrix. Essentially STACK asks for mathematical expressions and evaluates these using computer algebra. The prototype test is the following pseudo-code.

  simplify(student_answer-teacher_answer) = 0
  mark = 1,
  mark = 0.

STACK uses a computer algebra system (CAS) to implement these mathematical functions. A CAS provides a library of functions with which to manipulate students' answers and generate outcomes such as providing feedback. Establishing algebraic equivalence with a correct answer is only one kind of manipulation which is possible.

Using CAS can also help generate random yet structured problems, and corresponding worked solutions.

In STACK a lot of attention has been paid to allowing teachers to author and manage their own questions. The following are the key features.

  • Question versions are randomly generated within structured templates.
  • There are many different kinds of inputs. These are, for example, where the student enters a mathematical expression, or makes a true/false selection.
  • Mathematical properties of students' answers are established using answer tests within the CAS Maxima.
  • Feedback is assigned on the basis of these properties using a potential response tree. This feedback includes:
    1. Textual comments for the student.
    2. A numerical mark.
    3. Answer notes from which statistics for the teacher are compiled.

These broadly correspond to formative, summative and evaluative functions of assessment. Which of these outcomes is available to the student, and when, is under the control of the teacher.

  • Multi-part mathematical questions are possible: each question may have any number of inputs and any number of potential response trees. There need not be a one-to-one correspondence between these.
  • Partial credit is possible when an expression only satisfies some of the required properties.
  • Plots can be dynamically generated and included within any part of the question, including feedback in the form of a plot of the student's expression.


This plugin is part of set STACK.


Screenshot #0


Picture of Christopher Sangwin
Christopher Sangwin (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Christopher Sangwin
    Fri, 9 Sep 2016, 11:19 PM
    Yes Andreas,
    The larger sites using STACK find this very convenient.
  • Picture of Stephen Parry
    Thu, 2 Mar 2017, 10:36 AM
    I am running the following setup:
    Moodle 3.2.1+ (Build: 20170223) Version 2016120501.09
    Ubuntu 14.04
    maxima 5.32.1
    I have had real problems getting the system to run. It kept falling over during the compilation of draw/grcommon.lisp, with no meaningful error messages. Running from the regular shell either as myself or www-data was working fine (providing $HOME was set correctly). Fortunately I am familiar enough with LISP that with a lot of hacking about I was able to determine the cause at least within draw.lisp. Compiling grcommon.lisp requires access to gcc, but for some reason in STACK maxima, the system path is completely empty (NIL). This causes gcc not to be found and the compilation to fail. I managed to get it working by hacking in a minimal (system::setenv "PATH" ...) in the draw.lisp file, but that is obviously not great. Is there a configuration setting somewhere within STACK that would sort this please?
  • Picture of Stephen Parry
    Thu, 2 Mar 2017, 7:19 PM
    OK, I've found where the error is:
    $env = array('why' => 'itworks');

    This clears out the environment, including the path which is needed for compilation. Can we have a fix please?
  • Tim at Lone Pine Koala Sanctuary
    Thu, 2 Mar 2017, 8:29 PM
    Please could you open a Pull requestion on githhub for this issue.

    Note, that like of code has been there at least since the current incarnation of STACK as a Moodle question type started:, and no-one else has a problem with it. When you open the pull repease, please let us know which LISP variant you are using.
  • Tim at Lone Pine Koala Sanctuary
    Thu, 2 Mar 2017, 8:29 PM
    Sorry, I mean github issue, not pull request.
  • Picture of Stephen Parry
    Thu, 2 Mar 2017, 11:25 PM
    Will post an issue as requested. Yes, I was puzzled why nobody else has raised it. I get the impression a lot of people go for optimized because of advice online regarding other. It is possible to workaround thie issue without even realising it, by pre-running using su / sudo. This only works however if your setup yields the same $HOME when in apache2 STACK and when invoking su / sudo to become www-data. In my case it did not - apache2 STACK was null; sudo try to re-use my own home directory.

    I also suspect other version / lisp dialect combinations lack this issue. It's complex.
  • Picture of Stephen Parry
    Mon, 6 Mar 2017, 10:51 PM
    I have posted an issue on github, including a small patch that fixes the issue - the problem is in `question/type/stack/stack/cas/connector.unix.class.php`; This is where the environment for Maxima is (not) set.
  • Picture of Stephen Parry
    Fri, 10 Mar 2017, 1:47 PM
    I had to upgrade my server drastically (Ubuntu 14.04 -> 16.04) this weekend, and one of the casualties was Stack. After finding that the version of Maxima (5.37.2 ?) packaged with 16.04 is broken, I built 5.39.0 from source and tested that against Stack all the tests pass except these two:
    Units Fail 18*kJ 18000.0*J 2 1 1 ATUnits_compatible_units: (kg*m^2)/s^2. [NOTE expected: ATUnits_compatible_units: kg*m^2/s^2.]
    Units Fail 18.1*kJ 18000.0*J 2 0 0
    Your answer contains the wrong number of significant digits.
    ATUnitsSigFigs_WrongDigits. ATUnits_compatible_units: (kg*m^2)/s^2. [NOTE expected: ATUnitsSigFigs_WrongDigits. ATUnits_compatible_units: kg*m^2/s^2.]
    It seems there were unexpected parenths in the units. Is this a bug and if so in Maxima or in Stack please? Thanks.
  • Tim at Lone Pine Koala Sanctuary
    Fri, 10 Mar 2017, 4:49 PM
    It is not exactly a bug. What happens is that different versions of Maxima, or Maxima running on different flavours of LISP, return some expressions in slightly different forms. The question is: is that difference significant in the context of how people want to use STACK. In this case, probably yes, because humans would never write those units with brackets. Therefore, we probably need Chris to tame these differences with some more Maxima code in the STACK libraries.

    Anyway, there is an open github issue about this: Not sure when it will get fixed.

    These unit tests fails are very specific. They won't stop your questions from working.
  • Picture of Christopher Sangwin
    Fri, 10 Mar 2017, 5:12 PM
    Thanks for pointing this out. It is a *change* in Maxima behaviour. There have been quite a few over the years and I have to adapt STACK to them while maintaining the past behaviour. This is on my radar and I'll certainly look at it. It is a very subtle change in associtativity and the rules which govern order of precedence. Basically it is a change from (a*b)/c to a*(b/c). Does this matter? In this case not really at a mathematical level. In some very elementary mathematics it does. It isn't really a bug, more a change in designed behaviour...
  • Picture of Stephen Parry
    Wed, 15 Mar 2017, 5:34 AM
    Thanks for the quick turnaround on #281 and you're welcome on the bug report.

    I teach A level Computer Science and I am hoping to configure / extend STACK to cope with some Computer Science problems e.g. integer, fixed and floating point base 2 and 16 conversions and arithmetic; boolean algebra and anything else I can get it to do. Are you open to some contributions in this area?
  • Picture of Christopher Sangwin
    Wed, 15 Mar 2017, 6:24 AM
    Yes Stephen, very open to contributions. If you are based in the UK, then getting together to talk about this might be possible and productive. I know CS needs some features we haven't added yet. Maxima has good support for *display* of numbers in other bases, but we might need some input and evaluation functions. Someone else in Edinburgh is working on Boolean algebra, but I'm not sure if that will make its way into STACK!

    Please do get involved.
  • Picture of Phan Chon
    Wed, 2 Aug 2017, 10:56 AM
    Hi all,

    Please let me know wich version can work fine with moodle 3.3!

  • Picture of Christopher Sangwin
    Wed, 2 Aug 2017, 4:36 PM
    Thanks for the question Phan Chon,
    I'm in the process of final testing for STACK 3.6 and STACK 4.0 (both will be released within days of each other. STACK 4.0 is an irreversible upgrade). They will both work with Moodle 3.3.

  • Picture of Joël Schmid
    Thu, 14 Sep 2017, 3:09 PM
    Hey guys,
    If someone else has maxima version 5.38.0 on CentOS 7 installed from the EPEL repo, the STACK optimisation doesn't currently work. Rebuilding 5.38.1 from source, seems to solve the problem.
    See for more information.
    Cheers, Joël
1 2 3 4
Please login to post comments