## WeBWorK Problems

### Problem Error message upon saving a library problem to a local Drive.

by tim Payer -
Number of replies: 9
Hello,

I just saved an open Library problem to a local Drive in my webwork course.
I got an error statement without making any changes except for the filename.

The original file path was:
Library/Union/setDervGraphs/nsc2s10p3.pg
The new name I gave to this file was:

Payer/M105_HW_10/Overlayed_fprimes.pg

But in the error statement the reply stated that I named the file:

[TMPL]/Payer/M105_HW_10/derivative-text.pg
But I did not! What would cause this error?

Thanks, tim
        Problem6
ERROR caught by Translator while processing problem file:Payer/M105_HW_10/Overlayed_fprimes.pg
****************
ERRORS from evaluating PG file:  /usr/sbin/apache2: read_whole_file subroutine: Can't read file [TMPL]/Payer/M105_HW_10/derivative-text.pg at [PG]/lib/WeBWorK/PG/IO.pm line 120
Died within WeBWorK::PG::IO::read_whole_file called at line 114 of [PG]/lib/WeBWorK/PG/IO.pm
from within WeBWorK::PG::IO::read_whole_problem_file called at line 27 of [TMPL]/Library/macros/Union/unionInclude.pl
from within main::includePGfile called at line 78 of (eval 5364)

1		## DESCRIPTION
2		## Calculus
3		## ENDDESCRIPTION
4
5		## Tagged by tda2d
6
7		## DBsubject(Calculus - single variable)
8		## DBchapter(Applications of differentiation)
9		## DBsection(Summary of curve sketching)
10		## Date(9/29/08)
11		## Institution(Union College)
12		## MLT(SCS_graphs_match)
14		## Level(3)
15		## KEYWORDS('derivatives' 'graph')
16		## Library/Union/setDervGraphs/nsc2s10p3
17
18		DOCUMENT();        # This should be the first executable line in the problem.
19
21		  "PGstandard.pl",
22		  "PGunion.pl",            # Union College utilities
23		  "MathObjects.pl",
24		  "unionInclude.pl",       # The text for this question is called with includePGfile("derivative-text.pg"
25		  "PGchoicemacros.pl",
26		  "PGgraphmacros.pl",
27		  "PGcourse.pl",           # Customization file for the course
28		);
29
30		TEXT(beginproblem());
31
32		###################################
33		# Setup
34
35		$a=random(0, 6.3, .1); 36$b=random(.7, .9, .1);
37
38		$dom = 4; 39 @slice = NchooseK(3,3); 40 41 @colors = ("blue", "red", "green"); 42 @sc = @colors[@slice]; #scrambled colors 43 @sa = ('A','B','C')[@slice]; 44 45 # define the functions and their derivatives. 46 # FEQ (Format EQuations) cleans up the writing of the functions (see FEQ in PGbasicmacros) 47 # Otherwise we would need to worry about the signs of$a, $b and so forth. 48 49$f = FEQ("sin($a+$b*cos(x)) for x in <-$dom,$dom> using color:$sc[0] and weight:2"); 50$fp = FEQ("cos($a+$b*cos(x))*(-$b)*sin(x) for x in <-$dom,$dom> using color=$sc[1] and weight:2");
51		$fpp = FEQ("-sin($a+$b*cos(x))*$b*$b*sin(x)*sin(x)+ cos($a+$b*cos(x))*(-$b)*cos(x) for x in <-$dom,$dom> using color=$sc[2] and weight=2"); 52 53$graph = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8],'size'=>[300,300]);
54
55		($fRef,$fpRef,$fppRef) = plot_functions($graph,
56		               $f,$fp,$fpp 57 ); 58 59 # create labels 60 61$label_point=-1;
62		$label_f = new Label ($label_point,&{$fRef->rule}($label_point),$sa[0],"$sc[0]",'left')        ;
63		        # NOTE: $fRef->rule is a reference to the subroutine which calculates the 64 # function. It was defined in the output of plot_functions. It is used here 65 # to calculate the y value of the label corresponding to the function, 66 # and below to find the y values for the labels corresponding to the 67 # first and second derivatives. 68 69$label_fp = new Label ( $label_point+.5,&{$fpRef->rule}($label_point+.5),$sa[1],"$sc[1]",'left') ; 70$label_fpp = new Label ( $label_point+1,&{$fppRef->rule}($label_point+1),$sa[2],"$sc[2]",'left'); 71 72 # insert the labels into the graph 73$graph->lb($label_f,$label_fp,$label_fpp); 74 75 ################################### 76 # Main text 77 78 includePGfile("derivative-text.pg"); 79 80 ################################### 81 # Answers 82 83$showPartialCorrectAnswers = 0;
84		ANS(str_cmp( [ @sa ] ) );
85
86		###################################
87
88
89		;
90		ENDDOCUMENT();

