Skip to content

Commit 0a8e16d

Browse files
authored
Merge pull request #1060 from gajennings/main
Fix bug 4772, update with Math Objects, PGML
2 parents e0f4d06 + 8b26ee0 commit 0a8e16d

File tree

1 file changed

+55
-114
lines changed
  • OpenProblemLibrary/ASU-topics/setIntroduction_to_WeBWorK

1 file changed

+55
-114
lines changed
Lines changed: 55 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## DESCRIPTION
32
## Introduction to WeBWorK
43
## ENDDESCRIPTION
@@ -17,173 +16,115 @@
1716
## AuthorText1('')
1817
## Section1('')
1918
## Problem1('')
19+
## MO(1)
2020

2121

2222
DOCUMENT(); # This should be the first executable line in the problem.
2323

2424
loadMacros(
2525
"PGstandard.pl",
26-
"PGchoicemacros.pl",
26+
"MathObjects.pl",
27+
"PGML.pl",
2728
"PGcourse.pl"
2829
);
2930

3031
TEXT(beginproblem());
3132
$showPartialCorrectAnswers = 1;
3233

33-
BEGIN_TEXT
34-
This part demonstrates WeBWorK problems where you enter letters
35-
or words. We start with a True/False question.
36-
37-
$PAR
38-
39-
Enter a $BITALIC T $EITALIC or an $BITALIC F $EITALIC in
40-
each answer space below to indicate whether the corresponding statement is true or
41-
false.
42-
43-
$PAR
34+
## First we set up our variables.
4435

45-
END_TEXT
36+
Context("Numeric");
37+
Context()->strings->add(T=>{},F=>{},"undefined"=>{});
4638

47-
## First we set up our variables.
4839
$a = random(1,5,1);
4940
$b = random(6,10,1);
5041
$c = random(-10,-1,1);
5142
$d = random(-10,-1,1);
5243
$e = random(1,10,1);
5344
$f = random(5,10,1);
5445

55-
$questStr1 = EV2(" \( -$a \lt -$b \) ");
56-
$ansStr1 = "F";
57-
$questStr2 = EV2(" \( $c \leq $c \) ");
58-
$ansStr2 = "T";
59-
$questStr3 = EV2(" \( $d \lt $d \) ");
60-
$ansStr3 = "F";
61-
$questStr4 = EV2(" \( \pi \geq \frac{22}{7} \) ") ;
62-
$ansStr4 = "F";
63-
$questStr5 = EV2(" \( \sqrt {$e+3} \geq \sqrt $e + \sqrt 3 \) ");
64-
$ansStr5 = "F";
65-
$questStr6 = EV2(" \( \sqrt {$f-3} \geq \sqrt $f - \sqrt 3 \) ");
66-
$ansStr6 = "T";
67-
$questStr7 = EV2(" \( \sqrt {$f*$e} \geq \sqrt $e \sqrt $f \) ");
68-
$ansStr7 = "T";
46+
# The first five question and answer pairs are randomly selected
47+
# from this list
48+
49+
@quesAns = (
50+
["$a \lt -$b", String("F")],
51+
["$c \leq $c", String("T")],
52+
["$d \lt $d", String("F")],
53+
["\pi \geq \frac{22}{7}", String("F")],
54+
["\sqrt {$e+3} \geq \sqrt $e + \sqrt 3", String("F")],
55+
["\sqrt {$f-3} \geq \sqrt $f - \sqrt 3", String("T")],
56+
["\sqrt {$f*$e} \geq \sqrt $e \sqrt $f", String("T")]
57+
);
58+
59+
# randomly select five from the seven above
6960

70-
@questions =( $questStr1,$questStr2,$questStr3,$questStr4,$questStr5,$questStr6,$questStr7);
71-
@answers =( $ansStr1,$ansStr2,$ansStr3,$ansStr4,$ansStr5,$ansStr6,$ansStr7);
61+
@choices = (0..6);
62+
for ($i=0; $i<5; $i++){
63+
$j=random($i,6,1);
64+
($choices[$i],$choices[$j])=($choices[$j],$choices[$i]);
65+
}
66+
@quesAns = @quesAns[@choices[0..4]];
7267

73-
## Now choose randomly 5 questions out of the 7 question strings above.
68+
## Begin the text of the question
69+
## Insert the first five question/answer pairs into the text and generate the
70+
## others within the text.
7471

75-
@slice = NchooseK(scalar(@questions),5);
72+
BEGIN_PGML
73+
This part demonstrates WeBWorK problems where you enter letters
74+
or words. We start with a True/False question.
75+
76+
Enter a _T_ or an _F_ in
77+
each answer space below to indicate whether the corresponding statement is true or false.
7678

77-
## Next we output the 5 chosen questions. #
78-
TEXT( &match_questions_list(@questions[@slice]) );
79+
[___]{$quesAns[0][1]} *1.* [`[$quesAns[0][0]]`]
7980

80-
ANS(str_cmp([ @answers[@slice] ] ));
81+
[___]{$quesAns[1][1]} *2.* [`[$quesAns[1][0]]`]
8182

