Skip to content
Snippets Groups Projects
Commit 9200c051 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Related to issue #933.

parent cd109723
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 3075 -->
<question type="stack">
<name>
<text>Serving out data: download file</text>
</name>
<questiontext format="html">
<text><![CDATA[[[comment]]Use them like this in the question-text.[[/comment]]
<p>Load the data from
<a href="[[textdownload name="data.csv"]]{@stack_csv_formatter(data,lab)@}[[/textdownload]]">this file</a> and calculate the mean of data set \(A\).</p>
<p>[[input:ans1]] [[validation:ans1]]</p>]]></text>
</questiontext>
<generalfeedback format="moodle_auto_format">
<text></text>
</generalfeedback>
<defaultgrade>1</defaultgrade>
<penalty>0.1</penalty>
<hidden>0</hidden>
<idnumber></idnumber>
<stackversion>
<text>2023010401</text>
</stackversion>
<questionvariables>
<text><![CDATA[/* Define these in question variables: */
lab: ["A","B","C"];
data: makelist([rand(322)/100.0,rand(600)/100.0,rand(300)/100.0], i, 50);
/* And make a question. */
taA: mean(map(first,data));
taB: mean(map(second,data));
taC: mean(map(third,data));
]]></text>
</questionvariables>
<specificfeedback format="html">
<text>[[feedback:prt1]]</text>
</specificfeedback>
<questionnote>
<text>{@dispsf(taA,4)@}</text>
</questionnote>
<questionsimplify>1</questionsimplify>
<assumepositive>0</assumepositive>
<assumereal>0</assumereal>
<prtcorrect format="html">
<text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
</prtcorrect>
<prtpartiallycorrect format="html">
<text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
</prtpartiallycorrect>
<prtincorrect format="html">
<text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
</prtincorrect>
<multiplicationsign>dot</multiplicationsign>
<sqrtsign>1</sqrtsign>
<complexno>i</complexno>
<inversetrig>cos-1</inversetrig>
<logicsymbol>lang</logicsymbol>
<matrixparens>[</matrixparens>
<variantsselectionseed></variantsselectionseed>
<input>
<name>ans1</name>
<type>numerical</type>
<tans>dispsf(taA,4)</tans>
<boxsize>15</boxsize>
<strictsyntax>1</strictsyntax>
<insertstars>0</insertstars>
<syntaxhint></syntaxhint>
<syntaxattribute>0</syntaxattribute>
<forbidwords></forbidwords>
<allowwords></allowwords>
<forbidfloat>0</forbidfloat>
<requirelowestterms>0</requirelowestterms>
<checkanswertype>0</checkanswertype>
<mustverify>1</mustverify>
<showvalidation>1</showvalidation>
<options>minsf:3</options>
</input>
<prt>
<name>prt1</name>
<value>1.0000000</value>
<autosimplify>1</autosimplify>
<feedbackstyle>1</feedbackstyle>
<feedbackvariables>
<text></text>
</feedbackvariables>
<node>
<name>0</name>
<answertest>NumRelative</answertest>
<sans>ans1</sans>
<tans>taA</tans>
<testoptions>0.01</testoptions>
<quiet>0</quiet>
<truescoremode>=</truescoremode>
<truescore>1</truescore>
<truepenalty></truepenalty>
<truenextnode>-1</truenextnode>
<trueanswernote>prt1-1-T</trueanswernote>
<truefeedback format="html">
<text></text>
</truefeedback>
<falsescoremode>=</falsescoremode>
<falsescore>0</falsescore>
<falsepenalty></falsepenalty>
<falsenextnode>-1</falsenextnode>
<falseanswernote>prt1-1-F</falseanswernote>
<falsefeedback format="html">
<text></text>
</falsefeedback>
</node>
</prt>
<deployedseed>874478059</deployedseed>
<deployedseed>1358483538</deployedseed>
<deployedseed>372918353</deployedseed>
<deployedseed>563119235</deployedseed>
<deployedseed>252265368</deployedseed>
<qtest>
<testcase>1</testcase>
<testinput>
<name>ans1</name>
<value>taA</value>
</testinput>
<expected>
<name>prt1</name>
<expectedscore>1.0000000</expectedscore>
<expectedpenalty>0.0000000</expectedpenalty>
<expectedanswernote>prt1-1-T</expectedanswernote>
</expected>
</qtest>
</question>
</quiz>
\ No newline at end of file
...@@ -39,7 +39,7 @@ class stack_cas_castext2_textdownload extends stack_cas_castext2_block { ...@@ -39,7 +39,7 @@ class stack_cas_castext2_textdownload extends stack_cas_castext2_block {
public function compile($format, $options): ?MP_Node { public function compile($format, $options): ?MP_Node {
if (!isset($options['in main content']) || !$options['in main content']) { if (!isset($options['in main content']) || !$options['in main content']) {
throw new stack_exception('CASText2 textdownload currently only supportted in question-text / scene-text.'); throw new stack_exception('CASText2 textdownload is currently only supported in question-text / scene-text.');
} }
$format = castext2_parser_utils::RAWFORMAT; $format = castext2_parser_utils::RAWFORMAT;
......
...@@ -2029,4 +2029,21 @@ class castext_test extends qtype_stack_testcase { ...@@ -2029,4 +2029,21 @@ class castext_test extends qtype_stack_testcase {
"<span class='atom'>\(a\)</span></li><li><span class='atom'>\(b\)</span></li></ul></li></ul>", "<span class='atom'>\(a\)</span></li><li><span class='atom'>\(b\)</span></li></ul></li></ul>",
$at2->get_rendered()); $at2->get_rendered());
} }
public function test_stack_csv_formatter() {
$options = new stack_options();
$options->set_option('simplify', false);
$vars = 'S1:stack_csv_formatter([[1.24,1.34],[2.23,4.56]],[A,B]);';
$at1 = new stack_cas_keyval($vars, $options, 123);
$this->assertTrue($at1->get_valid());
$cs2 = $at1->get_session();
$at2 = castext2_evaluatable::make_from_source('{#S1#}', 'test-case');
$this->assertTrue($at2->get_valid());
$cs2->add_statement($at2);
$cs2->instantiate();
$this->assertEquals("\"A,B\n1.24,1.34\n2.23,4.56\"", $at2->get_rendered());
}
} }
...@@ -78,7 +78,7 @@ if (!(stack_user_can_view_question($question) || $USER->id === $usageuser)) { ...@@ -78,7 +78,7 @@ if (!(stack_user_can_view_question($question) || $USER->id === $usageuser)) {
\core\session\manager::write_close(); \core\session\manager::write_close();
// Make sure that the cache is good, as this is one of those places where // Make sure that the cache is good, as this is one of those places where
// the identifier for the cached item comes from outside we cannot // the identifier for the cached item comes from outside and we cannot
// cannot directly ask for it as that would allow people to force the cache // cannot directly ask for it as that would allow people to force the cache
// to be regenerated. // to be regenerated.
...@@ -106,7 +106,7 @@ $ses->add_statement($ct); ...@@ -106,7 +106,7 @@ $ses->add_statement($ct);
if (!$ses->get_valid()) { if (!$ses->get_valid()) {
header('HTTP/1.0 500 Internal Server Error'); header('HTTP/1.0 500 Internal Server Error');
header('Content-Type: text/plain;charset=UTF-8'); header('Content-Type: text/plain;charset=UTF-8');
echo 'Unknown issue related to the generation of this data'; echo 'Unknown issue related to the generation of this data.';
die(); die();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment