Forums

Search results: 133

Here's the whole problem, Davide.  I tried to implement your notation as closely as I could, still with the same results.  The empty set '{}' is still not accepted as the correct answer.

I'm using  ww_version: 2.8, pg_version: 2.8.1.

##DESCRIPTION
## Compound Inequalities
## 
##ENDDESCRIPTION
# Original Problem Author: Modified by Shafiu Jibrin 
#                 from setSets/ur_st_1_2.pg 
# Location: Northern Arizona University
## DBsubject(Set theory)
## DBchapter(Basic properties and operations)
## DBsection(Union and intersection)
## Institution(The College of Idaho)
## Author(RA Cruz)
## Level(2)
## TitleText1('Essentials of Intermediate Algebra')
## AuthorText1('Blitzer')
## EditionText1('1')
## Section1('4.1')
## Problem1('')
## KEYWORDS('inequalities')
## Date: 2007/10

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

loadMacros(
  "PGstandard.pl",
  "PGchoicemacros.pl",
  "MathObjects.pl",
#  "PGgraphmacros.pl",
#  "PGnauGraphics.pl",
#  "contextInequalitiesAllowStrings.pl",
  "answerHints.pl",
#  "CofIdaho_macros.pl"
);

TEXT(beginproblem());

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

@slice = NchooseK(12,9);
@A = ($slice[1], $slice[2], $slice[3], $slice[4]);
@B = ($slice[5], $slice[6], $slice[8]);
$AiB = "N";
@AuB = ($slice[1], $slice[2], $slice[3], $slice[4], $slice[5], $slice[6],$slice[8]);

for ($k=3; $k>0; $k-=1) {
  for ($i=0; $i<$k; $i+=1){
    if($A[$i]>$A[$k]) {
       $b = $A[$i];
       $A[$i] = $A[$k];
       $A[$k] = $b;
    }
  }
}

for ($k=2; $k>0; $k-=1) {
  for ($i=0; $i<$k; $i+=1){
    if($B[$i]>$B[$k]) {
       $b = $B[$i];
       $B[$i] = $B[$k];
       $B[$k] = $b;
    }
  }
}


#for ($k=2; $k>0; $k-=1) {
#  for ($i=0; $i<$k; $i+=1){
#    if($AiB[$i]>$AiB[$k]) {
#       $b = $AiB[$i];
#       $AiB[$i] = $AiB[$k];
#       $AiB[$k] = $b;
#    }
#  }
#}

for ($k=6; $k>0; $k-=1) {
  for ($i=0; $i<$k; $i+=1){
    if($AuB[$i]>$AuB[$k]) {
       $b = $AuB[$i];
       $AuB[$i] = $AuB[$k];
       $AuB[$k] = $b;
    }
  }
}

$LEFT_BRACE = '\{';
$RIGHT_BRACE = '\}';
 
Context("Interval");
$ans_a = Set();

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

Context()->texStrings;
BEGIN_TEXT

Let \( A= ${LEFT_BRACE} $A[0],  $A[1], $A[2], $A[3] ${RIGHT_BRACE}\) , $SPACE
\( B= ${LEFT_BRACE} $B[0],  $B[1],  $B[2] ${RIGHT_BRACE}\)
$BR
Find the following sets in list form. Separate elements with commas.  If there are no elements in the set, enter "NONE".
$PAR
a) \( A \cap B =  \) \{$ans_a->ans_rule(25) \}
$PAR
b) \( A \cup B = \) \{ans_rule(25)\} 
END_TEXT
Context()->normalStrings;
######################################
#  Answer


ANS($ans_a->cmp);

Context()->parens->replace('{' => {close => '}', type => 'Set'});

# $ans_a = String("NONE");

#ANS($ans_a->cmp->withPostFilter(AnswerHints(
#            sub {
 #              my ($correct,$student,$ans) = @_;
  #              if ($student=~ /\w/) {return $student !~ /[}{]/;}
   #             } => ["Enter your answer with set notation: { ... }", 
    #                  checkCorrect => 1, 
     #                 score => 0]
#)));

$ans_b = Set("{$AuB[0],$AuB[1],$AuB[2],$AuB[3],$AuB[4],$AuB[5],$AuB[6]}");
#Answer hints not working
ANS($ans_b->cmp->withPostFilter(AnswerHints(
            sub {
                my ($correct,$student,$ans) = @_;
                return $student !~ /[}{]/;
                } => ["Enter your answer with set notation: { ... }", 
                      checkCorrect => 1, 
                      score => 0]
)));

$showPartialCorrectAnswers = 1;

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


COMMENT('MathObject version');
ENDDOCUMENT();

