Forums

Search results: 133

Hi Bruce,

I'm not totally clear on what you want, but I think you should be able to modify the code below to get what you want. You may also want to look into two of the ways to write MultiPart questions at

http://webwork.maa.org/wiki/ProvingTrigIdentities1

http://webwork.maa.org/wiki/ProvingTrigIdentities2
http://webwork.maa.org/viewvc/system/trunk/pg/macros/compoundProblem.pl?revision=6387&view=markup

Best Regards,

Paul

##### begin PG code ########

##################
# Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserMultiAnswer.pl",
"unionTables.pl",
);

TEXT(beginproblem());

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

Context("Numeric");

$a = 2;
$b = 4;
$c = 3;
$d = 9;

$multians = MultiAnswer($a,$b,$c,$d)->with(
singleResult => 0,
allowBlankAnswers => 1,
checker => sub {
my ( $correct, $student, $self ) = @_;
my ( $stu11, $stu12, $stu21, $stu22 ) = @{$student};
my ( $cor11, $cor12, $cor21, $cor22 ) = @{$correct};

if ( (($cor11==$stu11 && $cor12==$stu12) && ($cor21==$stu21 && $cor22==$stu22)) ||
(($cor21==$stu11 && $cor22==$stu12) && ($cor11==$stu21 && $cor12==$stu22)) )
{
return [1,1,1,1];

} elsif ( (($cor11==$stu11 && $cor12==$stu12) || ($cor21==$stu11 && $cor22==$stu12)) ) {

$self->setMessage(3,"Your second answer is incorrect because...");
return [1,1,0,0];

} elsif ( (($cor11==$stu21 && $cor12==$stu22) || ($cor21==$stu21 && $cor22==$stu22)) ) {

$self->setMessage(1,"Your first answer is incorrect because...");
return [0,0,1,1];

} else {
return [0,0,0,0];
}
}
);


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

Context()->texStrings;
BEGIN_TEXT
Enter the points on the parabola \( y = x^2 \)
with x-coordinates 2 and 3.
\{
BeginTable().
AlignedRow(["\( \big( \)", $multians->ans_rule(10), ",", $multians->ans_rule(10), "\( \big) \)"], separation=>2).
TableSpace(5,25).
AlignedRow(["\( \big( \)", $multians->ans_rule(10), ",", $multians->ans_rule(10), "\( \big) \)"], separation=>2).
EndTable();
\}
END_TEXT
Context()->normalStrings;

#########################
# Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $multians->cmp() );

ENDDOCUMENT();


##### end PG code ########
Hal,
At WPI we've been using WeBWorK for freshman calculus placement for
several years. The number of students is much smaller - only about
900 per year, but we have implemented some of the features you
are interested in. Below I've responded to your five technical issues.

1, 2. Enrollment of students and assignment.
When a freshman officially enrolls, they get a computer account username
and password. This information is used to automatically enroll the
student in the placement test course and make assignments. This
is done by directly writing information to the WW mysql database. The
programming is in C, and was not done by me but by one of our outstanding computer support people.

3. Reporting results to the student.
The last problem in the placement test has two parts and uses
Davide Cervone's compoundProblem package. Answering the first
part of the problem sets a value in the WW database that says
the student is done. The student can then go on to the second part
of the problem, which contains a link to an external web site. If the
student clicks on the link, external programming is triggered that
collects information from the WW database, generates a recommendation,
and saves information to an external (to WW) database. It also sets
a field in the WW database that indicates the student has been processed.
The recommendation appears on the screen and is also e-mailed to the student.

If a student chooses not to view the recommendation immediately, there
is a chron job that runs early every morning to process students who
are done with the exam but chose not to see the recommendation
immediately. This generates the recommendation e-mail and writes
the information to the external database.

4. Reports to registrar.
Students, faculty, and academic advising staff can use the web site to
view the recommendation for a particular student or generate summary
reports. More complicated reports can be generated by accessing the
mysql database where the placement info is stored.

