Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d82eed1
Adjust error message in Value::Matrix.
mgage Nov 13, 2016
ec0bd10
Add macros for manipulating tableaus (extends matrix operations) in t…
mgage Nov 13, 2016
fdb43b4
Add ability to put labels on RHS when displaying matrices (side_label…
mgage Nov 13, 2016
214b39b
Fix spelling
mgage Dec 2, 2016
6891302
Fix linebreak_at_commas routine so that it runs properly in tableau.p…
mgage Jan 3, 2017
ca23487
Include quickMatrixEntry files
mgage Jan 3, 2017
ca93fcc
Add tableau test files to t/ directory
mgage Jan 3, 2017
4d23b16
Add embed test files to t/ .
mgage Jan 3, 2017
a05bab9
Fix mysterious bug caused by suddenly forcing @_ into scalar context …
mgage Jan 6, 2017
bf3a8b8
Prevent extraneous (and possibly confusing) warning message.
mgage Sep 10, 2017
3edba9a
Add tableau.pl
mgage Sep 20, 2017
8ce477e
Fixed error in defining row and column slices.
mgage Sep 24, 2017
ac11f7c
Add code to IO.pm to handle HTTP/2 and "success" : true bug ( true …
mgage Sep 25, 2017
39d8e8f
House cleaning the unit test directory
mgage Sep 25, 2017
e30a17a
update Matrix_entry_button to accept matrix
mgage Oct 5, 2017
4468cdb
update call to Fraction
mgage Oct 6, 2017
df65620
remove redundant use of "my"
mgage Oct 6, 2017
0af31a0
add _init() functions to quickmatrixEntry and tableau so that they a…
mgage Oct 6, 2017
d1e9b82
Allow entries of the form [[2,4],[2,3]]
mgage Oct 6, 2017
9ebf53e
Changes to pg test files.
mgage Oct 8, 2017
113eeef
Enhance context permutation
andrew-gardener Dec 11, 2017
ab6bd28
Add context Integer
andrew-gardener Jan 25, 2018
ca76ac4
Add context Congruence
andrew-gardener Jan 25, 2018
03a9608
Allow strings created by Compute() to have their case sensistivity pr…
dpvc Oct 31, 2018
e41a98c
Don't try to convert MathObjects to complex numbers
dpvc Oct 31, 2018
94207d8
Don't inherit non-inheritable properties when doing a union reduction.
dpvc Dec 3, 2018
a3e5271
replace hosted2 by demo in urls
mgage Jan 8, 2019
bb4472e
Forgot to comment out one line
mgage Jan 8, 2019
b07b55b
Remove typecheck for isParser when checking for Value::Matrix.
mgage Jan 8, 2019
1ac284a
Pull updated tableau.pl from fall17mth208/templates/macro/tableau.pl
mgage Jan 8, 2019
24a5474
Found more updates to tableau in other stray locations.
mgage Jan 9, 2019
2ce2153
Adjust error message in Value::Matrix.
mgage Nov 13, 2016
978d10d
Add macros for manipulating tableaus (extends matrix operations) in t…
mgage Nov 13, 2016
f0a6223
Add ability to put labels on RHS when displaying matrices (side_label…
mgage Nov 13, 2016
b6aaf5e
Fix spelling
mgage Dec 2, 2016
adc3263
Fix linebreak_at_commas routine so that it runs properly in tableau.p…
mgage Jan 3, 2017
9a14b29
Include quickMatrixEntry files
mgage Jan 3, 2017
38e1a6a
Add tableau test files to t/ directory
mgage Jan 3, 2017
67ad695
Add embed test files to t/ .
mgage Jan 3, 2017
f56631b
Fix mysterious bug caused by suddenly forcing @_ into scalar context …
mgage Jan 6, 2017
96052a2
Prevent extraneous (and possibly confusing) warning message.
mgage Sep 10, 2017
4defd89
Add tableau.pl
mgage Sep 20, 2017
04cfcaa
Fixed error in defining row and column slices.
mgage Sep 24, 2017
89f7004
Add code to IO.pm to handle HTTP/2 and "success" : true bug ( true …
mgage Sep 25, 2017
6aab0b6
House cleaning the unit test directory
mgage Sep 25, 2017
ceacb7a
update Matrix_entry_button to accept matrix
mgage Oct 5, 2017
c613a27
update call to Fraction
mgage Oct 6, 2017
43ade6e
remove redundant use of "my"
mgage Oct 6, 2017
c710d26
add _init() functions to quickmatrixEntry and tableau so that they a…
mgage Oct 6, 2017
f0c0376
Allow entries of the form [[2,4],[2,3]]
mgage Oct 6, 2017
b45c4ef
Changes to pg test files.
mgage Oct 8, 2017
390e5b8
Enhance context permutation
andrew-gardener Dec 11, 2017
843e3c6
Add context Integer
andrew-gardener Jan 25, 2018
48c6a37
Add context Congruence
andrew-gardener Jan 25, 2018
cef9021
Allow strings created by Compute() to have their case sensistivity pr…
dpvc Oct 31, 2018
258b0f3
Don't try to convert MathObjects to complex numbers
dpvc Oct 31, 2018
baaaf16
Don't inherit non-inheritable properties when doing a union reduction.
dpvc Dec 3, 2018
cfcc4c9
replace hosted2 by demo in urls
mgage Jan 8, 2019
ec03f0d
Forgot to comment out one line
mgage Jan 8, 2019
e6da9dd
Remove typecheck for isParser when checking for Value::Matrix.
mgage Jan 8, 2019
fe74169
Pull updated tableau.pl from fall17mth208/templates/macro/tableau.pl
mgage Jan 8, 2019
e02d17e
Found more updates to tableau in other stray locations.
mgage Jan 9, 2019
5f5f3f3
Update the VectorField package with cosmetic changes.
mgage Feb 24, 2019
174399f
Remove duplicate definition of sub make{}
mgage Feb 24, 2019
af0befa
Merge branch 'devel_candidate_01_27_no_multilingual_changes' of https…
mgage Feb 24, 2019
a7ccc18
Merge branch 'develop' into devel_candidate_01_27_no_multilingual_cha…
mgage Mar 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Value/Matrix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sub numberMatrix { #internal
my @M = (); my $isFormula = 0;
foreach my $x (@_) {
$x = Value::makeValue($x,context=>$context);
Value::Error("Matrix row entries must be numbers") unless _isNumber($x);
Value::Error("Matrix row entries must be numbers: $x ") unless _isNumber($x);
push(@M,$x); $isFormula = 1 if Value::isFormula($x);
}
return $self->formula([@M]) if $isFormula;
Expand Down Expand Up @@ -249,7 +249,7 @@ sub isRow {
}

#
# See if the matrix is an Indenity matrix
# See if the matrix is an Identity matrix
#
sub isOne {
my $self = shift;
Expand Down
33 changes: 14 additions & 19 deletions lib/VectorField.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Carp;
use GD;
use WWPlot;
use Fun;
$fn = new Fun( rule_reference);
$fn = new Fun( rule_reference , graph_reference);
$fn = new Fun ( x_rule_ref, y_rule_ref );
$fn = new Fun ( x_rule_ref, y_rule_ref, graph_ref );
use VectorField;
$vf = new VectorField( dy_rule_ref);
$vf = new VectorField( dy_rule_ref , graph_reference);
$vf = new VectorField( x_rule_ref, y_rule_ref );
$vf = new VectorField( x_rule_ref, y_rule_ref, graph_ref );

=head1 DESCRIPTION

Expand All @@ -25,42 +25,37 @@ The following functions are provided:

=over 4

=item $fn = new VectorField( dy_rule_ref);
=item $vf = new VectorField( dy_rule_ref);

rule_reference is a reference to a subroutine which accepts a pair of numerical values
and returns a numerical value.
The Fun object will draw the direction field associated with this subroutine.

The new method returns a reference to the vector field object.

=item $fn = new Fun( rule_reference , graph_reference);

The vector field is also placed into the printing queue of the graph
object pointed to by graph_reference and the
domain of the vector field object is set to the domain of the graph.
The graph_ref must come last.

=back

=head2 new (phase plane version)

=over 4

=item $fn = new VectorField ( dx_rule_ref, dy_rule_ref );
=item $vf = new VectorField ( dx_rule_ref, dy_rule_ref );

A vector field object is created where the subroutines refered to by dx_rule_ref and dy_rule_ref define
the x and y components of the vector field at (x,y). Both subroutines must be functions of two variables.

=item $fn = new VectorField ( x_rule_ref, y_rule_ref, graph_ref );
=item $vf = new VectorField ( x_rule_ref, y_rule_ref, graph_ref );

This variant inserts the vector field object into the graph object referred to by graph_ref. The domain
of the vector field object is set to the domain of the graph.
of the vector field object is set to the domain of the graph. The graph_ref must come last.

=back

=head2 Properites

All of the properties are set using the construction $new_value = $fn->property($new_value)
and read using $current_value = $fn->property()
All of the properties are set using the construction $new_value = $vf->property($new_value)
and read using $current_value = $vf->property()

=over 4

Expand Down Expand Up @@ -105,12 +100,12 @@ The width in pixels of the pen used to draw the arrow (respectively the dot).

=item domain

$array_ref = $fn->domain(-1,-2,1,2) sets xmin to -1, ymin to -2, xmax to 1, and ymax to 2.
$array_ref = $vf->domain(-1,-2,1,2) sets xmin to -1, ymin to -2, xmax to 1, and ymax to 2.


=item draw

$fn->draw($graph_ref) draws the vector field in the graph object pointed to by $graph_ref.
$vf->draw($graph_ref) draws the vector field in the graph object pointed to by $graph_ref.

The graph object must
respond to the methods below. The draw call is mainly for internal
Expand Down
66 changes: 53 additions & 13 deletions lib/WeBWorK/PG/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BEGIN {
directoryFromPath
createFile
createDirectory
path_is_course_subdir
path_is_course_subdir
);

our @SHARED_FUNCTIONS = qw(
Expand Down Expand Up @@ -260,8 +260,12 @@ sub path_is_course_subdir {
#
sub query_sage_server {
my ($python, $url, $accepted_tos, $setSeed, $webworkfunc, $debug, $curlCommand)=@_;
my $sagecall = qq{$curlCommand -i -k -sS -L --data-urlencode "accepted_tos=${accepted_tos}"}.
# my $sagecall = qq{$curlCommand -i -k -sS -L --http1.1 --data-urlencode "accepted_tos=${accepted_tos}"}.
# qq{ --data-urlencode 'user_expressions={"WEBWORK":"_webwork_safe_json(WEBWORK)"}' --data-urlencode "code=${setSeed}${webworkfunc}$python" $url};
my $sagecall = qq{$curlCommand -i -k -sS -L --data-urlencode "accepted_tos=${accepted_tos}"}.
qq{ --data-urlencode 'user_expressions={"WEBWORK":"_webwork_safe_json(WEBWORK)"}' --data-urlencode "code=${setSeed}${webworkfunc}$python" $url};


my $output =`$sagecall`;
if ($debug) {
warn "debug is turned on in IO.pm. ";
Expand All @@ -279,13 +283,44 @@ sub query_sage_server {
# Access-Control-Allow-Origin: *
# Content-Type: application/json; charset=UTF-8
# $content: Either error message about terms of service or output from sage
my ($continue, $header, @content) = split("\r\n\r\n",$output);
my $content = join("\r\n\r\n",@content); # handle case where there were blank lines in the content
# warn "output list is ", join("|||\n|||",($continue, $header, @content));
# warn "header is $header =" , $header =~/200 OK\r\n/;
# find the header
# expecting something like
# HTTP/1.1 100 Continue

# HTTP/1.1 200 OK
# Date: Wed, 20 Sep 2017 14:54:03 GMT
# ......
# two blank lines
# content

# or (notice that here there is no continue response)
# HTTP/2 200
# date: Wed, 20 Sep 2017 16:06:03 GMT
# ......
# two blank lines
# content

my ($continue, $header, @content) = split("\r\n\r\n",$output);
#my $content = join("\r\n\r\n",@content); # handle case where there were blank lines in the content
my @lines = split("\r\n\r\n", $output);
$continue=0;
my $header_ok =0;
while (@lines) {
my $header_block = shift(@lines);
warn "checking for header: $header_block" if $debug;
next unless $header_block=~/\S/; #skip empty lines;
next if $header_block=~/HTTP/ and $header_block=~/100/; # skip continue line
if ($header_block=~/200/) { # 200 return is ok
$header_ok=1;
last;
}
}
my $content = join("|||\n|||",@lines) ; #headers have been removed.
#warn "output list is ", $content; # join("|||\n|||",($continue, $header, $content));
#warn "header_ok is $header_ok";
my $result;
if ($header =~/200 OK\r\n/) { #success
$result = $content;
if ($header_ok) { #success put any extraneous splits back together
$result = join("\r\n\r\n",@lines);
} else {
warn "ERROR in contacting sage server. Did you accept the terms of service by
setting {accepted_tos=>'true'} in the askSage options?\n $content\n";
Expand Down Expand Up @@ -343,24 +378,29 @@ END
# has something been returned?
not_null($output) or die "Unable to make a sage call to $url.";
warn "IO::askSage: We have some kind of value |$output| returned from sage" if $output and $debug;

if ($output =~ /"success":\s*true/ and $debug){
warn '"success": true is present in the output';
}
my $decoded = decode_json($output);
not_null($decoded) or die "Unable to decode sage output";
if ($debug and defined $decoded ) {
my $warning_string = "decoded contents\n ";
foreach my $key (keys %$decoded) {$warning_string .= "$key=".$decoded->{$key}.", ";}
$warning_string .= ' end decoded contents';
#warn "\n$warning_string" if $debug;
warn " decoded contents \n", PGUtil::pretty_print($decoded, 'text'), "end decoded contents";
warn " decoded contents \n", PGUtil::pretty_print($decoded, 'text'), "end decoded contents" if $debug;
}
# was there a Sage/python syntax Error
# is the returned something text from stdout (deprecated)
# have objects been returned in a WEBWORK variable?
my $success = $decoded->{success} if defined $decoded;
my $success = 0;
$success = $decoded->{success} if defined $decoded and $decoded->{success};
warn "success is $success" if $debug;
# the decoding process seems to change the string "true" to "1" sometimes -- we could enforce this
$success = 1 if defined $success and $success eq 'true';
if ($decoded->{success}==1) {
$success = 1 if $decoded->{execute_reply}->{status} eq 'ok';
warn "now success is $success because status was ok" if $debug;
if ($success) {
my $WEBWORK_variable_non_empty=0;
my $sage_WEBWORK_data = $decoded->{execute_reply}{user_expressions}{WEBWORK}{data}{'text/plain'};
warn "sage_WEBWORK_data $sage_WEBWORK_data" if $debug;
Expand All @@ -387,7 +427,7 @@ END
} else {
die "Error receiving JSON output from sage: \n$output\n ";
}
} elsif ($decoded->{success} == 0 ) { # this might be a syntax error
} elsif ($success == 0 ) { # this might be a syntax error
$ret->{error_message} = $decoded->{execute_reply}; # this is a hash. # need a better pretty print method
warn ( "IO.pm: Perhaps there was syntax error.", join(" ",%{ $decoded->{execute_reply}}));
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/PG/Translator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ sub process_answers{
if defined($new_rh_ans_evaluation_result) && ref($new_rh_ans_evaluation_result)
&& defined($new_rh_ans_evaluation_result->error_flag());
} else {
$PG->warning_message(" The evaluated answer is not an answer hash $new_rh_ans_evaluation_result: |".ref($new_rh_ans_evaluation_result)."|.");
$PG->warning_message(" The evaluated answer is not an answer hash ".($new_rh_ans_evaluation_result//'').': |'.ref($new_rh_ans_evaluation_result)."|.");
}
# $PG->debug_message( $self->{envir}->{'probFileName'} ." new_temp_ans and temp_ans don't agree: ".
# ref($new_temp_ans)." $new_temp_ans ". ref($temp_ans). " $temp_ans".length($new_temp_ans).length($temp_ans))
Expand Down
2 changes: 1 addition & 1 deletion macros/LinearProgramming.pl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ sub lp_current_value {
if (defined &Fraction) {
return Fraction(0); # MathObjects version
} else {
return new Fraction(0); # old style Function module version
return Fraction->new(0); # old style Function module version
}
} else {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion macros/LiveGraphics3D.pl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sub LiveGraphics3D {
size => [250,250],
jar => "live.jar", # "${htmlURL}live.jar",
codebase => findAppletCodebase("live.jar"),
# codebase => "http://hosted2.webwork.rochester.edu/webwork2_files/applets/", # used for testing
# codebase => "http://demo.webwork.rochester.edu/webwork2_files/applets/", # used for testing
background => "#FFFFFF",
scale => 1.,
tex_size => 500,
Expand Down
20 changes: 13 additions & 7 deletions macros/PGmatrixmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,18 @@ sub display_matrix {
# column labels for linear programming
$out .= dm_special_tops(%opts, 'alignList'=>$alignList) if ($opts{'top_labels'});
$out .= dm_mat_left($numRows, %opts);
my $cnt = 1; # we count rows in in case an element is boxed
my $cnt = 1; # we count rows in in case an element is boxed
# vertical lines put in with first row
$j = shift @myRows;
$out .= dm_mat_row($j, $alignList, %opts, 'isfirst'=>$numRows,
'cnt' => $cnt);
$cnt++ unless ($j eq 'hline');
my $tag = $opts{side_labels}->[$cnt-1];
$out .= dm_mat_row($j, $alignList, %opts, 'isfirst'=>$numRows,
'cnt' => $cnt, 'tag'=>$tag);
$cnt++ unless ($j eq 'hline');
$out .= dm_mat_right($numRows, %opts);
for $j (@myRows) {
$tag = $opts{side_labels}->[$cnt-1];
$out .= dm_mat_row($j, $alignList, %opts, 'isfirst'=>0,
'cnt' => $cnt);
'cnt' => $cnt,'tag'=>$tag);
$cnt++ unless ($j eq 'hline');
}
$out .= dm_end_matrix(%opts);
Expand Down Expand Up @@ -488,7 +490,11 @@ sub dm_mat_row {
$out .= '}' if ($colcount == $opts{'box'}->[1] and $opts{'cnt'} == $opts{'box'}->[0]);
$out .= " &";
}
chop($out); # remove last &
if ($opts{tag}) {
$out.= $opts{tag};
} else {
chop($out); # remove last &
}
$out .= "\\cr \n";
# carriage returns must be added manually for tex
} elsif ( $main::displayMode eq 'HTML_MathJax'
Expand Down Expand Up @@ -762,7 +768,7 @@ =head2 convert_to_array_ref {

sub convert_to_array_ref {
my $input = shift;
if (Value::isParser($input) and Value::classMatch($input,"Matrix")) {
if (Value::classMatch($input,"Matrix")) {
$input = [$input->value];
} elsif (ref($input) eq 'Matrix' ) {
$input = $input->array_ref;
Expand Down
Loading