WeBWorK Problems -> MultiAnswer oddity -> Re: MultiAnswer oddity

by Michael Gage -
This is not a direct reply to your post, but don't expect compoundProblems5/Scaffold and MultiAnswer to always work smoothly together.  They both change the names of answer blanks around and not always in ways that work together.  John Travis and I ran into this while working on some sample questions at Asheville.  The Scaffolding code needs some more work and possibly a new idea to work smoothly with multianswer.  So far compoundProblems5 has worked well with arrays.

WeBWorK Problems -> MultiAnswer oddity

by Peter Staab -
I've been playing with compoundProblem5 and MultiAnswer within it.  I'm getting a strange result where I enter the correct expression  in the first ans_rule and I get the following in the entered column : "-\left(\sin\!\left(4x\right)\right)\tan\!\left(4x\right)/4x"  

and the warning: Unexpected character '\'

It appears that the tex version is being sent as the input.  

Here is the relevant code (the entire problem is about 300 lines, so I'll save you some headaches): 

$top3= Compute("-sin($b*x)*tan($b*x)");
$bottom3 = Compute("$b*x");

$dtop3 = $top3->D;
$dbottom3 = $bottom3->D;

$limit5 = MultiAnswer($top3, $bottom3)->with(
  singleResult => 0,
  allowBlankAnswers => 1,
  checker => sub {
    my ( $correct, $student, $self ) = @_;
    my ($studNum,$studDen) =@{$student};
    my $studentAns = Compute("$studNum/$studDen");
    my ($correctNum,$correntDen) = @{$correct};
    my $correctAns = Compute("$correctNum/$correntDen");
    my $denomLinear =  $studDen->D()->D() == Compute(0);
    $self->setMessage(2,"The denominator must be linear") unless $denomLinear;

    my $result = $studentAns == $correctAns && $denomLinear;

    return $result;
});

if ($displayMode eq 'TeX') {
  $showLimit =
  "\[ $limit  ".$limit5->ans_rule(10).$limit5->ans_rule(10)." \]";
} else {
  $showLimit =
  ColumnTable(
  "\( \displaystyle $limit \)",
  $limit5->ans_rule(20).$BR.$HR.$limit5->ans_rule(20),
  indent => 0, separation => 10, valign => "MIDDLE"
  );
}

Context()->texStrings;
DISPLAY_SECTION(
{ name=>"5: Rewrite and apply L'Hopital's Rule Again", 
    canshow =>$scaffold->requireCorrect(7,8,9). " or $isInstructor",
    iscorrect=>$scaffold->requireCorrect(10,11,12,13), 
    section=>5
},   <<'END_SECTION'); 

You found the limit in the previous section to be

\[ $limit \frac{$top2}{$bottom2} \]

Rewrite this into the form where the bottom is a linear function and the top has trigonometric functions.  (Note: do not apply L'Hopital's Rule)

$showLimit

WeBWorK Problems -> CompoundProblem5 bug

by Peter Staab -
I'm trying to use the new version of compoundProblem (compoundProblem5.pl) and started with the documented one at http://webwork.maa.org/wiki/CompoundProblem5 and I'm running the latest version of the develop branch. 

If I walk through the problem, the 3rd section doesn't open.  Troubleshooting, it looks like at the end of the problem, it opens sections based on

$opensection = $last_correct_section + 1;
$scaffold->openSections($opensection);

and if I print out $opensection, then it equals 0 when the problem first loads, 1 after the correct answer is opened in the first sections, and remains 1 after the 2nd section is correctly solved.  
I would like to be able to have a list of zero, one or two linear equations (like:  x=2, x=4) be entered and checked.  I can get one equation to work, but when trying to use a list, I am unsuccessful.  How can this be done?  Below is the code I am using 

Thanks, 
Mary Cameron

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"answerHints.pl",
"compoundProblem.pl",
"problemRandomize.pl",   # to get more problem practice
"parserImplicitPlane.pl",    # for VA and HA linear equations
);
TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;
ProblemRandomize(when => "Correct", onlyAfterDue => 0);
Context("Numeric");
##############################  Setup

# Choose two different vertical asymptotes
@va = ();
$va[1] = random(-9,9,1);   
do {   $va[2] = random(-9,9,1);  }  until ( $va[1] != $va[2]) ; 

$denom = Formula( "x^2 - ($va[1] + $va[2]) * x + $va[1] * $va[2]"  ) -> reduce ( "(-x)-y" => 0, "(-x)+y" => 0 );
$f = Formula("1/$denom"); 