5. Retiring students
I have a model placement test course that I use to generate the
placement test course each year. After the end of a placement
cycle, the current course is deactivated, meaning that no more
students are added to that course. Before the next cycle begins, I
create a new placement course.

In the external data base, there is a different table for each cycle.


I'm not sure how much of our experience can be translated to your
very different situation, but it does indicate that at least part of
what you are interested in is possible.

Regards,
Bill Farr
Worcester Polytechnic Institute
Hi all,
Before starting typing code I would like to ask you where I can find the documentation regarding the tables of the database and how the 'answer button' works in webwork. Knowing these documents maybe I could figure out why it is not working with moodle and find a better solution to my problem.

Thanks a lot,
Angel
Mike, Angel, Paul,
I would appreciate being informed of everything that is being done with bridge 2. We, at University of New Hampshire, are building an adaptive WeBWorK system for middle school. Initially, we had been working with Matt Leventi to use Moodle to provide parts of the adaptive component that are not available in WeBWorK itself. When
Matt left we decided to make sure that we built adequate
problem libraries so that when bridge 2 began to move again we would be ready to take full advantage of it. Now, it seems that you are making it move and we bless you for that and want to do all we can to cooperate as well as take advantage of your progress.
Ken Appel
I believe you are correct. I know that Matt Leventi who wrote "bridge2" implemented a lot of caching for speed. I will be attending the annual joint math meetings this next week but in about two weeks, after I have the semester's classes started, I'll have some time to look more closely at this.

I'm glad you are interested in working on it.

--Mike
Hi Mike,

I think moodle doesn't refresh the perl code once it has shown it (that's why in compound problems it always shows the first part), I've tested an example to see if the 'score' changes when you submit the correct answer and it's always printing score 0.

Here the example:

$a1 = 10;


BEGIN_TEXT
Write $a1
$BR $BR \{ans_rule(10) \}
$BR
END_TEXT

$ans_eval1 = num_cmp($a1);
$score = $ans_eval1->evaluate()->{score};
BEGIN_TEXT
$score
END_TEXT

ANS($ans_eval1);


I attached the screenshot once I have submitted the correct answer.

Next week I will try the solution about the page break and let you know about it.

Thanks to all,

Angel
Attachment screenshot14.png
Hi Paul,

About the compound problem I have clicked submit button several times (with the checkbox selected) but nothing happens.

Thanks for your information about 'conditional questions'. I've tried the example but it doesn't work. It seems moodle doesn't like the 'NAMED_ANS' or 'NAMED_ANS_RULE' fields.

I've written a simple example, but it is always showing the answer as incorrect.

Thanks

DOCUMENT();
loadMacros(
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl"
);
TEXT(beginproblem(), $BR,$BBOLD, "Conditional questions example", $EBOLD, $BR,$BR);
$showPartialCorrectAnswers = 1;

$a1 = 10;


BEGIN_TEXT
Write $a1
$BR $BR \{NAMED_ANS_RULE('first_answer',10) \}
$BR
END_TEXT

$ans_eval1 = num_cmp($a1);
NAMED_ANS(first_answer => $ans_eval1);


ENDDOCUMENT();
That sounds like a good idea for now. If it works well we can bake it into the moodle/webwork code so that it is easier to set up. I'm working on a rewrite of the basic underpinnings of webwork (originally written more than 10 years ago) which will take a while to finish -- but it should allow us to customize an output mode specifically for moodle. This should make the bridge2 more robust.

The current version of bridge2 was written under the constraint that nothing was changed on the webwork side so some compromises had to be made. By making some additions to the webwork side I think we can make this connection much stronger.

That sounds like a good idea for now. If it works well we can bake it into the moodle/webwork code so that it is easier to set up. I'm working on a rewrite of the basic underpinnings of webwork (originally written more than 10 years ago) which will take a while to finish -- but it should allow us to customize an output mode specifically for moodle. This should make the bridge2 more robust.

The current version of bridge2 was written under the constraint that nothing was changed on the webwork side so some compromises had to be made. By making some additions to the webwork side I think we can make this connection much stronger.

Dear Angel,

The issue probably is the WebWork and Moodle link. However, I'll point out one obvious caveat of compound problems and offer an alternative suggestion (conditional questions).

First the obvious caveat: For some reason, in order to advance from one part to the next in a webwork compound problem you need to submit the correct answer twice. The first time you submit it and get it correct, a new checkbox will appear near the bottom of the page that says "Go on to next part". Select that checkbox and click submit again.

Second, as an alternative to compound problems, you may also want to look into conditional questions. The following example of a conditional question comes from

/Library/Rochester/setMAAtutorial/conditionalquestionexample.pg



##DESCRIPTION
##KEYWORDS('sample')
## Tagged by jjh2b

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('MAA Tutorial')
## Date('8/30/07')
## Author('')
## Institution('')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')

DOCUMENT();
loadMacros(
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl"
);
TEXT(beginproblem(), $BR,$BBOLD, "Conditional questions example", $EBOLD, $BR,$BR);
$showPartialCorrectAnswers = 1;

$a1 = random(3,25,1);
$b1 = random(2,27,1);
$x1 = random(-11,11,1);
$a2 = $a1+5;

BEGIN_TEXT
If \( f(x) = $a1 x + $b1 \), find \( f'( $x1 ) \).
$BR $BR \{NAMED_ANS_RULE('first_answer',10) \}
$BR
END_TEXT



$ans_eval1 = num_cmp($a1);
NAMED_ANS(first_answer => $ans_eval1);

# Using named answers allows for more control. Any unique label can be
# used for an answer.
# (see http://webwork.math.rochester.edu/docs/docs/pglanguage/pgreference/managinganswers.html
# for more details on answer evaluator formats and on naming answers
# so that you can refer to them later. Look also at the pod documentation in
# PG.pl and PGbasicmacros.pl which you can also reach at
# http://webwork.math.rochester.edu/docs/techdescription/pglanguage/index.html)

# Check to see that the first answer was answered correctly. If it was then we
# will ask further questions.
$first_Answer = $inputs_ref->{first_answer}; # We need to know what the answer
# was named.
$rh_ans_hash = $ans_eval1->evaluate($first_Answer);

# warn pretty_print($rh_ans_hash); # this is useful technique for finding errors.
# When uncommented it prints out the contents of
# the ans_hash for debugging

# The output of each answer evaluator consists of a single %ans_hash with (at
# least) these entries:
# $ans_hash{score} -- a number between 0 and 1
# $ans_hash{correct_ans} -- The correct answer, as supplied by the instructor
# $ans_hash{student_ans} -- This is the student's answer
# $ans_hash{ans_message} -- Any error message, or hint provided by
# the answer evaluator.
# $ans_hash{type} -- A string indicating the type of answer evaluator.
# -- Some examples:
# 'number_with_units'
# 'function'
# 'frac_number'
# 'arith_number'
# For more details see
# http://webwork.math.rochester.edu/docs/docs/pglanguage/pgreference/answerhashdataype.html

# If they get the first answer right, then we'll ask a second part to the
# question ...
if (1 == $rh_ans_hash->{score} ) {

# WATCH OUT!!: BEGIN_TEXT and END_TEXT have to be on lines by
# themselves and left justified!!! This means you can't indent
# this section as you might want to. The placement of BEGIN_TEXT
# and END_TEXT is one of the very few formatting requirements in
# the PG language.

BEGIN_TEXT
$PAR Right! Now
try the second part of the problem: $PAR $HR
If \( f(x) = $a2 x + \{$b1+5\} \), find \( f'( x) \).
$BR $BR \{ NAMED_ANS_RULE('SecondAnSwEr',10) \}
$BR
END_TEXT

$ans_eval2 = num_cmp($a2);

NAMED_ANS(SecondAnSwEr => $ans_eval2);

}
ENDDOCUMENT();