Forums

Search results: 133

Hi Angel,

The "bridge2" connection between moodle and webwork on a question by question basis is still somewhat incomplete so I'm not surprised that there are some features that aren't working The connection between moodle and webwork at the set level (bridge1) has now been used in production in a limited number of sites and is in pretty good shape (although it could still use more documentation) but bridge2 is still in beta testing at best.

My suggestion is that you try to implement the multipart aspect on the Moodle side (this is part of the reason for bridge2 exisiting -- is to take advantage of some of the features in the question type that are not mathematics specific so reproducing them in WeBWorK is extra work). This means that the moodle side would store the seed and just ask successive questions of WeBWorK using that same seed.

Let me know whether you think this would work. The bridge2 interface clearly needs work (and for that matter the Compound/Sequential problem capabilities in WeBWorK also needs work) and I'm interested in working on it, but it is a long term not short term project.

Hope this helps.

Take care,

Mike

Hi all,

I'm using Webwork as a question type within moodle.

I need to do a problem divided in different parts. The students can't read the next part if they have not answered the current one. All the parts are using some random numbers so is needed to keep those numbers in memory.

Reading the webwork documentation I have found out how to do it: using CompoundProblem. I've used it in the main webwork framework and it's working properly but when I use it with the moodle integration I can only see the first part, the submit button doesn't show the next part.

Somebody knows where is the problem or how to fix it in order to use it with Moodle?

Thanks a lot
Here's what webwork tells me

$5253.12 $5253.12 incorrect
$5798.47 incorrect

Yes, you're right it marks $5253.12 as incorrect, but it's also telling me this is the correct answer (which I believed). Is this what you see when you try this, or am I missing something?

## http://wwrk.maa.org/moodle/mod/forum/discuss.php?d=459
## seed 3515

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

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"contextCurrency.pl",
#"source.pl", # allows code to be displayed on certain sites.
#"PGcourse.pl", # Customization file for the course
);

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;

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

TEXT(&beginproblem);
Context("Currency");
$showPartialCorrectAnswers = 1;

@periods = ("annually","semiannually","quarterly","monthly","weekly","daily");
@ms = (1,2,4,12,52,365);

$mm = random(1,4);
$period = $periods[$mm];
$m = $ms[$mm];

$rate = random(5,10);
$r = $rate/100;

$t1 = random(1,6);
$t2 = $t1 + random(1,6);

$p = 5000*random(1,10);
$P = Currency($p);

$a1 = $p*(1+$r/$m)**($m*$t1);
$a2 = $p*(1+$r/$m)**($m*$t2);

$A1 = Currency($a1);
$A2 = Currency($a2);
BEGIN_TEXT;
If $P is invested at $rate$PERCENT compounded $period, what is the amount after
$HR
(A) $t1 years?
$PAR
Answer: \{ans_rule(8)\}
$PAR
(B) $t2 years?
$PAR
Answer: \{ans_rule(8)\}
$PAR
(Use dollar signs for monetary values)
END_TEXT
ANS($A1->cmp);
ANS($A2->cmp);
ENDDOCUMENT();
I gave the following problem on a homework set, and a student with seed 3515 gave the correct answer to part (A), but it was marked incorrect, despite displaying as the correct answer. As far as I can tell, she was the only student to have this problem. Can anyone help with this?

Nathan

TEXT(&beginproblem);
Context("Currency");
$showPartialCorrectAnswers = 1;

@periods = ("annually","semiannually","quarterly","monthly","weekly","daily");
@ms = (1,2,4,12,52,365);

$mm = random(1,4);
$period = $periods[$mm];
$m = $ms[$mm];

$rate = random(5,10);
$r = $rate/100;

$t1 = random(1,6);
$t2 = $t1 + random(1,6);

$p = 5000*random(1,10);
$P = Currency($p);

$a1 = $p*(1+$r/$m)**($m*$t1);
$a2 = $p*(1+$r/$m)**($m*$t2);

$A1 = Currency($a1);
$A2 = Currency($a2);
BEGIN_TEXT;
If $P is invested at $rate$PERCENT compounded $period, what is the amount after
$HR
(A) $t1 years?
$PAR
Answer: \{ans_rule(8)\}
$PAR
(B) $t2 years?
$PAR
Answer: \{ans_rule(8)\}
$PAR
(Use dollar signs for monetary values)
END_TEXT
ANS($A1->cmp);
ANS($A2->cmp);
ENDDOCUMENT();
I'm not talking about a macro, but an actual MathObject for reactions. Pattern matching for something like this is too fragile; you need the power of an actual formula parser, which is what MathObjects provides. The thing that is needed is the definitions required to make the parser understand chemical formulas, and that means a MathObject Context with the right definitions and support code.

