Question Authors' Forum

Chained coderunner questions

Chained coderunner questions

de Sylvain Salvati -
Número de respuestas: 5

I am writting a course of Logic using coderunner. I would like students to answer one question using a formula in propositional logic. With coderunner I check whether that formula is equivalent to the expected answer. Then the student has to construct a truth value table for that formula in a second question. The difficulty here is that there is a dependence between the answer to the first question : the student formula and the answer to the second question : the truth table for that specific formula. Is it possible to make such an exercice ?

PS : I have implemented formula equivalence, and construction of truth table for specific formulae. So the issue is the dependency between the answers.

En respuesta a Sylvain Salvati

Re: Chained coderunner questions

de Richard Lobb -

I don't know any way of associating the grading of one question with the answer to a previous one. And it would break the usual assumption in Moodle quizzes that students can attempt quiz questions in any order.

What you could perhaps do instead is set a single question in which there are two entry fields: one for the formula and one for the truth table. If students are currently submitting both the formula and the truth table as pure text, you could use a GapfillerUI to define the two TextAreas. For example:


The template I used in that example simply prints the JSON-decoded STUDENT_ANSWER, which is a list of the textual field values. The template is

import json
fields = json.loads("""{{ STUDENT_ANSWER | e('py') }}""")
print(fields)

You would need to use a template grader and grade the two parts separately, printing the appropriate JSON encoded feedback and mark (see the documentation).

However, if your second question is already using the TableUI for the student's truth table (which would be much nicer than a text box), your job becomes harder. You'd then have to use the HtmlUI and construct a form with a field for the formula and a table with <input> elements in all cells for the truth table. If you wanted students to be able to click buttons to add rows and columns to their table, you could include appropriate JavaScript within the form, but it does get rather complicated at that point.

En respuesta a Richard Lobb

Re: Chained coderunner questions

de Sylvain Salvati -

Thank you for the anwer, it is helpful. Concerning the truth table, I was thinking to let the student use a spreadsheet outsied moodle and submit a CSV file. This allows me to avoid javascript complications. ]

En respuesta a Richard Lobb

Re: Chained coderunner questions

de Sylvain Salvati -

Actually, I do not see how to add another answer text area. I have thus some further questions :

1. how to add another text-area ?

2. is it possible to add another kind of answer object (check-box, ...) ?

En respuesta a Sylvain Salvati

Re: Chained coderunner questions

de Richard Lobb -

You have to customise the question (click the "Customise" check box) and then, in the Customisation block, you'll see an option to select the Input User Interface (UI). The different options are documented here, although I've just noticed that I still say in the introduction that only the Ace UI and Graph UI are built in. That's not true: as you'll see from the drop-down UI selector you have Ace, GapFiller, Graph, Html and Table.

The demo I showed in my previous post used the GapFiller UI and sets the Global extra field (which defines the format of the answer box) to:

(a) Enter your formula for ... in the following answer box.
{[ 5, 80 ]}

(b) Enter the truth table corresponding to your answer for part (a) in the following answer box.
{[ 10, 80 ]}

The entries {[ 5, 80 ]} and {[ 10, 80 ]} define a 5 line by 80 column text area and a 10 line by 80 column text area respectively. The rest of the content appears verbatim, as pure text.

To get anything other than just simple input or textarea elements in the answer box you need to use the HTML UI, documented here and here. This is relatively new and somewhat experimental but other people have started using it, so I'm now pretty much committed to maintaining it as a core feature. Here's an image of an HTML UI question. 


The xml export is attached. This example doesn't do any grading - everything submitted gets full marks. In a practical question you have to write your own template grader.

To toggle between the HTML view and the underlying textual serialisation, type Ctrl+Alt+M. THis works with all UIs, including Ace.

En respuesta a Richard Lobb

Re: Chained coderunner questions

de Sylvain Salvati -

Thank you very much. It is very helpful.

As a side note, I use Haskell to check the results following the indications of the "extra language section". This works very well.