Difference between revisions of "AnswerOrderedList1"
Jump to navigation
Jump to search
(Switch to PGML and remove AnswerFormatHelp) |
(add historical tag and give links to newer problems.) |
||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Sequences/AnswerOrderedList.html a newer version of this problem]</p> |
||
+ | |||
<h2>Answer is an Ordered List</h2> |
<h2>Answer is an Ordered List</h2> |
||
Latest revision as of 06:43, 18 July 2023
This problem has been replaced with a newer version of this problem
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.
- PGML location in OPL: FortLewis/Authoring/Templates/Sequences/AnswerOrderedList1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( 'PGstandard.pl', 'MathObjects.pl', 'PGML.pl', 'PGcourse.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_string = join(', ',@seq); $answer_cmp = Compute("$answer_string")->cmp(ordered=>1); |
Setup:
We create an empty array
Since the answer is a MathObject List, which is by default unordered, we must specify that the answer checker use |
BEGIN_PGML 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. Sequence = [_____]{$answer_cmp} [@ helpLink('numbers') @]* END_PGML |
Main Text: |
Context()->texStrings; BEGIN_SOLUTION Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |