Difference between revisions of "AnswerOrderedList1"
Jump to navigation
Jump to search
Paultpearson (talk | contribs) m |
Paultpearson (talk | contribs) |
||
Line 5: | Line 5: | ||
This PG code shows how to write a question in which the answer is an ordered list, such as a sequence of numbers. |
This PG code shows how to write a question in which the answer is an ordered list, such as a sequence of numbers. |
||
</p> |
</p> |
||
− | * Download file: [[File:AnswerOrderedList1.txt]] (change the file extension from txt to pg when you save it) |
||
+ | * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Sequences/AnswerOrderedList1.pg FortLewis/Authoring/Templates/Sequences/AnswerOrderedList.pg] |
||
− | * File location in NPL: <code>FortLewis/Authoring/Templates/Sequences/AnswerOrderedList.pg</code> |
||
<br clear="all" /> |
<br clear="all" /> |
||
Line 135: | Line 134: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_SOLUTION |
BEGIN_SOLUTION |
||
− | ${PAR}SOLUTION:${PAR} |
||
Solution explanation goes here. |
Solution explanation goes here. |
||
END_SOLUTION |
END_SOLUTION |
Revision as of 16:06, 16 June 2013
Answer is an Ordered List
This PG code shows how to write a question in which the answer is an ordered list, such as a sequence of numbers.
- File location in OPL: FortLewis/Authoring/Templates/Sequences/AnswerOrderedList.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("Numeric"); @seq = (); $seq[0] = 1; $seq[1] = 1; foreach my $i (2..6) { $seq[$i] = $seq[$i-1] + $seq[$i-2]; } $answer = join(", ",@seq); $answer = Compute("$answer"); |
Setup:
We create an empty array |
Context()->texStrings; BEGIN_TEXT If \( s_1 = $seq[0] \), \( s_2 = $seq[1] \), and \( s_n = s_{n-1} + s_{n-2} \), find the first seven terms of this sequence, including \( s_1 \) and \( s_2 \). Enter your answer as a comma separated list of numbers. $BR $BR Sequence = \{ ans_rule(40) \} \{ AnswerFormatHelp("numbers") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers=1; ANS( $answer->cmp(ordered=>1) ); |
Answer Evaluation:
Since the answer is a MathObject List, which is by default unordered, we must specify that the answer checker use |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |