Forums

Search results: 163

WeBWorK Main Forum -> Library browser causes slow-down

by Lars Jensen -
Hi everyone,

It seems that working in the library browser for extended periods of time causes the library browser to slow down. Initially, as I build a set, the browser refreshes quickly as I change between libraries and add problems to a set. But after having added problems from several locations and refreshed several times, the library browser begins to slow down dramatically, and eventually becomes very slow, taking several minutes to refresh a small page.

What causes this behavior, and is there any remedy?

Thanks,
Lars.
I am using WeBWorK version 2.5 on Ubuntu 10.04.3. I have a problem that asks students to find the derivative of a straight line from a graph with units, the code is below. I used this problem last semester without issue.

The problem has two answer blanks, both of which use the same answer.
A student complained to me that his first answer was being marked incorrect. I looked at his problem and WeBWorK is reporting the correct answer to the first question as -1/30 ft/min, and to the second answer as -4 ft/min (which is correct). Since both blanks use the same answer, something is amiss.

I tried giving him a new seed, but we get the same problem, just different numbers. I looked at many of the other students in the class, and he is the only one with this problem that I can find.

CODE:

loadMacros(
"PGstandard.pl",
"PGunion.pl",
"Parser.pl",
"PGcourse.pl",
"PGgraphmacros.pl",
"parserNumberWithUnits.pl",
);

TEXT(beginproblem());
BEGIN_PROBLEM();

##############################################
# Setup
$refreshCachedImages=1;
Context("Numeric");
Context()->variables->add(t=>'Real');
#
# The function to plot
#
$m = Compute(non_zero_random(-4,4));
$b = Compute(non_zero_random(-4,4));

$munits = NumberWithUnits("$m","ft/min");

$s = Formula("$m*t+$b")->reduce;
$sgraph = Formula("$m*x+$b");

#
# Graph size
#

($tm,$tM) = (-2,2);
$extreme1 = abs($s->eval(t=>"$tm"));
$extreme2 = abs($s->eval(t=>"$tM"));
if($extreme1 > $extreme2){$sM = $extreme1;}
else {$sM = $extreme2;};
$sm=-$sM;
$size = [450,450];

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

#
# The plot defaults
#
@Goptions = (
$tm,$sm,$tM,$sM, # dimensions of graph
axes => [0,0], grid => [$tM-$tm,$sM-$sm], # number of grid lines
size => $size # pixel dimension
);

$plotdomain = "x in <$tm,$tM>";
$plotoptions = "using color:red and weight=2";

$graph = init_graph(@Goptions);
plot_functions($graph,"$sgraph for $plotdomain $plotoptions");



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

Context()->texStrings;
BEGIN_TEXT
$BBOLD Note: $EBOLD Your answers must include \{ helpLink('units') \}.
$BR
$BR
The position \(x\) of a car at time t is graphed below.
$BCENTER
\{ image( insertGraph($graph),width=>450, height=>450 ) \}
$ECENTER
If the position of the car is given in feet and time is measured in minutes then
\(x^\prime (t) = \) \{ans_rule\}
$BR
The velocity of the car is \{ans_rule\}
$BR

END_TEXT
Context()->normalStrings;

##################################################
# Answers

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

ANS($munits->cmp() );
ANS($munits->cmp() );

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

Installation -> Installing new Webwork theme

by Randy Cone -
Dear Webwork,

In the process of bringing up our new Webwork server, we're trying to create a new theme. We've installed the directory, templates, and css files in the appropriate places and with the appropriate permissions. However, the drop-down list on the course configuration page doesn't give our new theme as an option, even after refreshing the page as suggested. What should we try next?

Thanks!
Randy Cone
I have created a few macros that make customization of TeX display a bit easier.  It would be nice to simplify it more.

First -- to have equations display vectors in a particular style place this 
in your PGcourse.pl file (and place "PGcourse.pl" in the loadMacros() queueue).

addToTeXPreamble("\\newcommand{\\myVec}[1]{\\vec{#1}} ");

