Skip to content

Commit

Permalink
Merge pull request #364 from openwebwork/rel-PG-2.14
Browse files Browse the repository at this point in the history
Rel pg 2.14
  • Loading branch information
mgage authored Dec 30, 2018
2 parents 8a089ed + 60a17f1 commit a2d83ca
Show file tree
Hide file tree
Showing 99 changed files with 1,931 additions and 648 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Online Homework Delivery System
Version 2.*

Copyright 2000-2017, The WeBWorK Project
Copyright 2000-2018, The WeBWorK Project
All rights reserved.

This program is free software; you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PG_VERSION ='PG-2.13';
$PG_COPYRIGHT_YEARS = '1996-2017';
$PG_VERSION ='PG-2.14';
$PG_COPYRIGHT_YEARS = '1996-2018';

1;
2 changes: 1 addition & 1 deletion lib/AnswerHash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
AnswerHash -- this class stores information related to the student's
answer. It is little more than a standard perl hash with
a special name, butit does have some access and
a special name, but it does have some access and
manipulation methods. More of these may be added as it
becomes necessary.
Expand Down
2 changes: 1 addition & 1 deletion lib/Applet.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/
# $CVSHeader$
#
# This program is free software; you can redistribute it and/or modify it under
Expand Down
108 changes: 72 additions & 36 deletions lib/Label.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ This module defines labels for the graph objects (WWPlot).
=head2 Usage
$label1 = new Label($x_value, $y_value, $label_string, $label_color, @justification)
$justification = one of ('left', 'center', 'right) and ('bottom', 'center', 'top')
describes the position of the ($x_value, $y_value) within the string.
The default is 'left', 'top'
$label1 = new Label($x_value, $y_value, $label_string, $label_color, @options)
$options is an array with (*'d defaults)
- one of 'left'*, 'center', 'right' (horizontal alignment)
- one of 'bottom', 'center', 'top'* (verical alignment)
- one of 'horizontal'*, 'vertical' (orientation)
- one of 'small', 'large', 'mediumbold'*, 'tiny', 'giant' (which gd font to use)
Note the alignment specifications are relative to the English reading of the string,
even when the orientation is vertical.
=head2 Example
=head2 Example:
$new_label = new Label ( 0,0, 'origin','red','left', 'top')
@labels = $graph->lb($new_label);
Expand All @@ -51,14 +55,15 @@ use strict;
@Label::ISA = qw(WWPlot);

my %fields =(
'x' => 0,
'y' => 0,
color => 'black',
font => GD::gdMediumBoldFont, #gdLargeFont
# constants from GD need to be addressed fully, they have not been imported.
str => "",
lr_nudge => 0, #justification parameters
tb_nudge => 0,
'x' => 0,
'y' => 0,
color => 'black',
font => GD::gdMediumBoldFont, #gdLargeFont
# constants from GD need to be addressed fully, they have not been imported.
str => "",
lr_nudge => 0, #justification parameters
tb_nudge => 0,
orientation => 'horizontal',
);


Expand All @@ -74,31 +79,46 @@ sub new {
}

sub _initialize {
my $self = shift;
my ($x,$y,$str,$color,@justification) = @_;
$self -> x($x);
$self -> y($y);
$self -> str($str);
$self -> color($color) if defined($color);
my $j;
foreach $j (@justification) {
$self->lr_nudge( - length($self->str) ) if $j eq 'right';
$self->tb_nudge( - 1 ) if $j eq 'bottom';
$self->lr_nudge( - ( length($self->str) )/2)if $j eq 'center';
$self->tb_nudge(-0.5) if $j eq 'middle';
# print "\njustification=$j",$self->lr_nudge,$self->tb_nudge,"\n";
}
my $self = shift;
my ($x,$y,$str,$color,@justification) = @_;
$self -> x($x);
$self -> y($y);
$self -> str($str);
$self -> color($color) if defined($color);
my $j;
foreach $j (@justification) {
if ($j eq 'right') {$self->lr_nudge( - length($self->str) ); }
elsif ($j eq 'bottom') {$self->tb_nudge( - 1 ); }
elsif ($j eq 'center') {$self->lr_nudge( - ( length($self->str) )/2); }
elsif ($j eq 'middle') {$self->tb_nudge(-0.5); }
elsif ($j eq 'vertical') {$self->orientation($j); }
#there are only five avialble fonts: http://search.cpan.org/~rurban/GD-2.68/lib/GD.pm#Font_Utilities
elsif ($j eq 'small') {$self->font(GD::gdSmallFont); }
elsif ($j eq 'large') {$self->font(GD::gdLargeFont); }
elsif ($j eq 'tiny') {$self->font(GD::gdTinyFont); }
elsif ($j eq 'giant') {$self->font(GD::gdGiantFont); }
}
}
sub draw {
my $self = shift;
my $g = shift; #the containing graph
$g->im->string( $self->font,
$g->ii($self->x)+int( $self->lr_nudge*($self->font->width) ),
$g->jj($self->y)+int( $self->tb_nudge*($self->font->height) ),
$self->str,
${$g->colors}{$self->color}
);

my $self = shift;
my $g = shift; #the containing graph
if ($self->orientation eq 'horizontal') {
$g->im->string( $self->font,
$g->ii($self->x)+int( $self->lr_nudge*($self->font->width) ),
$g->jj($self->y)+int( $self->tb_nudge*($self->font->height) ),
$self->str,
${$g->colors}{$self->color}
);
}
elsif ($self->orientation eq 'vertical') {
$g->im->stringUp( $self->font,
$g->ii($self->x)+int( $self->tb_nudge*($self->font->height) ),
$g->jj($self->y)-int( $self->lr_nudge*($self->font->width) ),
$self->str,
${$g->colors}{$self->color}
);

}
}

sub AUTOLOAD {
Expand Down Expand Up @@ -214,6 +234,22 @@ sub tb_nudge {
return $self->{tb_nudge}
}
}

sub orientation {
my $self = shift;
my $type = ref($self) || die "$self is not an object";
unless (exists $self->{orientation} ) {
die "Can't find orientation field in object of class $type";
}

if (@_) {
return $self->{orientation} = shift;
} else {
return $self->{orientation}
}
}


sub DESTROY {
# doing nothing about destruction, hope that isn't dangerous
}
Expand Down
84 changes: 57 additions & 27 deletions lib/Matrix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Matrix - Matrix of Reals
Implements overrides for MatrixReal.pm for WeBWorK
In general it is better to use MathObjects Matrices (Value::Matrix)
in writing PG problem. The answer checking is much superior with better
error messages for syntax errors in student entries. Some of the
subroutines in this file are still used behind the scenes
by Value::Matrix to perform calculations,
such as decompose_LR().
=head1 DESCRIPTION
Expand Down Expand Up @@ -68,8 +74,23 @@ sub _stringify {
return($s);
}

# obtain the Left Right matrices of the decomposition and the two pivot permutation matrices
# the original is M = PL*L*R*PR
=head3 Accessor functions
(these are deprecated for direct use. Use the covering Methods
provided by MathObject Matrices instead.)
L($matrix) - return matrix L of the LR decomposition
R($matrix) - return matrix R of the LR decomposition
PL($matrix) - return permutation matrix
PR($matrix) - return permutation matrix
Original matrix is PL * L * R *PR = M
Obtain the Left Right matrices of the decomposition
and the two pivot permutation matrices
the original is M = PL*L*R*PR
=cut

sub L {
my $matrix = shift;
my $rows = $matrix->[1];
Expand All @@ -83,6 +104,7 @@ sub L {
}
$L_matrix;
}

sub R {
my $matrix = shift;
my $rows = $matrix->[1];
Expand Down Expand Up @@ -117,12 +139,14 @@ sub PR { # use this permuation on the right PL*L*R*PR =M
$PR_matrix;

}
# obtain the Left Right matrices of the decomposition and the two pivot permutation matrices
# the original is M = PL*L*R*PR


=head4
Method $matrix->rh_options
Meant for internal use when dealing with MatrixReal1
=cut

sub rh_options {
Expand All @@ -137,9 +161,13 @@ sub rh_options {
Method $matrix->trace
Returns: scalar which is the trace of the matrix.
Used by MathObject Matrices for calculating the trace.
Deprecated for direct use in PG questions.
=cut


sub trace {
my $self = shift;
my $rows = $self->[1];
Expand All @@ -152,9 +180,12 @@ sub trace {
$sum;
}


=head4
Method $matrix->new_from_array_ref
Method $new_matrix = $matrix->new_from_array_ref ([[a,b,c],[d,e,f]])
Deprecated in favor of using creation tools for MathObject Matrices
=cut

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

sub array_ref {
Expand All @@ -183,6 +216,8 @@ sub array_ref {
Method $matrix->list
Converts a Matrix column vector to an ARRAY (list).
=cut

sub list { # this is used only for column vectors
Expand All @@ -196,29 +231,14 @@ sub list { # this is used only for column vectors
@list;
}

=head4
Method $matrix->new_from_list
=cut

sub new_from_list { # this builds a row vector from an array
my $class = shift;
my @list = @_;
my $cols = @list;
my $rows = 1;
my $matrix = new Matrix($rows, $cols);
my $i=1;
while(@list) {
my $elem = shift(@list);
$matrix->assign($i++,1, $elem);
}
$matrix;
}

=head4
Method $matrix->new_row_matrix
Deprecated -- there are better tools for MathObject Matrices.
Create a row 1 by n matrix from a list. This subroutine appears to be broken
=cut

Expand All @@ -239,7 +259,9 @@ sub new_row_matrix { # this builds a row vector from an array
=head4
Method $matrix->proj
Provides behind the scenes calculations for MathObject Matrix->proj
Deprecated for direct use in favor of methods of MathObject matrix
=cut

sub proj{
Expand All @@ -251,6 +273,8 @@ sub proj{
=head4
Method $matrix->proj_coeff
Provides behind the scenes calculations for MathObject Matrix->proj_coeff
Deprecated for direct use in favor of methods of MathObject matrix
=cut

Expand All @@ -271,6 +295,8 @@ sub proj_coeff{
Method $matrix->new_column_matrix
Create column matrix from an ARRAY reference (list reference)
=cut

sub new_column_matrix {
Expand All @@ -293,6 +319,8 @@ sub new_column_matrix {
vectors.
Method $matrix->new_from_col_vecs
Deprecated: The tools for creating MathObjects Matrices are simpler
=cut

Expand Down Expand Up @@ -343,8 +371,8 @@ sub new_from_col_vecs

=head4
Method $matrix->new_from_col_vecs
Function: cp()
Provides ability to use complex numbers.
=cut

sub cp { # MEG makes new copies of complex number
Expand Down Expand Up @@ -462,6 +490,8 @@ sub transpose
Method $matrix->decompose_LR
Used by MathObjects Matrix for LR decomposition
Deprecated for direct use in PG problems.
=cut

sub decompose_LR
Expand Down
2 changes: 1 addition & 1 deletion lib/PGUtil.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/
# $CVSHeader: pg/lib/PGcore.pm,v 1.6 2010/05/25 22:47:52 gage Exp $
#
# This program is free software; you can redistribute it and/or modify it under
Expand Down
Loading

0 comments on commit a2d83ca

Please sign in to comment.