@answers = ();
################### The following WORKS -- checking just ONE linear equation:
#Context("ImplicitPlane")->variables->are(x=>"Real",y=>"Real");
#$v1 = ImplicitPlane("x=$va[1]")  ;  # vertical asymptote equation
#$answers[1] = ImplicitPlane("x=$va[1]")  ;  # vertical asymptote equation  WORKS

#$answers[1] = ImplicitPlane( $v1 )  ;              # also works (if put $v1 defined before this)

################### The following FAILS -- Want to check Two linear equation answers as a list of two linear equations
Context("ImplicitPlane")->variables->are(x=>"Real",y=>"Real");
$v1 = ImplicitPlane("x=$va[1]")  ;  # vertical asymptote equation
$v2 = ImplicitPlane("x=$va[2]")  ;  # vertical asymptote equation
$answers[1] = List( $v1, $v2  );

################### more FAILURES
#$answers[1] = List (   ImplicitPlane( $v1 ) ,  ImplicitPlane( $v2 ) );    #  FAILS Can't locate object method "blank" via package "ImplicitPlane::formula"
#$answers[1] = List (   $v1, $v2 );                                #  FAILS ... "blank"
#$answers[1] = List (   "$v1" );                                 #  also FAILS with just one... "blank"
#$answers[1] = List (   "x=$va[1]",   "x=$va[2]"   );   # FAILS ... "blank"
#$answers[1] = List (  $va[1],   $va[2] );     # correct answers are like 4, 5  rather than "x=4", and "x=5".
#$answers[1] = List (  "$va[1]",   "$va[2]" );     # same problem here -- 4,5 is correct "

$ans_eval[1] = $answers[1] ->cmp();
#################################  Text #1
Context()->texStrings;
BEGIN_TEXT
${BBOLD}Part 1 of 3:${EBOLD}
Enter the equation(s) for the vertical asymptotes of \(  f(x) = \displaystyle $f \)
$BR If there is more than one vertical asymptote, separate the equations with commas.
$BR If there are no vertical asymptotes, enter "NONE"
$BR  The equations for the vertical asymptotes of \( f(x)  \) are
\{ ans_rule(20) \}
END_TEXT
################################  Answers #1
Context()->normalStrings;
ANS( $ans_eval[1] );



ENDDOCUMENT();


I want to have students enter "P'(t)=k * P(t)".

I found this thread by two of our esteemed PREP2014 moderators: http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2816

I downloaded the file parserFunctionPrime.pl found there, put it in the templates/macros folder, and still can't get it to work.  But maybe the problem is somewhere else.  The pink screen of death says something about illegal function name P' though.  I'm trying to do implicit plane and P'(t) and I'm not really sure about either thing.  My backup option is to turn it into multiple choice so that they don't have to enter it.  

Thanks for any help!
---------------------------------------------------

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

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

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

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

$a = random(2,6,1);
$b = random(100,1000,100);
$c = Compute($a*3);

Context("Numeric");


Context()->variables->add(t =>'Real');
Context()->variables->remove("x");

$ans1 = Compute("$b*8");
$ans2 = Compute("$b*2^(t/$a)");
$ans3 = Compute("$b*2^(19/$a)");

Context("ImplicitPlane");

parser::FunctionPrime->Enable();

 Context()->variables->remove("x","y","z");
Context()->variables->add(t =>"Real", k=>"Real", C=>"Real");
parserFunction("P(t)"=>"t**2 + sin(t)");
parserFunction("P'(t)"=>"2 t +cos(t)");
  $diffeq = ImplicitPlane("P'(t) =  k * P(t) ");

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

Context()->texStrings;
BEGIN_TEXT

The following problem is an example of exponential growth/decay (in this case, growth).  All these types of functions have the general form \(y=Ce^{kt}\), where \(t \) is time, \( C\) is the initial value, \(y\) is the value of the function at any time \(t\), and \(k\) is called the growth (or decay) constant.  (Note that interest compounded continuously has the same form).  $PAR

If we use the more customary variable names for exponential growth problems, \(P(t)=P_0 e^{k t} \), then what differential equation does this function \(P(t) \) satisfy?  Your answer should include some combination of \(P(t), P'(t), k, C, t, e\) and it's an equation, so also \( = \). (You can find this in the first few pages of Section 5.1 in your textbook if you don't remember).
\{ans_rule\} \{AnswerFormatHelp("equations") \}

----------------------------------------------------------------------
# I've redacted unedited stuff from an exponential growth problem in the library, but can but it back in if you want to see it.
-----------------------------------------------------------------------

ANS($diffeq->cmp);

ANS( $ans1->cmp() );
ANS( $ans2->cmp() );
ANS( $ans3->cmp(tolType=>'absolute', tolerance=>1) );


ENDDOCUMENT();