-----

### Re: Problem Error message upon saving a library problem to a local Drive.

by Michael Gage -
Not sure what happened.  Can you replicate the error?  Do you have another problem in homework set whose path ends in
derivative-text.pg?

### Re: Problem Error message upon saving a library problem to a local Drive.

by tim Payer -
Yes I can replicate the same error over and over.
And no I do not have another Homework set that ends in derivative-text.pg

At least not a problem that I have saved or created.
I never use hyphens in the file path, I just use underscores.

Here is a screen capture of the file path saved

### Re: Problem Error message upon saving a library problem to a local Drive.

by Davide Cervone -
Danny Glin has correctly identified the problem and given you the solution below (an hour before your response here), so you should have seen that before writing this one. If you do what he suggests, you should be able to resolve the problem.

### Re: Problem Error message upon saving a library problem to a local Drive.

by tim Payer -
Hi Davide,

I did read Danny Glin's response and I did responded in kind (over an hour ago) that I could not find such a file named derivative-text.pg

I will redouble my efforts and see if a more thorough search will turn up the file...

I will respond back shortly...

Thanks

### Re: Problem Error message upon saving a library problem to a local Drive.

by Davide Cervone -
I did read Danny Glin's response and I did responded in kind (over an hour ago)

It must have been a private response, as there is no reply in this forum. My apologies. But there was no indication here that you had done so, and only a reply that continued to pursue directions that were not related to the problem.

As you found, the file is not in you course directory (the is the source of the problem). From Danny's original message, the indication is that it is in the same directory as the original problem file that you edited. So it would be in the Library/Union/setDervGraphs directory along the original problem, which is where you eventually found it. There is really no need to look anywhere else.

### Re: Problem Error message upon saving a library problem to a local Drive.

by Danny Glin -
I would guess that the file got saved with the name you gave.  The error isn't in the saving, it's in the displaying of the new question.

The question calls the file derivative-text.pg using the code:
78		includePGfile("derivative-text.pg");


Since no path is given, it looks for the file in the same directory as the question itself.  Since you saved the new question in a different directory, it can't find
derivative-text.pg there.

The fix should be to use the file manager to copy the file derivative-text.pg into the directory Payer/M105_HW_10.

### Re: Problem Error message upon saving a library problem to a local Drive.

by tim Payer -
OKAY I think I have it,

Here is the deal and the solution to the problem.

1.)  First Thanks, but There is NO File in our file manager named "derivative-text.pg". It does not exist at this location. A thorough search has been made and is has been confirmed.

2.) Keep in mind that we do not have administrative privileges, perhaps that is what Danny was assuming as part of the solution in using the file manager?

3.)  The main text of the problem sites only this file "derivative-text.pg"
If we want to save this homework problem to our local directory and perhaps add a few words in a general solution for the student, The problem needs to have this file.

4.)  We can save the homework problem to a local directory with this name:

Payer/M105_HW_10/Overlayed_primes.pg

If when editing the HW problem we include the entire file path including a few ../../ to bring the path out of this local directory so that file can be connected to the template directory. So we change the reference of:

"derivative-text.pg"

in the problem to that of:

"../../Library/Union/setDervGraphs/derivative-text.pg"

This will permit a clean save without the error statement.

Thanks to fellow teacher Tim Lauck for pulling out this Solution.

### Re: Problem Error message upon saving a library problem to a local Drive.

by Danny Glin -
Sorry, I forgot that the File Manager doesn't let you navigate to the Library directory, which makes it impossible to copy that file using the File Manager.

Tim's solution is one of two possibilities.  The other alternative is to download a copy of the missing file (derivative-text.pg) from github, and then upload it to the same directory as your saved problem.

There are pros and cons to each.  Using the relative path solution is nice because it doesn't lead to multiple copies of the file floating around.  It is a little fragile, though, as the number of ../ needed at the front depends on how many subdirectories deep your new question is saved.

If you upload a new copy of derivative-text.pg in your directory, it would allow you to edit that file for your questions if you so desire, but it means having to put this file in any directory where it is called.

In any case, it's good to see that you were able to get it working.

### Re: Problem Error message upon saving a library problem to a local Drive.

by Davide Cervone -
I forgot that the File Manager doesn't let you navigate to the Library directory

Actually, it can allow that, because you can tell the FileManager what symbolic links it is allowed to follow. If you add

$webworkDirs{valid_symlinks} = [$problemLibrary{root}];

to your course.conf file, that will tell the File Manager that it is allowed to follow the symbolic link into the OPL library directory.