## 2017 Problem Authoring Workshop

### pop-up True-False statements + essay ### pop-up True-False statements + essay

by shirley yap -
Number of replies: 2
I'd like to
1.)create a list of true-false statements with an essay answer blank afterwards
2.)randomize the order of those TF statements

(Unrelated to the above) I'd also like to include Latex into the statement. If you see the statements below, none of them contain Latex, b/c I wasn't sure how to do it. But suppose I wanted to say " $f(x)$ is differentiable implies that $f(x) is continuous." The relevant code is below and I've also included it in homework3. The pop-up + essay part works, but the choosing one out of the list doesn't. ------------------------------------------------ #$f->Formula("f(x)")

# Create and use pop up lists
$popup = new_select_list();$popup->rf_print_q(~~&pop_up_list_print_q);

# Choices presented to students
$popup->ra_pop_up_list( [ "No answer" => "?", "True" => "True", "False" => "False", ]); # Questions and answers$popup -> qa (
"Continuous functions are differentiable.",
"False",
"Differentiable functions are continuous.",
"True",
"The sum of differentiable functions is differentiable. ",
"True",
"The product of differentiable functions is differentiable. ",
"True",
"The quotient of differentiable functions is differentiable.",
"False",
" Functions which are decreasing have a negative second derivative",
"False",
"If a function f is negative, its' derivative is negative. ",
"False",
);

# Pick a question from the list. This isn't right because $popup is now fixed # to be one specific statement from the list above. How do I choose one and #then eliminate it from the list?$popup->choose(1);

###########################
# Main text

BEGIN_PGML
Are the following statements true or false? Explain your reasoning in
the given spaces below the statements.

[@ $popup -> print_q() @]* [@ essay_box(5,90) @]* [@$popup -> print_q() @]*
[@ essay_box(5,90) @]*

END_PGML ### Re: pop-up True-False statements + essay

by Davide Cervone -
Here is a possible solution to your problem. It uses PopUp() objects instead of select lists, and uses a subroutine to create the popups and associated essay answer blanks, in PGML.
loadMacros(
"PGML.pl",
"PGessaymacros.pl",
"PGchoicemacros.pl",
"parserPopUp.pl"
);

#
#  The questions and their correct answers
#

@Q = (
["Continuous functions are differentiable.", "False"],
["Differentiable functions are continuous.", "True"],
["The sum of differentiable functions is differentiable.", "True"],
["The product of differentiable functions is differentiable.", "True"],
["The quotient of differentiable functions is differentiable.", "False"],
["Functions which are decreasing have a negative second derivative", "False"],
["If a function [:f:] is negative, its derivative is negative.", "False"],
);

#
#  The indices shuffled; we will use the first two of these as indices
#  to pick two random questions
#
@I = shuffle($#Q); # # Used to store the pop-ups for the selected questions # @P = (); # # A function for formatting the pop-ups and their essays #$n is the number of the question to show
#    ($q,$a) are the question and answer from the n-th question in the shuffled order
#    $P[$n] is the pop-up for this question
#    We return PGML code for the popup, the question, and the associated essay
#
sub TFpopup {
my $n = shift; my ($q,$a) = @{$Q[$I[$n]]};  Get the random question/answer from shuffled list
$P[$n] = PopUp(["?", "True", "False"], $a); return '[___]{$P['.$n.']} ' .$q . "  ~~n~~n".
'    [@ ANS(essay_cmp()); essay_box(5,90) @]*' . "~~n~~n";
}

BEGIN_PGML
Are the following statements true or false? Explain your reasoning in
the given spaces below the statements.

[@ TFpopup(0) @]**
[@ TFpopup(1) @]**
END_PGML

Hope that does what you have in mind. 