I have put such a context together, and have added it to the pg/macros directory. You can get it from the HEAD version of the CVS repository. There are comments at the top of the file that explain how it works, which I also provide below.

I'm not a chemist, so I don't know if this is exactly what you need, but it looks like it should handle the problems that you illustrated in your initial question. Let me know if it needs adjusting.

Here is the documentation from the file:


contextReaction.pl - Implements a MathObject class for checmical reactions.

This file implements a Context in which checmical reactions can be specified and compared. Reactions can be composed of sums of integer multiples of elements (possibly with subscripts), separated by a right arrow (indicated by "-->"). Helpful error messages are given when a reaction is not of the correct form. Sums of compounds can be given in any order, but the elements within a compound must be in the order given by the correct answer; e.g., if the correct answer specifies CO_2, then O_2C would be marked incorrect.

To use the context include

    loadMacros("contextReaction.pl");
    Context("Reaction");
at the top of your PG file, then create Formula() objects for your reactions. For example:
    $R = Formula("4P + 5O_2 --> 2P_2O_5");
Reactions know how to create their own TeX versions (via $R->TeX), and know how to check student answers (via $R->cmp), just like any other MathObject.

The Reaction Context also allows you to create parts of reactions. E.g., you could create

    $products = Formula("4CO_2 + 6H_2O");
which you could use in a problem as follows:
    loadMacros("contextReaction.pl");
    Context("Reaction");

    $reactants = Formula("2C_2H_6 + 7O_2");
    $products  = Formula("4CO_2 + 6H_2O");

    Context()->texStrings;
    BEGIN_TEXT
    \($reactants \longrightarrow\) \{ans_rule(30)\}.
    END_TEXT
    Context()->normalStrings;

    ANS($products->cmp);

Note that sums and products are not simplified in any way, so that Formula("O + O") and Formula("2O") and Formula("O_2") are all different and unequal in this context.

All the elements of the periodic table are available within the Reaction Context. If you need additional terms, like "Heat" for example, you can add them as variables:

    Context()->variables->add(Heat => $context::Reaction::CONSTANT);
Then you can make formulas that include Heat as a term. These "constants" are not allowed to have coefficients or subscripts, and can not be combined with compounds except by addition. If you want a term that can be combined in those ways, use $context::Reaction::ELEMENT instead.


Hope that does what you need.

Davide

WeBWorK Problems -> Setting up a chemistry problem

