## PREP 2013 Question Authoring - Archived

### changing true/false to yes/no

by Mary Shepherd -
Number of replies: 1
I used one of the templates Paul Pearson created and I wanted to change the "true/false" answers to "yes/no" answers. I got the pop-ups to change to yes/no, but when the correct answers display I see True/false. I tried to change the first part "True"=>"Yes" to "Yes"=>"Yes" and other similar changes, but this did not work. The code is copied below.

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
);

TEXT(beginproblem());

###########################
# Setup

Context("Numeric");

$den = random(2,9,1);$c = Compute("4*$den"); # Create and use pop up lists$tf = new_select_list();
$tf->rf_print_q(~~&pop_up_list_print_q); # Choices presented to students$tf->ra_pop_up_list( [
"True" => "Yes",
"False" => "No",
]);

Context()->texStrings;
$tf -> qa ( "You need to divide $$c$$ cookies among $$den$$ people.", "False", "You need to find $$\frac{1}{den}$$ of $$c$$ ounces.", "False", "You need to find how many $$\frac{1}{den}$$ doses there are in $$c$$ ounces.", "True", "A sale advertises $$\frac{1}{den}$$ off a $$c$$ dollar purchase.", "False", "You purchased $$c$$ yards of material. Each kit requires $$\frac{1}{den}$$ yard of material. You need to determine how many kits you can make.", "True", "You have $$c$$ flowers and you need to determine how many bouquets of $$den$$ flowers you can make.", "False", "If you do not pay your bill in by the due date you will be charged a fee of $$\frac{1}{den}$$ of the bill which totals $$c$$ dollars.", "False", ); Context()->normalStrings; # How many questions to use$tf->choose(5);

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

Context()->texStrings;
BEGIN_TEXT
Which of the following describes a situation where division by $$\frac{1}{den)$$ would be needed?
$BR \{$tf -> print_q() \}
END_TEXT
Context()->normalStrings;

############################

$showPartialCorrectAnswers = 0; # # Incremental grader # install_problem_grader(~~&custom_problem_grader_fluid);$ENV{'grader_numright'} = [2,4,6];
$ENV{'grader_scores'} = [0.3,0.6,1];$ENV{'grader_message'} = "You can earn " .
"30% partial credit for 2 - 3 correct answers, and " .
"60% partial credit for 4 - 5 correct answers.";

#
#

ANS( str_cmp( $tf->ra_correct_ans() ) ); ############################ # Solution Context()->texStrings; BEGIN_SOLUTION${PAR}SOLUTION:${PAR} You could put an explanation here. END_SOLUTION Context()->normalStrings; COMMENT("MathObject version."); ENDDOCUMENT(); In reply to Mary Shepherd ### Re: changing true/false to yes/no by Paul Pearson - Hi Mary, You will need to change all occurrences of "True" to "Yes" and "False" to "No". You likely had changed them in the$tf->ra_pop_up_list() but not in the $tf -> qa() part. Also, since you used$tf->choose(5); instead of $tf->choose(6); as was originally written, you will want to change the custom grader at the bottom of the problem:$ENV{'grader_numright'} = [2,4,5]; # changed [2,4,6] to [2,4,5] since there are 5 problems total
$ENV{'grader_scores'} = [0.3,0.6,1];$ENV{'grader_message'} = "You can earn " .
"30% partial credit for 2 - 3 correct answers, and " .
"60% partial credit for 4 correct answers."; # changed '4 - 5' to '4'

This custom grader will give 0% for 0-1 correct answers, 30% for 2-3 correct answers, and 60% for 4 correct answers, and 100% for 5 correct answers. If you forget to change [2,4,6] to [2,4,5], then the maximum possible score is 60%.

I also caught a mismatched parentheses error: { ) needed to be changed to { }.

If you want to be able to see which lines in your code are different from my code, I would recommend using a utility such as WinMerge, which is free and easily found using google. WinMerge will allow you to open two files at the same time and view them side-by-side. Also, scrolling will be in sync for both files and lines that are different will be highlighted.

I've provided a working example below.

Have a good evening!

Paul Pearson

#####################################

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
);

TEXT(beginproblem());

###########################
# Setup

Context("Numeric");

$den = random(2,9,1);$c = Compute("4*$den"); # Create and use pop up lists$tf = new_select_list();
$tf->rf_print_q(~~&pop_up_list_print_q); # Choices presented to students$tf->ra_pop_up_list( [
"Yes" => "Yes",
"No" => "No",
]);

Context()->texStrings;
$tf -> qa ( "You need to divide $$c$$ cookies among $$den$$ people.", "No", "You need to find $$\frac{1}{den}$$ of $$c$$ ounces.", "No", "You need to find how many $$\frac{1}{den}$$ doses there are in $$c$$ ounces.", "Yes", "A sale advertises $$\frac{1}{den}$$ off a $$c$$ dollar purchase.", "No", "You purchased $$c$$ yards of material. Each kit requires $$\frac{1}{den}$$ yard of material. You need to determine how many kits you can make.", "Yes", "You have $$c$$ flowers and you need to determine how many bouquets of $$den$$ flowers you can make.", "No", "If you do not pay your bill in by the due date you will be charged a fee of $$\frac{1}{den}$$ of the bill which totals $$c$$ dollars.", "No", ); Context()->normalStrings; # How many questions to use$tf->choose(5);

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

Context()->texStrings;
BEGIN_TEXT
Which of the following describes a situation where division by $$\frac{1}{den}$$ would be needed?
$BR \{$tf -> print_q() \}
END_TEXT
Context()->normalStrings;

############################

$showPartialCorrectAnswers = 0; # # Incremental grader # install_problem_grader(~~&custom_problem_grader_fluid);$ENV{'grader_numright'} = [2,4,5];
$ENV{'grader_scores'} = [0.3,0.6,1];$ENV{'grader_message'} = "You can earn " .
"30% partial credit for 2 - 3 correct answers, and " .
"60% partial credit for 4 correct answers.";

#
ANS( str_cmp( $tf->ra_correct_ans() ) ); ############################ # Solution Context()->texStrings; BEGIN_SOLUTION${PAR}SOLUTION:\${PAR}