If you were to place this command in a single question (a .pg file) then you use single
backslashes instead of double backslashes.  You should place the command towards the beginning of the question before any equations are rendered.

This affects only image ("dvipng") mode.  It does not affect jsMath or MathJax
mode -- that will have to come later.

You can now modify this preamble command in PGcourse.pl to obtain different styles for denoting vectors.

To make sure that you can see the changes (equation images are cached!)
place   

refreshEquations(1);

in a given question or in the PGcourse.pl file while testing.  This forces equation images to be recreated every time.  

To set the style for the hardcopy for a given homework set, place the command

\newcommand{\myVec}[1]{\vec{#1}} 

in the header file used for the homework set in the section which is 
read when creating hardcopy. (Or if you use separate header files for 
screen display and for image display place it in the hardcopy header file.

There are ways to change the TexPreamble for an entire site -- 
see the WeBWorK/Constants.pm file for images TexPreamble and 
the webwork2/conf/snippets directory for the locations of the files to change the hardcopy version.

jsMath and MathJax headers are defined in the webwork2/html/ directory.

It would be nice to be able to change all of the different presentation modes simultaneously with one command -- but that is not possible yet.

-- Mike

Installation -> Config. Apache? -> Re: Config. Apache?

by Hal Sadofsky -

This is indeed something you can do with an apache configuration.

Here is how we did it on our server (the relevant files may be someplace else on your server):



1) mv /usr/local/apache2/htdocs/index.html to index.html.dist or some such thing.

2) create a new /usr/local/apache2/htdocs/index.html

which contains only the following single line:



(obviously above you replace webwork.uoregon.edu/webwork2 with whatever the URL for webwork is on your server)

-Hal

WeBWorK Problems -> epsilon delta problem

by Darwyn Cook -
Brian asked me about some epsilon/delta problems that I had written. Since I have yet to get my problems up into the NPL I thought I would include the source code here for one of them.
This problem mimics a problem from the text where the student is given epsilon and has to get the graph to exit the corners of the graphing window to find delta. Unfortunately the real trouble with this problem for my students seems to be the decimal arithmetic, not the epsilon/delta concept.

##DESCRIPTION
#
# File Created: 7/10/2008
# Last Modified: 7/10/2008
# Problem Author: Darwyn Cook
# WeBWorK Entry:
# Location: Alfred University
#
##ENDDESCRIPTION

##KEYWORDS('limits' 'epsilon' 'delta' 'rigorous')
##

## DBsubject('Calculus')
## DBchapter('Limits and Derivatives')
## DBsection('Limits Rigorously')
## Date('7/10/2008')
## Author('Darwyn Cook')
## Institution('Alfred University')
## TitleText1('Calculus: with Early Transcendentals')
## EditionText1('8')
## AuthorText1('Anton')
## Section1('2.4')
## Problem1('')


DOCUMENT(); # This should be the first executable line in the problem.
loadMacros("PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"PGgraphmacros.pl",
"MathObjects.pl");

TEXT(beginproblem());
$showPartialCorrectAnswers = 0;

TEXT($BEGIN_ONE_COLUMN);
$refreshCashedImages= 1;

Context()->strings->are(blue=>{},red=>{},black=>{},green=>{});
Context()->{format}{number} = "%.8g";
$answertolerance = 0.000003;
$functioncolor = String(black);
$epsiloncolor = String(red);
$epsilon = random(.001, .01,.0001);
$a = random(-3,3,.01);

##############################################################
# Check for student input
if (defined $inputs_ref->{'xmin'} ) {
$xmin = $inputs_ref->{'xmin'};
}
elsif (defined $in{'xmin'} ) {
$xmin = $in{'xmin'};
}
else {
$xmin = $a-1;
}
# set increment value for y
if (defined $inputs_ref->{'xmax'} ) {
$xmax = $inputs_ref->{'xmax'};
}
elsif (defined $in{'xmax'} ) {
$xmax = $in{'xmax'};
}
else {
$xmax = $a+1;
}
if (defined $inputs_ref->{'ymin'} ) {
$ymin = $inputs_ref->{'ymin'};
}
elsif (defined $in{'ymin'} ) {
$ymin = $in{'ymin'};
}
else {
$ymin = -20;
}
# set increment value for y
if (defined $inputs_ref->{'ymax'} ) {
$ymax = $inputs_ref->{'ymax'};
}
elsif (defined $in{'ymax'} ) {
$ymax = $in{'ymax'};
}
else {
$ymax = 20;
}

#####################################################
## This code allows the student to input an arithmetic
## expression, which we reduce to a number. Otherwise
## the graph object will complain in an unfriendly way.
$xmin=Real("$xmin")->reduce;
$xmax=Real("$xmax")->reduce;
$ymin=Real("$ymin")->reduce;
$ymax=Real("$ymax")->reduce;
$xmin->with(
tolType=>'absolute', tolerance=>'.0000001');
$xmax->with(
tolType=>'absolute', tolerance=>'.0000001');
$ymin->with(
tolType=>'absolute', tolerance=>'.0000001');
$ymax->with(
tolType=>'absolute', tolerance=>'.0000001');

#####################################################
## Better check the student input, they won't like the
## result if they input the coordinates backwards
if ($xmin > $xmax){
$xmin = $xmax-1;
BEGIN_TEXT
$BBOLD XMIN MUST BE LESS THEN XMAX!$EBOLD
$BR
END_TEXT
}
if ($ymin >= $ymax){
$ymin = $ymin-1;
BEGIN_TEXT
$BBOLD YMIN MUST BE LESS THEN YMAX!$EBOLD
$BR
END_TEXT
}

#####################################################
## Define the functions

$f = Formula("sin(pi*(x^2))");
$dfdx = $f->D('x');
$m = $dfdx->eval(x=>$a)->with(
tolType=>'absolute', tolerance=>$answertolerance);
while ($m == 0){
$a = random(-3,3,.01);
$m = $dfdx->eval(x=>$a);}
$y = $f->eval(x=>$a)->with(
tolType=>'absolute', tolerance=>$answertolerance);
$fplusepsilon = Formula("$y+$epsilon");
$fminusepsilon = Formula("$y-$epsilon");


######################################################
## Now we are going to use the quadratic Taylor series approximation
## to f to estimate delta. Close enough for this application.
## First we define the coefficients $a0+$a1x+$a2x^2
$dfdxdx = $dfdx->D('x');
$c = $dfdxdx->eval(x=>$a);
#$a1 = Real("$m-$a*$c");
#$a2 = Real("$a^2*$c/2");
#$delta = Real("
#(-(2*$a2*$x+$a1)+sqrt((2*$a2*$x+$a2)^2+4*$a2*$epsilon))/(2*$a2)")->with(tolType=>'absolute', #tolerance=>'.00001');
######################################################
## This would be the tangent line approximation
$delta = Real(abs($epsilon/$m))->with(
tolType=>'absolute', tolerance=>'0.000003');;

######################################################
## Generate the graphs

$size = [200,250];
$tex_size = 350;

## initialize the graph and add the functions in
$gr = init_graph($xmin,$ymin,$xmax,$ymax,axes=>[$a,$y],size=>[400,400]);
add_functions($gr,
"$f for x in <$xmin,$xmax> using color:$functioncolor and weight:2");
add_functions($gr,
"$fplusepsilon for x in <$xmin,$xmax> using color:$epsiloncolor and weight:1");
add_functions($gr,
"$fminusepsilon for x in <$xmin,$xmax> using color:$epsiloncolor and weight:1");
$gr->stamps( closed_circle($a,$y,'black') );
$in=time();
$gr->gifName($gr->gifName()."$in");

#######################################################
## The code to generate student input boxes

$len = 1;
$INPUTSPACEXMIN = M3( qq! \\rule{${len}in}{.01in}!,
qq!\begin{rawhtml}<INPUT TYPE = "TEXT" NAME="xmin"
VALUE="$xmin">\end{rawhtml}!,
qq!<INPUT TYPE = "TEXT" NAME="xmin" VALUE="$xmin">!
);
$INPUTSPACEXMAX = M3( qq! \\rule{${len}in}{.01in}!,
qq!\begin{rawhtml}<INPUT TYPE = "TEXT" NAME="xmax"
VALUE="$xmax">\end{rawhtml}!,
qq!<INPUT TYPE = "TEXT" NAME="xmax" VALUE="$xmax">!
);
$INPUTSPACEYMIN = M3( qq! \\rule{${len}in}{.01in}!,
qq!\begin{rawhtml}<INPUT TYPE = "TEXT" NAME="ymin"
VALUE="$ymin">\end{rawhtml}!,
qq!<INPUT TYPE = "TEXT" NAME="ymin" VALUE="$ymin">!
);
$INPUTSPACEYMAX = M3( qq! \\rule{${len}in}{.01in}!,
qq!\begin{rawhtml}<INPUT TYPE = "TEXT" NAME="ymax"
VALUE="$ymax">\end{rawhtml}!,
qq!<INPUT TYPE = "TEXT" NAME="ymax" VALUE="$ymax">!
);

########################################################
## The problem
Context()->texStrings;
BEGIN_TEXT
\{ image( insertGraph($gr),, width=>400, height=>400,tex_size=>250) \}
$PAR
Use the graph of f to find \(\delta\) so that \(\vert f(x) - f(a)\vert <$epsilon\) when \(\vert x-a\vert < \delta\) if \(a = $a\) and \(f(a) = $y\).
$BR
\(\delta = \) \{ans_rule(20)\}
$BR
To change the graph enter values for
$PAR
x min = $INPUTSPACEXMIN x max= $INPUTSPACEXMAX
$PAR
y min = $INPUTSPACEYMIN y max= $INPUTSPACEYMAX
$BR and then press the Submit Answer button.
$PAR
$BBOLD Note: $EBOLD \(f(a) + \epsilon\) and \(f(a)-\epsilon\) are graphed in red to help you find \(\delta\). Mathematically speaking, once you have found \(\delta\) any smaller number will also work for \(\delta\). Since that would make the problem rather easy, you could just put in a very small number, for this problem you will need to find the largest delta that will work. Your answer must be within $answertolerance of the correct answer.
END_TEXT
BEGIN_HINT
$BR
$BR
$BBOLD HINT $EBOLD
$BR
\(\epsilon\) determines the vertical size of the window, you want it at \($y-\epsilon\) and \($y+\epsilon\). The horizontal spacing you will have to guess at, how will you know when you have it right.
END_HINT
BEGIN_SOLUTION
$BR
$BR
$BBOLD SOLUTION $EBOLD
$BR
You have the correct horizontal window when the graph exits the corners of the windows.
END_SOLUTION
Context()->normalStrings;
ANS($delta->cmp);
ENDDOCUMENT(); # This should be the last executable line in the problem.
The following message has started showing up in our error_log (a student brought the problem to my attention when he had trouble logging on, and this was the error message he forwarded):

Failed to initialize course environment: Could not evaluate global environment file /opt/webwork/webwork2/conf/global.conf: Can't locate object method "get" via package "APR::Table" at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 74.

By the error_log entries (only 16 in the last 4 days -- not a lot, I know, but it would be nice to solve the problem rather than just live with it and perhaps find out later that it was a harbinger of worse to come. Also, it's the only error we're getting on the system.) it seems to have happened on login, logout, while an instructor was accessing setmaker, and just viewing problems. Redoing a request or refreshing clears the error, so the problem is still at the level of "user annoyance."

We are running RHEL 5 with RedHat's build of Apache 2.2.3. 1 GB RAM. Only serving 6 courses. perl-status shows ARP::Table is loaded.
APR::Table 0.009000 Fri Sep 19 04:30:28 2008 /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/APR/Table.pm

httpd.conf tweaks are
Timeout 300
KeepAlive On
MaxKeepAliveRequests 25
KeepAliveTimeout 5
StartServers 5
MaxSpareServers 10
MaxClients 8
MaxRequestsPerChild 100

Any ideas?