by Eric Stroyan -
Sorry in advance for the length of this.
I am trying to set up a problem in which students are to predict the products of a chemical reaction.
The reactants and products are currently stored in a macro file with the following format
%reactions=(
1=>{equation=>"N_{2} + H_{2} \longrightarrow NH_{3}",
class=>"combination",
components=>[
{type=>"reactant", compound=>"N_{2}", coef=>1 },
{type=>"reactant", compound=>"H_{2}", coef=>3 },
{type=>"product", compound=>"NH_{3}", coef=>2 },]},
2=>{equation=>"P + O_{2} \longrightarrow P_{2}O_{5}",
class=>"combination",
components=>[
{type=>"reactant", compound=>"P", coef=>4 },
{type=>"reactant", compound=>"O_{2}", coef=>5 },
{type=>"product", compound=>"P_{2}O_{5}", coef=>2 },]},
3=>{equation=>"C_{2}H_{6} + O_{2} \longrightarrow CO_{2} + H_{2}O",
class=>"combustion",
components=>[
{type=>"reactant", compound=>"C_{2}H_{6}", coef=>2 },
{type=>"reactant", compound=>"O_{2}", coef=>7 },
{type=>"product", compound=>"CO_{2}", coef=>4 },
{type=>"product", compound=>"H_{2}O", coef=>6 },]},
4=>{equation=>"KClO_{3} \longrightarrow KCl + O_{2}",
class=>"decomposition",
components=>[
{type=>"reactant", compound=>"KClO_{3}", coef=>2 },
{type=>"product", compound=>"KCl", coef=>2 },
{type=>"product", compound=>"O_{2}", coef=>3 },]},

The problem that I have working asks the student to predict one of the two products (code attached). I would like to develop a problem with two (or more, as the reaction warrants) answer blanks that students would enter the products in LaTeX format. I have set one up that will check answers, the problem is the products must be in a specific order. I would like to be able to let students enter the products in any order. I'm pretty much shot as to how to do this.
Any suggestions/help would be appreciated.

WeBWorK Problems -> contextFraction.pl -> Re: contextFraction.pl

by Davide Cervone -
There are several problems here. First, the requireProperFractions flag requires the strictFractions flag, so it is really only effective in the LimitedFraction context, not in the plain Fraction context. Also, if you were to get this flag to work Fraction context (by setting strictFraction), then you would not be able to enter the improper fractions that you do in the Compute() calls below.

Second, the LimitedFraction context that you set at the bottom has no effect. This is because MathObjects retain the context in which they were created, so since $ans1, $ans2, and $ans3 where created in the Fraction context, they continue to be in that context even after you change the current context to LimitedFraction.

The proper way to do this is to create them in LimitedFraction context initially (without the requireReducedFractions flag set, so the correct answer can be entered as an improper fraction) and then set the requireReducedFractions flag after they are created.

Here is the code:


    #DESCRIPTION
    ##Type of
    #ENDDESCRIPTION

    DOCUMENT();
    loadMacros(
    "PGstandard.pl",
    #"PGchoicemacros.pl",
    #"PGgraphmacros.pl",
    "MathObjects.pl",
    # "compoundProblem.pl",
    #"contextCurrency.pl",
    #"contextInequalities.pl",
    #"unionTables.pl",
    # "unionLists.pl",
    #"unionMacros.pl",
    #"contextLeadingZero.pl",
    "contextFraction.pl",
    #"answerHints.pl",
    #"problemPanic.pl",
    );
    #for currency use Context("Currency") then Currency($A);
    #Then, in the text use $DOLLAR $a
    TEXT(beginproblem());
    $showPartialCorrectAnswers = 1;

    Context("LimitedFraction");

    $a1=random (3,7,2);
    $b1=random (4,8,4);
    $x=Compute("$a1/$b1");
    $a2=random (4,8,2);
    $b2=random (5,7,2);
    $y=Compute("$a2/$b2");
    $a3=random (3,9,3);
    $b3=random (5,10,5);
    $z=Compute("$a3/$b3");
    $ans1=$x-$y;
    $ans2=$x+2*$y;
    $ans3=$x+$y+$z;
    #warn "a1=$a1, b1=$b1, x=$x, a2=$a2, b2=$b2, y=$y, a3=$a3, b3=$b3, z=$z, a1=$ans1";

    Context()->flags->set(requireProperFractions => 1);


    BEGIN_TEXT
    Evaluate each expression if \(x =\frac{$a1}{$b1}\), \(y=\frac{$a2}{$b2}\), and
    \(z=\frac{$a3}{$b3}\).$BR
    Your answer should be a reduced fraction or a mixed number with the $BR
    faction part reduced (a mixed number can be entered in the form 2 3/4 to
    mean \(2\frac{3}{4}\)).$PAR
    $PAR
    a) \(x-y=\) \{ans_rule(6)\}
    $PAR
    b) \(x+2y=\) \{ans_rule(6)\}
    $PAR
    c) \(x+y+z=\) \{ans_rule(6)\}
    END_TEXT

    ANS($ans1->cmp);
    ANS($ans2->cmp);
    ANS($ans3->cmp);

    ENDDOCUMENT();

Hope that clears things up.

Davide

WeBWorK Problems -> contextFraction.pl -> Re: contextFraction.pl

by Kenneth Appel -
I can refine the question above a bit due to further experimentation. I have modified the context so that the
answers shown are mixed numbers, but entries that are not
mixed numbers are accepted, for example

Entered Answer Preview Correct Result
9/20 incorrect
2.85 2.85 2 17/20 correct
3 17/20 3 {\textstyle\frac{17}{20}} 3 17/20 correct
1 of the questions remains unanswered.

Evaluate each expression if x =\frac{5}{4},\ y=\frac{4}{5},\ and\ z=\frac{9}{5}
Your answer should be a reduced fraction or a mixed number with the
faction part reduced (A mixed number can be entered in the form 2 3/4 to mean 2\frac{3}{4} ).

a) x-y=\ \

b) x+2y=\ \

c) x+y+z=\ \

Note that the 77/20 is converted to 3 17/20 but not rejected for improper form and 2.85 is accepted even
though it is a decimal.

Here is the code

DESCRIPTION
##Type of
#ENDDESCRIPTION

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
#"PGgraphmacros.pl",
"MathObjects.pl",
# "compoundProblem.pl",
#"contextCurrency.pl",
#"contextInequalities.pl",
#"unionTables.pl",
# "unionLists.pl",
#"unionMacros.pl",
#"contextLeadingZero.pl",
"contextFraction.pl",
"answerHints.pl",
"problemPanic.pl",

#"PGauxiliaryFunctions.pl", #for lcm, gcd,etc
);
#for currency use Context("Currency") then Currency($A);
#Then, in the text use $DOLLAR $a
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

