WeBWorKdocs

sq_webwork:


Home
Current UR
courses
Visitor
page
Intro to
WeBWorK
WeBWorK 2
Twiki
WW
Community
Grant Support
& awards
Discussion
group
Problem
library
Write/modify
problems
Create &
manage course
Tutorial on
running a course
HowTos
FAQ
WeBWorK2
FAQ
Software
Download
How to
Install WW server
Feedback
Site Map
Change
preferences
Change
password





Prev | Next | tutorial

This page is no longer being maintained. The new URL for this content is http://webwork.maa.org/wiki/SampleProblem2

The true false basic example

(for more advanced information on select lists, see Select.pm) To obtain this problem

(1 pt) rochesterLibrary/setMAAtutorial/truefalseexample.pg

True False Example

Enter T or F depending on whether the statement is true or false. (You must enter T or F -- True and False will not work.)

 1. All differentiable strictly increasing functions have non-negative derivatives at every point
 2. All polynomials are differentiable.
 3. All compact sets are closed
 4. All closed sets are compact


WARNINGS
µ¦å{h­
{viewSource(setMAAtutorial/truefalseexample.pg)} <!--
(1 pt)
Enter T or F depending on whether the statement is true or false. (You must enter T or F -- True and False will not work.)

1. All continuous functions are differentiable.
2. All polynomials are differentiable.


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:

  1. 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.
  2. First we create the object -- this time called a "select list". $tf = new_select_list(); (line 17)
  3. Next we enter a list of questions, followed by their answers (T or F) (lines 22 - 31)
  4. Choose two questions at random from the list. $tf ->choose(2); (line 34)
  5. Print the questions { $tf-> print_q } (line 42)
  6. Register the correct answers ANS( str_cmp( $tf->ra_correct_ans ) ) ; (line 47)


Prev | Next | tutorial

Last update: Tuesday, March 4, 2008 at 12:33:28 AM.
This site maintained using Manila and Frontier software.