82-
TEXT(<<EOT);
83+
[___]{$quesAns[2][1]} *3.* [`[$quesAns[2][0]]`]
8384

84-
$PAR
85+
[___]{$quesAns[3][1]} *4.* [`[$quesAns[3][0]]`]
8586

87+
[___]{$quesAns[4][1]} *5.* [`[$quesAns[4][0]]`]
88+
8689
Notice that if one of your answers is wrong then, in this problem,
8790
WeBWorK will tell you which parts are wrong and which parts are right.
8891
This is the behavior for most problems, but for true/false or multiple
8992
choice questions WeBWorK will usually only tell you whether or not all
9093
the answers are correct. It won't tell you which ones are wrong. The
9194
idea is to encourage you to think rather than to just try guessing.
9295

93-
$PAR Typically all of the answers must be correct before you get
96+
Typically all of the answers must be correct before you get
9497
credit for a problem like this.
95-
EOT
9698

97-
BEGIN_TEXT
98-
99-
$PAR
100-
$HR
101-
$PAR
99+
-----
102100

103101
Now we have a question where the answer involves a word. When a word is
104102
a possible answer, we will usually emphasize your options by using
105-
$BITALIC italics $EITALIC. Where would this happen?
106-
107-
$PAR
103+
_italics_. Where would this happen?
108104

109-
Well, we might have a situation where we have division by zero. Of course, we all know that this is $BITALIC undefined $EITALIC.
105+
Well, we might have a situation where we have division by zero. Of course, we all know that this is _undefined_.
110106

111-
$PAR
107+
We might also try to take the square root (or even root) of a negative number. This is also _undefined_ if we expect to get a real number as an answer.
112108

113-
We might also try to take the square root (or even root) of a negative number. This is also $BITALIC undefined $EITALIC if we expect to get a real number as an answer.
109+
-----
114110

115-
$PAR
116-
$HR
117-
$PAR
118-
119-
Evaluate the following expressions. Exact real number answers are required for each problem. When one of them does not evaluate to a real number, type $BITALIC undefined $EITALIC in its answer box. Also, if you try to enter the calculation into WeBWorK for an $BITALIC undefined $EITALIC process, WeBWorK will NOT give you credit.
120-
121-
$PAR
111+
Evaluate the following expressions. Exact real number answers are required for each problem. When one of them does not evaluate to a real number, type _undefined_ in its answer box. Also, if you try to enter the calculation into WeBWorK for an _undefined_ process, WeBWorK will NOT give you credit.
122112

123113
Pay attention to how placing parentheses, shifting the location of a negative sign, or changing an operation can change the result of the calculations.
124114

125-
END_TEXT
126-
127-
BEGIN_TEXT
128-
$PAR
129-
130-
$BBOLD 6. $EBOLD $SPACE (2/3-3) = \{ ans_rule(20) \}
131-
132-
END_TEXT
133-
134-
ANS(str_cmp("-7/3"));
135-
136-
BEGIN_TEXT
137-
$PAR
138-
139-
$BBOLD 7. $EBOLD $SPACE 2/(3-3) = \{ ans_rule(20) \}
140-
141-
END_TEXT
142-
143-
ANS(str_cmp("undefined"));
144-
145-
BEGIN_TEXT
146-
$PAR
147-
148-
$BBOLD 8. $EBOLD $SPACE (4-4)/(3*3) = \{ ans_rule(20) \}
149-
150-
END_TEXT
151-
152-
ANS(str_cmp("0"));
153-
154-
BEGIN_TEXT
155-
$PAR
156-
157-
$BBOLD 9. $EBOLD $SPACE (4-4)/(3-3) = \{ ans_rule(20) \}
158-
159-
END_TEXT
160-
161-
ANS(str_cmp("undefined"));
162-
163-
BEGIN_TEXT
164-
165-
$PAR
166-
167-
$BBOLD 10. $EBOLD $SPACE \( -\sqrt{25}\) = \{ ans_rule(20) \}
168-
169-
$PAR
170-
171-
END_TEXT
172-
173-
$ans = "-sqrt(25)" ;
174-
ANS(num_cmp($ans));
115+
*6.* [`(2/3-3)`] = [__________]{Compute("-7/3")}
175116

176-
BEGIN_TEXT
117+
*7.* [`2/(3-3) `] = [__________]{String("undefined")}
177118

178-
$PAR
119+
*8.* [`(4-4)/(3*3) `] = [__________]{Compute(0)}
179120

180-
$BBOLD 11. $EBOLD $SPACE \( \sqrt{-25}\) = \{ ans_rule(20) \}
121+
*9.* [`(4-4)/(3-3) `] = [__________]{String("undefined")}
181122

182-
$PAR
123+
*10.* [` -\sqrt{25} `] = [__________]{Compute(-5)}
183124

184-
END_TEXT
125+
*11.* [`\sqrt{-25} `] = [__________]{String("undefined")}
126+
END_PGML
185127

186-
ANS(str_cmp("undefined"));
187128

188129

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

0 commit comments

Comments
 (0)