Context("Fraction")->flags->set(allowProperFractions =>1,
requireProperFractions =>1, showProperFractions=>1 ,
reduceConstants => 0, #keep fractions and operations between them
);
$a1=random (3,7,2);
$b1=random (4,8,4);
$x=Compute("$a1/$b1");
$a2=random (4,8,2);
$b2=random (5,7,2);
$y=Compute("$a2/$b2");
$a3=random (3,9,3);
$b3=random (5,10,5);
$z=Compute("$a3/$b3");
$ans1=$x-$y;
$ans2=$x+2*$y;
$ans3=$x+$y+$z;
#warn "a1=$a1, b1=$b1, x=$x, a2=$a2, b2=$b2, y=$y, a3=$a3, b3=$b3, z=$z, a1=$ans1";


BEGIN_TEXT
Evaluate each expression if \( x =\frac{$a1}{$b1},\ y=\frac{$a2}{$b2},\ and\
z=\frac{$a3}{$b3}\)

$BR Your answer should be a reduced fraction or a mixed number with the $BR
faction part reduced (A mixed number can be entered in the form 2 3/4 to mean
\(2\frac{3}{4}\) ).$PAR
$PAR
a) \(x-y=\ \ \) \{ans_rule(6)\}
$PAR
b) \(x+2y=\ \ \) \{ans_rule(6)\}
$PAR
c) \(x+y+z=\ \ \) \{ans_rule(6)\}
END_TEXT
Context("LimitedFraction")->flags->set(allowProperFractions =>1,
requireProperFractions =>1, showProperFractions =>1,
reduceConstants => 0, #keep fractions and operations between them
);
ANS($ans1->cmp);
ANS($ans2->cmp);
ANS($ans3->cmp);


ENDDOCUMENT()

WeBWorK Problems -> path to context?

by Kenneth Appel -
In our WeBWorK installation,
contextIntegerFunctions.pl is in directory
/web/opt/pg/macros along with most other contexts.

This makes the error below hard to interpret.
WeBWorK Error
WeBWorK has encountered a software error while attempting to process this problem. It is likely that there is an error in the problem itself. If you are a student, report this error message to your professor to have it corrected. If you are a professor, please consult the error output below for more information.

Error messages

Can't locate macro file |contextIntegerFunctionspl| via path: |.|, |/opt/webwork2/courses/testprobs/templates/macros|, |/opt/pg/macros|, |/web/opt/webwork2/libraries/union_problib/macros|, |/web/opt/pg/doc/MathObjects/macros| at line 310 of (eval 1036) Died within main::loadMacros called at line 6 of [TMPL]/probs/prob1.pg

Error details

Problem1
ERROR caught by Translator while processing problem file:probs/prob1.pg
****************
Can't locate macro file |contextIntegerFunctionspl| via path: |.|, |/opt/webwork2/courses/testprobs/templates/macros|, |/opt/pg/macros|, |/web/opt/webwork2/libraries/union_problib/macros|, |/web/opt/pg/doc/MathObjects/macros| at line 310 of (eval 1036)
Died within main::loadMacros called at line 6 of [TMPL]/probs/prob1.pg

****************

------Input Read
1 #DESCRIPTION
2 ##Type of
3 #ENDDESCRIPTION
4
5 DOCUMENT();
6 loadMacros(
7 "PGstandard.pl",
8 "PGchoicemacros.pl",
9 #"PGgraphmacros.pl",
10 "MathObjects.pl",
11 # "compoundProblem.pl",
12 #"contextCurrency.pl",
13 #"contextInequalities.pl",
14 #"unionTables.pl",
15 # "unionLists.pl",
16 #"unionMacros.pl",
17 #"contextLeadingZero.pl",
18 #"contextFraction.pl",
19 "answerHints.pl",
20 "problemPanic.pl",
21 contextIntegerFunctions.pl, #for C(n,r), P(n,r)
22 #PGauxiliaryFunctions.pl, #for lcm, gcd,etc
23 );
24 #for currency use Context("Currency") then Currency($A);
25 #Then, in the text use $DOLLAR $a
26 TEXT(beginproblem());
27 $showPartialCorrectAnswers = 1;
28 Context("Numeric");
29 $a=random(3,5,1);
30 $ans=C(10,$a);
31
32
33 BEGIN_TEXT
34 How many ways can $a CD's be chosen from a case of 10 CDs?
35 \{ans_rule(5)\}
36 SPAR
37 \{Panic::Button(label => " Ask for a Hint", penalty => .00)\}
38 END_TEXT
39 ANS(Real($ans)->cmp);
40
41 ENDDOCUMENT()
42
43
44 END_TEXT
45 if ($panicked) {
46 BEGIN_TEXT
47 Hint:
48 END_TEXT
49 };
50 BEGIN_TEXT
51 $PAR

-----

Request information