Forum archive 2000-2006

Michael Gage - Pop-up list example

Michael Gage - Pop-up list example

by Arnold Pizer -
Number of replies: 0
inactiveTopicPop-up list example topic started 5/8/2000; 8:58:07 PM
last post 5/8/2000; 8:58:07 PM
userMichael Gage - Pop-up list example  blueArrow
5/8/2000; 8:58:07 PM (reads: 3206, responses: 0)

(1 pt) rochesterLibrary/setMAAtutorial/popuplistexample.pg

True False Pop-up Example

Indicate whether each statement is true or false.

  ? True False  1. All differentiable strictly increasing functions have non-negative derivatives at every point

  ? True False  2. All polynomials are differentiable.

  ? True False  3. All compact sets are closed

  ? True False  4. All closed sets are compact

 

 

 


WARNINGS
µ¦å{h­
DOCUMENT();        # This should be the first executable line in the problem.

loadMacros("PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
);

TEXT(beginproblem(), $BR,$BBOLD, "True False Pop-up Example", $EBOLD, $BR,$BR);
$showPartialCorrectAnswers = 0;

# Make a new select list
$tf = new_select_list();
# $tf now "contains" the select list object.

# change the printing mechanism of the object to
# use pop-up list instead of an answer rule.
$tf->rf_print_q(~~&pop_up_list_print_q);

# What should the pop-up list contain, and what string should it
# submit for an answer when selected?
# These are specified in the statment below.
# To enter T as an answer choose the list element "True"
# To enter F as an answer choose the list element "False"
# The first choice is a blank to make the students do SOMETHING!!!
$tf -> ra_pop_up_list( [ No_answer => "  ?", T => "True", F => "False"] );
# Note how the list is constructed [ answer => list element text, answer => list element text ]

# Insert some questions and their answers.

$tf -> qa ( # each entry has to end with a comma
"All continuous functions are differentiable.",
"F",
"All differentiable functions are continuous.",
"T",
"All polynomials are differentiable.",
"T",
"All functions with positive derivatives are increasing.",
"T",
"All compact sets are closed",
"T",
"All closed sets are compact",
"F",
"All increasing functions have positive deriviatives",
"F",
"All differentiable strictly increasing functions have non-negative derivatives
at every point",
"T",
);

# Choose two of the question and answer pairs at random.
$tf ->choose(4); # Using choose(3) would choose all three
# questions, but the order of the questions
# and answers would be scrambled.

# Now print the text using $ml->print_q for the questions.
BEGIN_TEXT
$PAR
Indicate whether each statement is true or false. $BR
\{ $tf-> print_q \}
$PAR
END_TEXT
# Enter the correct answers to be checked against the answers to the students.
ANS(str_cmp( $tf->ra_correct_ans ) ) ;

ENDDOCUMENT(); # This should be the last executable line in the problem.


 


Comments:

This problem is just a demo -- it doesn't actually work if you push the submit answer button. (You can test a {linkWebworkProblem("tutorialCourse", "setFirstSteps","5","live")} version of this problem.)
  1. This is nearly identical to the true-false problem, but this time the answers are selected from a list.
  2. First we create the object -- this time called a "pop-up select list". $tf = new_pop_up_select_list(); (line 16)
  3. Next we enter a list of questions, followed by their answers (T or F) (lines 20 - 29)
  4. Choose two questions at random from the list. $tf ->choose(2); (line 32)
  5. Print the questions { $tf-> print_q } (line 40)
  6. Register the correct answers ANS( str_cmp( $tf->ra_correct_ans ) ) ; ( line 45 )

 

<| Post or View Comments |>