Skip to content

Commit a2d83ca

Browse files
authored
Merge pull request #364 from openwebwork/rel-PG-2.14
Rel pg 2.14
2 parents 8a089ed + 60a17f1 commit a2d83ca

File tree

99 files changed

+1931
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1931
-648
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Online Homework Delivery System
33
Version 2.*
44

5-
Copyright 2000-2017, The WeBWorK Project
5+
Copyright 2000-2018, The WeBWorK Project
66
All rights reserved.
77

88
This program is free software; you can redistribute it and/or modify

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PG_VERSION ='PG-2.13';
2-
$PG_COPYRIGHT_YEARS = '1996-2017';
1+
$PG_VERSION ='PG-2.14';
2+
$PG_COPYRIGHT_YEARS = '1996-2018';
33

44
1;

lib/AnswerHash.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
AnswerHash -- this class stores information related to the student's
2222
answer. It is little more than a standard perl hash with
23-
a special name, butit does have some access and
23+
a special name, but it does have some access and
2424
manipulation methods. More of these may be added as it
2525
becomes necessary.
2626

lib/Applet.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22
# WeBWorK Online Homework Delivery System
3-
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
3+
# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/
44
# $CVSHeader$
55
#
66
# This program is free software; you can redistribute it and/or modify it under

lib/Label.pm

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ This module defines labels for the graph objects (WWPlot).
1818
1919
=head2 Usage
2020
21-
$label1 = new Label($x_value, $y_value, $label_string, $label_color, @justification)
22-
$justification = one of ('left', 'center', 'right) and ('bottom', 'center', 'top')
23-
describes the position of the ($x_value, $y_value) within the string.
24-
The default is 'left', 'top'
21+
$label1 = new Label($x_value, $y_value, $label_string, $label_color, @options)
22+
$options is an array with (*'d defaults)
23+
- one of 'left'*, 'center', 'right' (horizontal alignment)
24+
- one of 'bottom', 'center', 'top'* (verical alignment)
25+
- one of 'horizontal'*, 'vertical' (orientation)
26+
- one of 'small', 'large', 'mediumbold'*, 'tiny', 'giant' (which gd font to use)
27+
Note the alignment specifications are relative to the English reading of the string,
28+
even when the orientation is vertical.
2529
2630
2731
28-
=head2 Example
32+
=head2 Example:
2933
3034
$new_label = new Label ( 0,0, 'origin','red','left', 'top')
3135
@labels = $graph->lb($new_label);
@@ -51,14 +55,15 @@ use strict;
5155
@Label::ISA = qw(WWPlot);
5256

5357
my %fields =(
54-
'x' => 0,
55-
'y' => 0,
56-
color => 'black',
57-
font => GD::gdMediumBoldFont, #gdLargeFont
58-
# constants from GD need to be addressed fully, they have not been imported.
59-
str => "",
60-
lr_nudge => 0, #justification parameters
61-
tb_nudge => 0,
58+
'x' => 0,
59+
'y' => 0,
60+
color => 'black',
61+
font => GD::gdMediumBoldFont, #gdLargeFont
62+
# constants from GD need to be addressed fully, they have not been imported.
63+
str => "",
64+
lr_nudge => 0, #justification parameters
65+
tb_nudge => 0,
66+
orientation => 'horizontal',
6267
);
6368

6469

@@ -74,31 +79,46 @@ sub new {
7479
}
7580

7681
sub _initialize {
77-
my $self = shift;
78-
my ($x,$y,$str,$color,@justification) = @_;
79-
$self -> x($x);
80-
$self -> y($y);
81-
$self -> str($str);
82-
$self -> color($color) if defined($color);
83-
my $j;
84-
foreach $j (@justification) {
85-
$self->lr_nudge( - length($self->str) ) if $j eq 'right';
86-
$self->tb_nudge( - 1 ) if $j eq 'bottom';
87-
$self->lr_nudge( - ( length($self->str) )/2)if $j eq 'center';
88-
$self->tb_nudge(-0.5) if $j eq 'middle';
89-
# print "\njustification=$j",$self->lr_nudge,$self->tb_nudge,"\n";
90-
}
82+
my $self = shift;
83+
my ($x,$y,$str,$color,@justification) = @_;
84+
$self -> x($x);
85+
$self -> y($y);
86+
$self -> str($str);
87+
$self -> color($color) if defined($color);
88+
my $j;
89+
foreach $j (@justification) {
90+
if ($j eq 'right') {$self->lr_nudge( - length($self->str) ); }
91+
elsif ($j eq 'bottom') {$self->tb_nudge( - 1 ); }
92+
elsif ($j eq 'center') {$self->lr_nudge( - ( length($self->str) )/2); }
93+
elsif ($j eq 'middle') {$self->tb_nudge(-0.5); }
94+
elsif ($j eq 'vertical') {$self->orientation($j); }
95+
#there are only five avialble fonts: http://search.cpan.org/~rurban/GD-2.68/lib/GD.pm#Font_Utilities
96+
elsif ($j eq 'small') {$self->font(GD::gdSmallFont); }
97+
elsif ($j eq 'large') {$self->font(GD::gdLargeFont); }
98+
elsif ($j eq 'tiny') {$self->font(GD::gdTinyFont); }
99+
elsif ($j eq 'giant') {$self->font(GD::gdGiantFont); }
100+
}
91101
}
92102
sub draw {
93-
my $self = shift;
94-
my $g = shift; #the containing graph
95-
$g->im->string( $self->font,
96-
$g->ii($self->x)+int( $self->lr_nudge*($self->font->width) ),
97-
$g->jj($self->y)+int( $self->tb_nudge*($self->font->height) ),
98-
$self->str,
99-
${$g->colors}{$self->color}
100-
);
101-
103+
my $self = shift;
104+
my $g = shift; #the containing graph
105+
if ($self->orientation eq 'horizontal') {
106+
$g->im->string( $self->font,
107+
$g->ii($self->x)+int( $self->lr_nudge*($self->font->width) ),
108+
$g->jj($self->y)+int( $self->tb_nudge*($self->font->height) ),
109+
$self->str,
110+
${$g->colors}{$self->color}
111+
);
112+
}
113+
elsif ($self->orientation eq 'vertical') {
114+
$g->im->stringUp( $self->font,
115+
$g->ii($self->x)+int( $self->tb_nudge*($self->font->height) ),
116+
$g->jj($self->y)-int( $self->lr_nudge*($self->font->width) ),
117+
$self->str,
118+
${$g->colors}{$self->color}
119+
);
120+
121+
}
102122
}
103123

104124
sub AUTOLOAD {
@@ -214,6 +234,22 @@ sub tb_nudge {
214234
return $self->{tb_nudge}
215235
}
216236
}
237+
238+
sub orientation {
239+
my $self = shift;
240+
my $type = ref($self) || die "$self is not an object";
241+
unless (exists $self->{orientation} ) {
242+
die "Can't find orientation field in object of class $type";
243+
}
244+
245+
if (@_) {
246+
return $self->{orientation} = shift;
247+
} else {
248+
return $self->{orientation}
249+
}
250+
}
251+
252+
217253
sub DESTROY {
218254
# doing nothing about destruction, hope that isn't dangerous
219255
}

lib/Matrix.pm

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Matrix - Matrix of Reals
44
55
Implements overrides for MatrixReal.pm for WeBWorK
6+
In general it is better to use MathObjects Matrices (Value::Matrix)
7+
in writing PG problem. The answer checking is much superior with better
8+
error messages for syntax errors in student entries. Some of the
9+
subroutines in this file are still used behind the scenes
10+
by Value::Matrix to perform calculations,
11+
such as decompose_LR().
612
713
=head1 DESCRIPTION
814
@@ -68,8 +74,23 @@ sub _stringify {
6874
return($s);
6975
}
7076

71-
# obtain the Left Right matrices of the decomposition and the two pivot permutation matrices
72-
# the original is M = PL*L*R*PR
77+
=head3 Accessor functions
78+
79+
(these are deprecated for direct use. Use the covering Methods
80+
provided by MathObject Matrices instead.)
81+
82+
L($matrix) - return matrix L of the LR decomposition
83+
R($matrix) - return matrix R of the LR decomposition
84+
PL($matrix) - return permutation matrix
85+
PR($matrix) - return permutation matrix
86+
Original matrix is PL * L * R *PR = M
87+
88+
Obtain the Left Right matrices of the decomposition
89+
and the two pivot permutation matrices
90+
the original is M = PL*L*R*PR
91+
92+
=cut
93+
7394
sub L {
7495
my $matrix = shift;
7596
my $rows = $matrix->[1];
@@ -83,6 +104,7 @@ sub L {
83104
}
84105
$L_matrix;
85106
}
107+
86108
sub R {
87109
my $matrix = shift;
88110
my $rows = $matrix->[1];
@@ -117,12 +139,14 @@ sub PR { # use this permuation on the right PL*L*R*PR =M
117139
$PR_matrix;
118140

119141
}
120-
# obtain the Left Right matrices of the decomposition and the two pivot permutation matrices
121-
# the original is M = PL*L*R*PR
142+
143+
122144
=head4
123145
124146
Method $matrix->rh_options
125147
148+
Meant for internal use when dealing with MatrixReal1
149+
126150
=cut
127151

128152
sub rh_options {
@@ -137,9 +161,13 @@ sub rh_options {
137161
Method $matrix->trace
138162
139163
Returns: scalar which is the trace of the matrix.
164+
165+
Used by MathObject Matrices for calculating the trace.
166+
Deprecated for direct use in PG questions.
140167
141168
=cut
142169

170+
143171
sub trace {
144172
my $self = shift;
145173
my $rows = $self->[1];
@@ -152,9 +180,12 @@ sub trace {
152180
$sum;
153181
}
154182

183+
155184
=head4
156185
157-
Method $matrix->new_from_array_ref
186+
Method $new_matrix = $matrix->new_from_array_ref ([[a,b,c],[d,e,f]])
187+
188+
Deprecated in favor of using creation tools for MathObject Matrices
158189
159190
=cut
160191

@@ -172,6 +203,8 @@ sub new_from_array_ref { # this will build a matrix or a row vector from [a, b
172203
173204
Method $matrix->array_ref
174205
206+
Converts Matrix from an ARRAY to an ARRAY reference.
207+
175208
=cut
176209

177210
sub array_ref {
@@ -183,6 +216,8 @@ sub array_ref {
183216
184217
Method $matrix->list
185218
219+
Converts a Matrix column vector to an ARRAY (list).
220+
186221
=cut
187222

188223
sub list { # this is used only for column vectors
@@ -196,29 +231,14 @@ sub list { # this is used only for column vectors
196231
@list;
197232
}
198233

199-
=head4
200-
201-
Method $matrix->new_from_list
202-
203-
=cut
204-
205-
sub new_from_list { # this builds a row vector from an array
206-
my $class = shift;
207-
my @list = @_;
208-
my $cols = @list;
209-
my $rows = 1;
210-
my $matrix = new Matrix($rows, $cols);
211-
my $i=1;
212-
while(@list) {
213-
my $elem = shift(@list);
214-
$matrix->assign($i++,1, $elem);
215-
}
216-
$matrix;
217-
}
218234

219235
=head4
220236
221237
Method $matrix->new_row_matrix
238+
239+
Deprecated -- there are better tools for MathObject Matrices.
240+
241+
Create a row 1 by n matrix from a list. This subroutine appears to be broken
222242
223243
=cut
224244

@@ -239,7 +259,9 @@ sub new_row_matrix { # this builds a row vector from an array
239259
=head4
240260
241261
Method $matrix->proj
242-
262+
Provides behind the scenes calculations for MathObject Matrix->proj
263+
Deprecated for direct use in favor of methods of MathObject matrix
264+
243265
=cut
244266

245267
sub proj{
@@ -251,6 +273,8 @@ sub proj{
251273
=head4
252274
253275
Method $matrix->proj_coeff
276+
Provides behind the scenes calculations for MathObject Matrix->proj_coeff
277+
Deprecated for direct use in favor of methods of MathObject matrix
254278
255279
=cut
256280

@@ -271,6 +295,8 @@ sub proj_coeff{
271295
272296
Method $matrix->new_column_matrix
273297
298+
Create column matrix from an ARRAY reference (list reference)
299+
274300
=cut
275301

276302
sub new_column_matrix {
@@ -293,6 +319,8 @@ sub new_column_matrix {
293319
vectors.
294320
295321
Method $matrix->new_from_col_vecs
322+
323+
Deprecated: The tools for creating MathObjects Matrices are simpler
296324
297325
=cut
298326

@@ -343,8 +371,8 @@ sub new_from_col_vecs
343371

344372
=head4
345373
346-
Method $matrix->new_from_col_vecs
347-
374+
Function: cp()
375+
Provides ability to use complex numbers.
348376
=cut
349377

350378
sub cp { # MEG makes new copies of complex number
@@ -462,6 +490,8 @@ sub transpose
462490
463491
Method $matrix->decompose_LR
464492
493+
Used by MathObjects Matrix for LR decomposition
494+
Deprecated for direct use in PG problems.
465495
=cut
466496

467497
sub decompose_LR

lib/PGUtil.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###############################################################################
22
# WeBWorK Online Homework Delivery System
3-
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
3+
# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/
44
# $CVSHeader: pg/lib/PGcore.pm,v 1.6 2010/05/25 22:47:52 gage Exp $
55
#
66
# This program is free software; you can redistribute it and/or modify it under

0 commit comments

Comments
 (0)