|
The true false basic example
(for more advanced information on select lists, see Select.pm)
To obtain this problem
WARNINGS µ¦å{h
{viewSource(setMAAtutorial/truefalseexample.pg)}
<!--
Enter this code
1 DOCUMENT(); # This should be the first executable line in the problem.
2 loadMacros(PG.pl,
3 PGbasicmacros.pl,
4 PGchoicemacros.pl,
5 PGanswermacros.pl,
6 PGgraphmacros.pl,
7 );
8
9
10 TEXT(beginproblem()); # standard preamble to each problem.
11 # Since this is a true questions, we do not usually wish to tell students which
12 # parts of the matching question have been answered correctly and which are
13 # incorrect. That is too easy. To accomplish this we set the following flag to zero.
14 $showPartialCorrectAnswers = 0;
15
16 # Make a new select list
17 $tf = new_select_list();
18 # $tf now "contains" the select list object.
19 # See matchinglistexample.pg for details
20
21 # Insert some questions and whether or not they are true.
22 $tf -> qa (
23 "All continuous functions are differentiable.", # each entry has to end with a comma
24 "F",
25 "All differentiable functions are continuous.",
26 "T",
27 "All polynomials are differentiable.",
28 "T",
29 "All functions with positive derivatives are increasing.",
30 "T"
31 ); # remember every statement has to end with a semi-colon.
32
33 # Choose two of the question and answer pairs at random.
34 $tf ->choose(2);
35 # Now print the text using $ml->print_q
36
37 BEGIN_TEXT
38 $PAR
39
40 Enter T or F depending on whether the statement is true or false.
41 (You must enter T or F -- True and False will not work.)$BR
42 \{ $tf-> print_q \}
43 $PAR
44 END_TEXT
45
46 # Enter the correct answers to be checked against the answers to the students.
47 ANS( str_cmp( $tf->ra_correct_ans ) ) ;
48
49 # The ra_... means that the output of this function is an array reference -- a gadget that looks like
50 # [T, F, T] or whatever the list of T's and F's represents the correct answers.
51 # That's it.
52 ENDDOCUMENT(); # This should be the last executable line in the problem.
-->
Comments:
- This is similar to the matching list problem, but this time there is no separate list of matching answers to choose from. You can also use this template for problems which require short answers (e.g. "decreasing", "increasing", "constant") rather than "T" and "F" or "True" and "False". See also the pop-up list example for another way to pose this kind of question.
- First we create the object -- this time called a "select list".
$tf = new_select_list(); (line 17)
- Next we enter a list of questions, followed by their answers (T or F) (lines 22 - 31)
- Choose two questions at random from the list.
$tf ->choose(2); (line 34)
- Print the questions
{ $tf-> print_q } (line 42)
- Register the correct answers
ANS( str_cmp( $tf->ra_correct_ans ) ) ; (line 47)
|