You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: dpvc v. a. <we...@ma...> - 2009-10-10 13:57:41
|
Log Message: ----------- A new context for chemical reactions Added Files: ----------- pg/macros: contextReaction.pl Revision Data ------------- --- /dev/null +++ macros/contextReaction.pl @@ -0,0 +1,365 @@ +=head1 NAME + +contextReaction.pl - Implements a MathObject class for checmical reactions. + +=head1 DESCRIPTION + +This file implements a Context in which checmical reactions can be +specified and compared. Reactions can be composed of sums of integer +multiples of elements (possibly with subscripts), separated by a right +arrow (indicated by "-->"). Helpful error messages are given when a +reaction is not of the correct form. Sums of compounds can be given +in any order, but the elements within a compound must be in the order +given by the correct answer; e.g., if the correct answer specifies +CO_2, then O_2C would be marked incorrect. + +To use the context include + + loadMacros("contextReaction.pl"); + Context("Reaction"); + +at the top of your PG file, then create Formula() objects for your +reactions. For example: + + $R = Formula("4P + 5O_2 --> 2P_2O_5"); + +Reactions know how to create their own TeX versions (via $R->TeX), and +know how to check student answers (via $R->cmp), just like any other +MathObject. + +The Reaction Context also allows you to create parts of reactions. +E.g., you could create + + $products = Formula("4CO_2 + 6H_2O"); + +which you could use in a problem as follows: + + loadMacros("contextReaction.pl"); + Context("Reaction"); + + $reactants = Formula("2C_2H_6 + 7O_2"); + $products = Formula("4CO_2 + 6H_2O"); + + Context()->texStrings; + BEGIN_TEXT + \($reactants \longrightarrow\) \{ans_rule(30)\}. + END_TEXT + Context()->normalStrings; + + ANS($products->cmp); + +Note that sums and products are not simplified in any way, so that +Formula("O + O") and Formula("2O") and Formula("O_2") are all +different and unequal in this context. + +All the elements of the periodic table are available within the +Reaction Context. If you need additional terms, like "Heat" for +example, you can add them as variables: + + Context()->variables->add(Heat => $context::Reaction::CONSTANT); + +Then you can make formulas that include Heat as a term. These +"constants" are not allowed to have coefficients or subscripts, and +can not be combined with compounds except by addition. If you want a +term that can be combined in those ways, use +$context::Reaction::ELEMENT instead. + +=cut + +sub _contextReaction_init {context::Reaction::Init()} + +###################################################################### + +package context::Reaction; +our @ISA = ('Value::Formula'); + +our $ELEMENT = {isValue => 1, type => Value::Type("Element",1)}; +our $MOLECULE = {isValue => 1, type => Value::Type("Molecule",1)}; +our $COMPOUND = {isValue => 1, type => Value::Type("Compound",1)}; +our $REACTION = {isValue => 1, type => Value::Type("Reaction",1)}; +our $CONSTANT = {isValue => 1, type => Value::Type("Constant",1)}; + +sub Init { + my $context = $main::context{Reaction} = Parser::Context->getCopy("Numeric"); + $context->functions->clear(); + $context->strings->clear(); + $context->constants->clear(); + $context->lists->clear(); + $context->lists->add( + 'List' => {class =>'context::Reaction::List::List', open => '', close => '', separator => ' + '}, + ); + $context->parens->clear(); + $context->parens->add( + '(' => {close => ')', type => 'List', formList => 1, removable => 1}, + '{' => {close => '}', type => 'List', removable => 1}, + ); + $context->operators->clear(); + $context->operators->set( + '-->' => {precedence => 1, associativity => 'left', type => 'bin', string => ' --> ', + class => 'context::Reaction::BOP::arrow', TeX => " \\longrightarrow "}, + + '+' => {precedence => 2, associativity => 'left', type => 'bin', string => ' + ', + class => 'context::Reaction::BOP::add', isComma => 1}, + + ' ' => {precedence => 3, associativity => 'left', type => 'bin', string => ' ', + class => 'context::Reaction::BOP::multiply', hidden => 1}, + + '_' => {precedence => 4, associativity => 'left', type => 'bin', string => '_', + class => 'context::Reaction::BOP::underscore'}, + + '-' => {precedence => 5, associativity => 'left', type => 'both', string => ' - ', + class => 'Parser::BOP::undefined'}, + 'u-'=> {precedence => 6, associativity => 'left', type => 'unary', string => '-', + class => 'Parser::UOP::undefined', hidden => 1}, + ); + $context->variables->are( + map {$_ => $ELEMENT} ( + "H", "He", + "Li","Be", "B", "C", "N", "O", "F", "Ne", + "Na","Mg", "Al","Si","P", "S", "Cl","Ar", + "K", "Ca", "Sc","Ti","V", "Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr", + "Rb","Sr", "Y", "Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I", "Xe", + "Cs","Ba", "Lu","Hf","Ta","W", "Re","Os","Ir","Pt","Au","Hg","Ti","Pb"."Bi","Po","At","Rn", + "Fr","Ra", "Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Uut","Uuq","Uup","Uuh","Uus","Uuo", + + "La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb", + "Ac","Th","Pa","U", "Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No", + ) + ); + $context->{parser}{Number} = "context::Reaction::Number"; + $context->{parser}{Variable} = "context::Reaction::Variable"; + $context->{parser}{List} = "context::Reaction::List"; + $context->{parser}{Formula} = "context::Reaction"; + $context->{value}{Reaction} = "context::Reaction"; + $context->{value}{Element} = "context::Reaction::Variable"; + $context->{value}{Constant} = "context::Reaction::Variable"; + Parser::Number::NoDecimals($context); + + main::PG_restricted_eval('sub Reaction {Value->Package("Formula")->new(@_)};'); +} + +sub compare { + my ($l,$r) = @_; my $self = $l; + my $context = $self->context; + $r = $context->Package("Formula")->new($context,$r) unless Value::isFormula($r); + return ($l->{tree}->equivalent($r->{tree}) ? 0 : 1); +} + +sub eval { + my $self = shift; + $self->Error("Can't evaluate ".$self->TYPE); +} + +sub TYPE {'a chemical reaction'} +sub cmp_class {'a Chemical Reaction'} + +sub cmp_defaults {(showTypeWarnings => 1)} + +sub cmp_equal {Value::cmp_equal(@_)}; + +sub cmp_postprocess { + my $self = shift; my $ans = shift; + return unless $self->{tree}->type eq 'Reaction'; + $self->cmp_Error($ans,"Your answer doesn't seem to be a reaction (it should contain a reaction arrow '-->')") + unless $ans->{student_value}{tree}->type eq 'Reaction'; +} + +sub typeMatch { + my $self = shift; my $other = shift; + return 1; +} + +###################################################################### + +package context::Reaction::Number; +our @ISA = ('Parser::Number'); + +sub equivalent { + my $self = shift; my $other = shift; + return 0 unless $other->class eq 'Number'; + return $self->eval == $other->eval; +} + +sub isChemical {0} + +sub class {'Number'} +sub TYPE {'a Number'} + +###################################################################### + +package context::Reaction::Variable; +our @ISA = ('Parser::Variable'); + +sub equivalent { + my $self = shift; my $other = shift; + return 0 unless $other->class eq 'Variable'; + return $self->{name} eq $other->{name}; +} + +sub eval {context::Reaction::eval(@_)} + +sub isChemical {1} + +sub TeX { + my $self = shift; + return "{\\rm $self->{name}}"; +} + +sub class {'Variable'} + +sub TYPE { + my $self = shift; + return ($self->type eq 'Constant'? "'$self->{name}'" : 'an element'); +} + +###################################################################### + +package context::Reaction::BOP; +our @ISA = ('Parser::BOP'); + +sub isChemical {1} + +sub eval {context::Reaction::eval(@_)} + +sub equivalent { + my $self = shift; my $other = shift; + return 0 unless substr($other->class,0,3) eq 'BOP'; + return $self->{lop}->equivalent($other->{lop}) && $self->{rop}->equivalent($other->{rop}); +} + +sub class { + my $self = shift; + my $class = ref($self); + $class =~ s/.*::BOP::/BOP::/; + return $class; +} + +###################################################################### + +package context::Reaction::BOP::arrow; +our @ISA = ('context::Reaction::BOP'); + +sub isChemical {0} + +sub _check { + my $self = shift; + $self->Error("The left-hand side of '-->' must be a (sum of) reactants, not %s", + $self->{lop}->TYPE) unless $self->{lop}->isChemical; + $self->Error("The right-hand side of '-->' must be a (sum of) products, not %s", + $self->{rop}->TYPE) unless $self->{rop}->isChemical; + $self->{type} = $REACTION->{type}; +} + +sub TYPE {'a reaction'} + +###################################################################### + +package context::Reaction::BOP::add; +our @ISA = ('Parser::BOP::comma','context::Reaction::BOP'); + +sub _check { + my $self = shift; + $self->Error("Can't add %s and %s",$self->{lop}->TYPE,$self->{rop}->TYPE) + unless $self->{lop}->isChemical && $self->{rop}->isChemical; + $self->SUPER::_check(@_); +} + +sub equivalent { + my $self = shift; my $other = shift; + return 0 unless substr($other->class,0,3) eq 'BOP'; + return $self->SUPER::equivalent($other) || + ($self->{lop}->equivalent($other->{rop}) && $self->{rop}->equivalent($other->{rop})); +} + +sub TYPE {'a sum of Compounds'} + +###################################################################### + +package context::Reaction::BOP::multiply; +our @ISA = ('context::Reaction::BOP'); + +sub _check { + my $self = shift; + $self->Error("Can't combine %s and %s",$self->{lop}->TYPE,$self->{rop}->TYPE) + unless ($self->{lop}->class eq 'Number' || $self->{lop}->isChemical) && + $self->{rop}->isChemical; + $self->Error("Can't combine %s with %s",$self->{lop}{name},$self->{rop}->TYPE) + if $self->{lop}->type eq 'Constant'; + $self->Error("Can't combine %s with %s",$self->{lop}->TYPE,$self->{rop}{name}) + if $self->{rop}->type eq 'Constant'; + $self->{type} = $COMPOUND->{type}; +} + +# +# No space for implied multiplication +# +sub string { + my $self = shift; + return $self->{lop}->string.$self->{rop}->string; +} +sub TeX { + my $self = shift; + return $self->{lop}->TeX.$self->{rop}->TeX; +} + +sub TYPE {'a compound'} + +###################################################################### + +package context::Reaction::BOP::underscore; +our @ISA = ('context::Reaction::BOP'); + +sub _check { + my $self = shift; + $self->Error("The left-hand side of '_' must be an element, not %s",$self->{lop}->TYPE) + unless $self->{lop}->type eq 'Element'; + $self->Error("The right-hand side of '_' must be a number, not %s",$self->{rop}->TYPE) + unless $self->{rop}->class eq 'Number'; + $self->{type} = $MOLECULE->{type}; +} + +sub TeX { + my $self = shift; + return $self->{lop}->TeX."_{".$self->{rop}->TeX."}"; +} + +sub TYPE {'a molecule'} + +###################################################################### + +package context::Reaction::List; +our @ISA = ('Parser::List::List'); + +sub cmp_compare { + my $self = shift; my $other = shift; my $ans = shift; + return $self->{tree}->equivalent($other->{tree}); +} + +###################################################################### + +package context::Reaction::List::List; +our @ISA = ('Parser::List::List'); + +sub equivalent { + my $self = shift; my $other = shift; + return 0 unless $self->length == $other->length; + my @left = main::lex_sort(map {$_->string} @{$self->{coords}}); + my @right = main::lex_sort(map {$_->string} @{$other->{coords}}); + return join(',',@left) eq join(',',@right); +} + +sub TeX { + my $self = shift; my $precedence = shift; my @coords = (); + foreach my $x (@{$self->{coords}}) {push(@coords,$x->TeX)} + return join(' + ',@coords); +} + +sub eval {context::Reaction::eval(@_)} + +sub isChemical {1} + +sub TYPE {'a sum of compounds'} + +###################################################################### + +1; |
From: Mark H. v. a. <we...@ma...> - 2009-10-09 20:35:13
|
Log Message: ----------- Modified global.conf.dist to include the changes needed for LDAPS Binding. Modified Files: -------------- webwork2/conf: global.conf.dist Revision Data ------------- Index: global.conf.dist =================================================================== RCS file: /webwork/cvs/system/webwork2/conf/global.conf.dist,v retrieving revision 1.216 retrieving revision 1.217 diff -Lconf/global.conf.dist -Lconf/global.conf.dist -u -r1.216 -r1.217 --- conf/global.conf.dist +++ conf/global.conf.dist @@ -624,6 +624,15 @@ }, # base to use when searching for user's DN net_ldap_base => "ou=people,dc=rochester,dc=edu", + + # Use a Bind account if set to 1 + bindAccount => 0, + + searchDN => "cn=search,DC=youredu,DC=edu", + bindPassword => "password", + + + # If LDAP rejects password, check it against the WeBWorK password database failover => 1, }; |
From: Mark H. v. a. <we...@ma...> - 2009-10-09 20:25:19
|
Log Message: ----------- Updated LDAP.pm to work with LDAPS servers that require the usage of a binder account. Modified Files: -------------- webwork2/lib/WeBWorK/Authen: LDAP.pm Revision Data ------------- Index: LDAP.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Authen/LDAP.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/WeBWorK/Authen/LDAP.pm -Llib/WeBWorK/Authen/LDAP.pm -u -r1.4 -r1.5 --- lib/WeBWorK/Authen/LDAP.pm +++ lib/WeBWorK/Authen/LDAP.pm @@ -31,6 +31,8 @@ # check against LDAP server return 1 if $self->ldap_authen_uid($userID, $possibleClearPassword); + + return 0 if ($userID !~ /admin/); # optional: fail over to superclass checkPassword if ($failover) { @@ -48,6 +50,11 @@ my $hosts = $ce->{authen}{ldap_options}{net_ldap_hosts}; my $opts = $ce->{authen}{ldap_options}{net_ldap_opts}; my $base = $ce->{authen}{ldap_options}{net_ldap_base}; + my $searchdn = $ce->{authen}{ldap_options}{searchDN}; + my $bindAccount = $ce->{authen}{ldap_options}{bindAccount}; + my $bindpassword = $ce->{authen}{ldap_options}{bindPassword}; + + # connect to LDAP server my $ldap = new Net::LDAP($hosts, @$opts); @@ -58,17 +65,28 @@ my $msg; + + if($bindAccount){ + # bind with a bind USER + $msg = $ldap->bind( $searchdn, password => $bindpassword ); + if ($msg->is_error) { + warn "AUTH LDAP: bind error ", $msg->code, ": ", $msg->error_text, ".\n"; + return 0; + } + } + else{ # bind anonymously - $msg = $ldap->bind; - if ($msg->is_error) { - warn "AUTH LDAP: bind error ", $msg->code, ": ", $msg->error_text, ".\n"; - return 0; + $msg = $ldap->bind; + if ($msg->is_error) { + warn "AUTH LDAP: bind error ", $msg->code, ": ", $msg->error_text, ".\n"; + return 0; + } } # look up user's DN - $msg = $ldap->search(base => $base, filter => "uid=$uid"); + $msg = $ldap->search(base => $base, filter => "sAMAccountName=$uid"); if ($msg->is_error) { - warn "AUTH LDAP: search error ", $msg->code, ": ", $msg->error_text, ".\n"; + warn "AUTH LDAP: search error ", $msg->code, ": ", $msg->error_text, ".\n",$searchdn,"\n",$base,"\n",$uid,"\n"; return 0; } if ($msg->count > 1) { |
From: Arnie P. v. a. <we...@ma...> - 2009-10-08 20:02:09
|
Log Message: ----------- Add new maco search paths Modified Files: -------------- webwork2/conf: global.conf.dist Revision Data ------------- Index: global.conf.dist =================================================================== RCS file: /webwork/cvs/system/webwork2/conf/global.conf.dist,v retrieving revision 1.215 retrieving revision 1.216 diff -Lconf/global.conf.dist -Lconf/global.conf.dist -u -r1.215 -r1.216 --- conf/global.conf.dist +++ conf/global.conf.dist @@ -857,10 +857,13 @@ ".", # search the problem file's directory $courseDirs{macros}, $pg{directories}{macros}, - "$courseDirs{templates}/Library/macros/Dartmouth", "$courseDirs{templates}/Library/macros/Union", - "$courseDirs{templates}/Library/macros/NAU", + "$courseDirs{templates}/Library/macros/HughesHallett", "$courseDirs{templates}/Library/macros/Michigan", + "$courseDirs{templates}/Library/macros/CollegeOfIdaho", + "$courseDirs{templates}/Library/macros/TCNJ", + "$courseDirs{templates}/Library/macros/NAU", + "$courseDirs{templates}/Library/macros/Dartmouth", ]; # The applet search path. If a full URL is given, it is used unmodified. If an |
From: dpvc v. a. <we...@ma...> - 2009-10-07 14:57:12
|
Log Message: ----------- fixed spelling error Modified Files: -------------- pg/macros: parserFormulaUpToConstant.pl Revision Data ------------- Index: parserFormulaUpToConstant.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFormulaUpToConstant.pl,v retrieving revision 1.21 retrieving revision 1.22 diff -Lmacros/parserFormulaUpToConstant.pl -Lmacros/parserFormulaUpToConstant.pl -u -r1.21 -r1.22 --- macros/parserFormulaUpToConstant.pl +++ macros/parserFormulaUpToConstant.pl @@ -46,7 +46,7 @@ ANS($f->cmp); -Note that the FormulaUpToConstant object creates its only private +Note that the FormulaUpToConstant object creates its own private copy of the current Context (so that it can add variables without affecting the rest of the problem). You should not notice this in general, but if you need to access that context, use $f->{context}. |
From: Mike G. v. a. <we...@ma...> - 2009-10-04 17:59:07
|
Log Message: ----------- edited some pod documentation Tags: ---- rel-2-4-patches Modified Files: -------------- pg/macros: PGgraders.pl Revision Data ------------- Index: PGgraders.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGgraders.pl,v retrieving revision 1.1.18.1 retrieving revision 1.1.18.1.2.1 diff -Lmacros/PGgraders.pl -Lmacros/PGgraders.pl -u -r1.1.18.1 -r1.1.18.1.2.1 --- macros/PGgraders.pl +++ macros/PGgraders.pl @@ -7,7 +7,10 @@ =head3 full_partial_grader +=pod + ########################################################### +# full_partial_grader # If the final answer is correct, then the problem is given full credit # and a message is generated to that effect. Otherwise, partial credit # is given for previous parts. @@ -66,7 +69,11 @@ =head3 custom_problem_grader_0_60_100(@rh_evaluated_answers,$rh_problem_state,%form_options) +=pod + ################################################################ +# custom_problem_grader_0_60_100 +# # We need a special problem grader on this problem, since we # want the student to get full credit for all five answers correct, # 60% credit for four correct, and 0% for three or fewer correct. @@ -164,8 +171,11 @@ =head3 NOTE: +=pod + ################################################################ -# This problem grader was contributed by Prof. Zig Fiedorowicz, +# This problem grader custom_problem_grader_fluid +# was contributed by Prof. Zig Fiedorowicz, # Dept. of Mathematics, Ohio State University on 8/25/01. # As written, the problem grader should be put in a separate macro file. # If actually inserted into a problem, you need to replace a couple |
From: Mike G. v. a. <we...@ma...> - 2009-10-04 17:58:51
|
Log Message: ----------- edited some pod documentation Modified Files: -------------- pg/macros: PGgraders.pl Revision Data ------------- Index: PGgraders.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGgraders.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/PGgraders.pl -Lmacros/PGgraders.pl -u -r1.2 -r1.3 --- macros/PGgraders.pl +++ macros/PGgraders.pl @@ -7,7 +7,10 @@ =head3 full_partial_grader +=pod + ########################################################### +# full_partial_grader # If the final answer is correct, then the problem is given full credit # and a message is generated to that effect. Otherwise, partial credit # is given for previous parts. @@ -66,7 +69,11 @@ =head3 custom_problem_grader_0_60_100(@rh_evaluated_answers,$rh_problem_state,%form_options) +=pod + ################################################################ +# custom_problem_grader_0_60_100 +# # We need a special problem grader on this problem, since we # want the student to get full credit for all five answers correct, # 60% credit for four correct, and 0% for three or fewer correct. @@ -164,8 +171,11 @@ =head3 NOTE: +=pod + ################################################################ -# This problem grader was contributed by Prof. Zig Fiedorowicz, +# This problem grader custom_problem_grader_fluid +# was contributed by Prof. Zig Fiedorowicz, # Dept. of Mathematics, Ohio State University on 8/25/01. # As written, the problem grader should be put in a separate macro file. # If actually inserted into a problem, you need to replace a couple |
From: Mike G. v. a. <we...@ma...> - 2009-10-03 21:57:28
|
Log Message: ----------- remove error message Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: locallib.php Revision Data ------------- Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.13 retrieving revision 1.14 diff -Lwwassignment4/moodle/mod/wwassignment/locallib.php -Lwwassignment4/moodle/mod/wwassignment/locallib.php -u -r1.13 -r1.14 --- wwassignment4/moodle/mod/wwassignment/locallib.php +++ wwassignment4/moodle/mod/wwassignment/locallib.php @@ -83,7 +83,7 @@ function _wwassignment_create_events($wwassignment,$wwsetdata ) { error_log("enter create_events for set ".$wwassignment->name." id ".$wwassignment->id." date ".$wwsetdata['open_date']." ".$wwsetdata['due_date'] ); global $COURSE; - error_log("set data".print_r($wwsetdata,true)); + //error_log("set data".print_r($wwsetdata,true)); if (! $opendate = $wwsetdata['open_date'] ) { error_log(" undefined open date "); } |
From: Mike G. v. a. <we...@ma...> - 2009-10-03 20:32:03
|
Log Message: ----------- Changed set name on calendar to moodle name instead of webwork name Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php locallib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.14 retrieving revision 1.15 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.14 -r1.15 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -59,9 +59,8 @@ //Get data about the set from WebWorK $wwclient = new wwassignment_client(); - $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); - $wwsetname = $wwassignment->webwork_set; - $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + $wwassignment->webwork_course = _wwassignment_mapped_course($COURSE->id,false); + $wwsetdata = $wwclient->get_assignment_data($wwassignment->webwork_course,$wwassignment->webwork_set,false); @@ -74,7 +73,7 @@ $wwassignment->id = $returnid; //Creating events - _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date']); + _wwassignment_create_events($wwassignment,$wwsetdata); debugLog("notify gradebook"); //notify gradebook wwassignment_grade_item_update($wwassignment); @@ -98,9 +97,13 @@ //checking mappings $wwclient = new wwassignment_client(); $wwcoursename = _wwassignment_mapped_course($COURSE->id,false); + $wwassignment->webwork_course = $wwcoursename; $wwsetname = $wwassignment->webwork_set; + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + //get data from WeBWorK + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); $wwassignment->id = $wwassignment->instance; $wwassignment->grade = $wwclient->get_max_grade($wwcoursename,$wwsetname,false); @@ -108,7 +111,7 @@ $returnid = update_record('wwassignment',$wwassignment); _wwassignment_delete_events($wwassignment->id); - _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date']); + _wwassignment_create_events($wwassignment,$wwsetdata); //notify gradebook -- update grades for this wwassignment only wwassignment_grade_item_update($wwassignment); @@ -175,34 +178,7 @@ * @param int $userid optional user id, 0 means all users * @return array array of grades, false if none */ -// function assignment_get_user_grades($assignment, $userid=0) { -// global $CFG; -// -// $user = $userid ? "AND u.id = $userid" : ""; -// -// $sql = "SELECT u.id, u.id AS userid, s.grade AS rawgrade, s.submissioncomment AS feedback, s.format AS feedbackformat, -// s.teacher AS usermodified, s.timemarked AS dategraded, s.timemodified AS datesubmitted -// FROM {$CFG->prefix}user u, {$CFG->prefix}assignment_submissions s -// WHERE u.id = s.userid AND s.assignment = $assignment->id -// $user"; -// -// return get_records_sql($sql); -// } -// object returned looks like an array of standard objects -// ( -// [22] => stdClass Object -// ( -// [userid] => 22 -// [rawgrade] => -1 -// [feedback] => 23 -// [feedbackformat] => 0 -// [usermodified] => 2 -// [dategraded] => 1211200838 -// [datesubmitted] => 1211199392 -// [id] => 22 -// ) -// -// ) + function wwassignment_get_user_grades($wwassignment,$userid=0) { debugLog("Begin wwassignment_get_user_grades"); @@ -620,90 +596,10 @@ return _wwassignment_get_course_students( $wwassignment->course ); } -// function assignment_refresh_events($courseid = 0) { -// -// if ($courseid == 0) { -// if (! $assignments = get_records("assignment")) { -// return true; -// } -// } else { -// if (! $assignments = get_records("assignment", "course", $courseid)) { -// return true; -// } -// } -// $moduleid = get_field('modules', 'id', 'name', 'assignment'); -// -// foreach ($assignments as $assignment) { -// $event = NULL; -// $event->name = addslashes($assignment->name); -// $event->description = addslashes($assignment->description); -// $event->timestart = $assignment->timedue; -// -// if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) { -// update_event($event); -// -// } else { -// $event->courseid = $assignment->course; -// $event->groupid = 0; -// $event->userid = 0; -// $event->modulename = 'assignment'; -// $event->instance = $assignment->id; -// $event->eventtype = 'due'; -// $event->timeduration = 0; -// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $assignment->id); -// add_event($event); -// } -// -// } -// return true; -// } -// - -// function chat_refresh_events($courseid = 0) { -// // This standard function will check all instances of this module -// // and make sure there are up-to-date events created for each of them. -// // If courseid = 0, then every chat event in the site is checked, else -// // only chat events belonging to the course specified are checked. -// // This function is used, in its new format, by restore_refresh_events() -// -// if ($courseid) { -// if (! $chats = get_records("chat", "course", $courseid)) { -// return true; -// } -// } else { -// if (! $chats = get_records("chat")) { -// return true; -// } -// } -// $moduleid = get_field('modules', 'id', 'name', 'chat'); -// -// foreach ($chats as $chat) { -// $event = NULL; -// $event->name = addslashes($chat->name); -// $event->description = addslashes($chat->intro); -// $event->timestart = $chat->chattime; -// -// if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) { -// update_event($event); -// -// } else { -// $event->courseid = $chat->course; -// $event->groupid = 0; -// $event->userid = 0; -// $event->modulename = 'chat'; -// $event->instance = $chat->id; -// $event->eventtype = $chat->schedule; -// $event->timeduration = 0; -// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id); -// -// add_event($event); -// } -// } -// return true; -// } function wwassignment_refresh_events($courseid = 0) { error_log('wwassignment_refresh_events called --not yet defined'); + // This standard function will check all instances of this module // and make sure there are up-to-date events created for each of them. // If courseid = 0, then every wwassignment event in the site is checked, else @@ -744,6 +640,7 @@ foreach ($cids as $cid) { // connect to WeBWorK $wwcoursename = _wwassignment_mapped_course($cid,false); + $wwassignment->webwork_course = $wwcoursename; if ( $wwcoursename== -1) { error_log("Can't connect course $cid to webwork"); break; @@ -761,10 +658,12 @@ // update event //this part won't work because these items implicitly require the course. _wwassignment_delete_events($wwassignment->id); - _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date'],$cid); + _wwassignment_create_events($wwassignment, $wwsetdata); } } + + return true; } Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.12 retrieving revision 1.13 diff -Lwwassignment4/moodle/mod/wwassignment/locallib.php -Lwwassignment4/moodle/mod/wwassignment/locallib.php -u -r1.12 -r1.13 --- wwassignment4/moodle/mod/wwassignment/locallib.php +++ wwassignment4/moodle/mod/wwassignment/locallib.php @@ -79,14 +79,32 @@ * @param $duedate integer The UNIX timestamp of the due date. * @return integer 0 on success. -1 on error. */ -function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate, $courseid=0) { - error_log("enter create_events for set $wwsetname id $wwassignmentid date $opendate $duedate course $courseid"); + +function _wwassignment_create_events($wwassignment,$wwsetdata ) { + error_log("enter create_events for set ".$wwassignment->name." id ".$wwassignment->id." date ".$wwsetdata['open_date']." ".$wwsetdata['due_date'] ); global $COURSE; + error_log("set data".print_r($wwsetdata,true)); + if (! $opendate = $wwsetdata['open_date'] ) { + error_log(" undefined open date "); + } + if (! $duedate = $wwsetdata["due_date"] ){ + error_log(" undefined due date "); + } + if (! $wwassignmentid = $wwassignment->id ) { + error_log(" undefined ww id "); + } + if (! $name = $wwassignment->name ) { + error_log(" undefined set name "); + } + $courseid = $wwassignment->course; + if (!courseid) { $courseid =$COURSE->id; } + + unset($event); - $event->name = addslashes($wwsetname); + $event->name = addslashes($name); $event->description = 'WeBWorK Set Event'; $event->courseid = $courseid; $event->groupid = 0; @@ -95,7 +113,6 @@ $event->modulename = 'wwassignment'; $event->instance = $wwassignmentid; $event->visible = 1; - $event->name .= ' is Due.'; $event->eventtype = 'due'; $event->timestart = $duedate; $event->timeduration = 1; @@ -126,48 +143,10 @@ } return 0; } -// function chat_refresh_events($courseid = 0) { -// // This standard function will check all instances of this module -// // and make sure there are up-to-date events created for each of them. -// // If courseid = 0, then every chat event in the site is checked, else -// // only chat events belonging to the course specified are checked. -// // This function is used, in its new format, by restore_refresh_events() -// -// if ($courseid) { -// if (! $chats = get_records("chat", "course", $courseid)) { -// return true; -// } -// } else { -// if (! $chats = get_records("chat")) { -// return true; -// } -// } -// $moduleid = get_field('modules', 'id', 'name', 'chat'); -// -// foreach ($chats as $chat) { -// $event = NULL; -// $event->name = addslashes($chat->name); -// $event->description = addslashes($chat->intro); -// $event->timestart = $chat->chattime; -// -// if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) { -// update_event($event); -// -// } else { -// $event->courseid = $chat->course; -// $event->groupid = 0; -// $event->userid = 0; -// $event->modulename = 'chat'; -// $event->instance = $chat->id; -// $event->eventtype = $chat->schedule; -// $event->timeduration = 0; -// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id); -// -// add_event($event); -// } -// } -// return true; -// } + + + + function _wwassignment_refresh_event($wwassignment) { $cid = $wwassignment->course; $wwcoursename = _wwassignment_mapped_course($cid,false); @@ -185,10 +164,11 @@ $returnid = update_record('wwassignment',$wwassignment); // update event _wwassignment_delete_events($wwassignment->id); - _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date'],$cid); + _wwassignment_create_events($wwassignment,$wwsetdata); return true; } + ////////////////////////////////////////////////////////////////// //Functions that ensure creation of WeBWorK Data ////////////////////////////////////////////////////////////////// |
From: Mike G. v. a. <we...@ma...> - 2009-10-03 18:00:41
|
Log Message: ----------- Added functions that refresh calendar events for the course. Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php locallib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.13 retrieving revision 1.14 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.13 -r1.14 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -522,12 +522,26 @@ //wwassignment_update_grades(null,0); //try { // try didn't work on some php systems -- leave it out. wwassignment_update_dirty_sets(); - //} catch (Exception $e) { - //error_log("\n Unable to run wwassignment_update_dirty_sets ".$e->getMessage()); - //} error_log("End wwassignment_cron"); return true; } + + +// reference material for improving update dirty sets: +// from wiki/lib /print_recent_activity +// $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l +// INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id +// WHERE l.time > '$timestart' AND l.course = {$course->id} +// AND l.module = 'wiki' AND action LIKE 'edit%' +// ORDER BY l.time ASC"; +// +// if (!$logs = get_records_sql($sql)){ +// return false; +// } +// +// $modinfo = get_fast_modinfo($course); +// + function wwassignment_update_dirty_sets() { // update grades for all instances which have been modified since last cronjob global $CFG; $timenow = time(); @@ -575,6 +589,9 @@ } else { wwassignment_grade_item_update($wwassignment); } + // refresh events for this assignment + _wwassignment_refresh_event($wwassignment); + } else { error_log("no update needed. timemodified ".$wwassignment->timemodified. ", lastcron $lastcron, course id ".$wwassignment->course.", wwassignment id ".$wwassignment->id. @@ -603,8 +620,151 @@ return _wwassignment_get_course_students( $wwassignment->course ); } +// function assignment_refresh_events($courseid = 0) { +// +// if ($courseid == 0) { +// if (! $assignments = get_records("assignment")) { +// return true; +// } +// } else { +// if (! $assignments = get_records("assignment", "course", $courseid)) { +// return true; +// } +// } +// $moduleid = get_field('modules', 'id', 'name', 'assignment'); +// +// foreach ($assignments as $assignment) { +// $event = NULL; +// $event->name = addslashes($assignment->name); +// $event->description = addslashes($assignment->description); +// $event->timestart = $assignment->timedue; +// +// if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) { +// update_event($event); +// +// } else { +// $event->courseid = $assignment->course; +// $event->groupid = 0; +// $event->userid = 0; +// $event->modulename = 'assignment'; +// $event->instance = $assignment->id; +// $event->eventtype = 'due'; +// $event->timeduration = 0; +// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $assignment->id); +// add_event($event); +// } +// +// } +// return true; +// } +// + +// function chat_refresh_events($courseid = 0) { +// // This standard function will check all instances of this module +// // and make sure there are up-to-date events created for each of them. +// // If courseid = 0, then every chat event in the site is checked, else +// // only chat events belonging to the course specified are checked. +// // This function is used, in its new format, by restore_refresh_events() +// +// if ($courseid) { +// if (! $chats = get_records("chat", "course", $courseid)) { +// return true; +// } +// } else { +// if (! $chats = get_records("chat")) { +// return true; +// } +// } +// $moduleid = get_field('modules', 'id', 'name', 'chat'); +// +// foreach ($chats as $chat) { +// $event = NULL; +// $event->name = addslashes($chat->name); +// $event->description = addslashes($chat->intro); +// $event->timestart = $chat->chattime; +// +// if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) { +// update_event($event); +// +// } else { +// $event->courseid = $chat->course; +// $event->groupid = 0; +// $event->userid = 0; +// $event->modulename = 'chat'; +// $event->instance = $chat->id; +// $event->eventtype = $chat->schedule; +// $event->timeduration = 0; +// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id); +// +// add_event($event); +// } +// } +// return true; +// } + function wwassignment_refresh_events($courseid = 0) { error_log('wwassignment_refresh_events called --not yet defined'); +// This standard function will check all instances of this module +// and make sure there are up-to-date events created for each of them. +// If courseid = 0, then every wwassignment event in the site is checked, else +// only wwassignment events belonging to the course specified are checked. +// This function is used, in its new format, by restore_refresh_events() and by the cron function +// + // find wwassignment instances associated with this course or all wwassignment modules + $courses = array(); # create array of courses + if ($courseid) { + if (! $wwassignments = get_records("wwassignment", "course", $courseid)) { + return true; + } else { + $courses[$courseid]= array(); // collect wwassignments for this course + array_push( $courses[$courseid], $wwassignments ); + } + } else { + if (! $wwassignments = get_records("wwassignment")) { + return true; + } else { + foreach ($wwassignments as $ww ) { + // collect wwassignments for each course + error_log("course id ".$ww->course); + if (! ($courses[$ww->course] ) ) { + $courses[$ww->course] = array(); + } + array_push($courses[$ww->course], $ww) ; // push wwassignment onto an exisiting one + } + } + + } + + + // $courses now holds a list of courses with wwassignment modules + $moduleid = _wwassignment_cmid(); + $cids = array_keys($courses); # collect course ids + error_log("cids".print_r($cids, true)); + $wwclient = new wwassignment_client(); + foreach ($cids as $cid) { + // connect to WeBWorK + $wwcoursename = _wwassignment_mapped_course($cid,false); + if ( $wwcoursename== -1) { + error_log("Can't connect course $cid to webwork"); + break; + } + // retrieve wwassignments associated with this course + foreach($courses[$cid] as $wwassignment ) { + //checking mappings + $wwsetname = $wwassignment->webwork_set; + error_log("updating events for $wwcoursename $wwsetname"); + //get data from WeBWorK + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + $wwassignment->grade = $wwclient->get_max_grade($wwcoursename,$wwsetname,false); + $wwassignment->timemodified = time(); + $returnid = update_record('wwassignment',$wwassignment); + // update event + //this part won't work because these items implicitly require the course. + _wwassignment_delete_events($wwassignment->id); + _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date'],$cid); + } + + } return true; } Index: locallib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/locallib.php,v retrieving revision 1.11 retrieving revision 1.12 diff -Lwwassignment4/moodle/mod/wwassignment/locallib.php -Lwwassignment4/moodle/mod/wwassignment/locallib.php -u -r1.11 -r1.12 --- wwassignment4/moodle/mod/wwassignment/locallib.php +++ wwassignment4/moodle/mod/wwassignment/locallib.php @@ -79,13 +79,16 @@ * @param $duedate integer The UNIX timestamp of the due date. * @return integer 0 on success. -1 on error. */ -function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate) { - error_log("enter create_events"); +function _wwassignment_create_events($wwsetname,$wwassignmentid,$opendate,$duedate, $courseid=0) { + error_log("enter create_events for set $wwsetname id $wwassignmentid date $opendate $duedate course $courseid"); global $COURSE; + if (!courseid) { + $courseid =$COURSE->id; + } unset($event); - $event->name = $wwsetname; + $event->name = addslashes($wwsetname); $event->description = 'WeBWorK Set Event'; - $event->courseid = $COURSE->id; + $event->courseid = $courseid; $event->groupid = 0; $event->userid = 0; $event->format = 1; @@ -99,7 +102,10 @@ // error_log("adding a due event"); $result = 0; - if(!add_event($event)) { + $calendareventid = add_event($event); + error_log("calendareventid $calendareventid created"); + if(!$calendareventid) { + error_log("can't create calendarevent for set $wwsetname wwid $wwassignmentid date $opendate $duedate course $courseid"); $result = -1; } return $result; @@ -120,6 +126,68 @@ } return 0; } +// function chat_refresh_events($courseid = 0) { +// // This standard function will check all instances of this module +// // and make sure there are up-to-date events created for each of them. +// // If courseid = 0, then every chat event in the site is checked, else +// // only chat events belonging to the course specified are checked. +// // This function is used, in its new format, by restore_refresh_events() +// +// if ($courseid) { +// if (! $chats = get_records("chat", "course", $courseid)) { +// return true; +// } +// } else { +// if (! $chats = get_records("chat")) { +// return true; +// } +// } +// $moduleid = get_field('modules', 'id', 'name', 'chat'); +// +// foreach ($chats as $chat) { +// $event = NULL; +// $event->name = addslashes($chat->name); +// $event->description = addslashes($chat->intro); +// $event->timestart = $chat->chattime; +// +// if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) { +// update_event($event); +// +// } else { +// $event->courseid = $chat->course; +// $event->groupid = 0; +// $event->userid = 0; +// $event->modulename = 'chat'; +// $event->instance = $chat->id; +// $event->eventtype = $chat->schedule; +// $event->timeduration = 0; +// $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $chat->id); +// +// add_event($event); +// } +// } +// return true; +// } +function _wwassignment_refresh_event($wwassignment) { + $cid = $wwassignment->course; + $wwcoursename = _wwassignment_mapped_course($cid,false); + if ( $wwcoursename== -1) { + error_log("Can't connect course $cid to webwork"); + return false; + } + $wwclient = new wwassignment_client(); + $wwsetname = $wwassignment->webwork_set; + error_log("updating events for $wwcoursename $wwsetname"); + //get data from WeBWorK + $wwsetdata = $wwclient->get_assignment_data($wwcoursename,$wwsetname,false); + $wwassignment->grade = $wwclient->get_max_grade($wwcoursename,$wwsetname,false); + $wwassignment->timemodified = time(); + $returnid = update_record('wwassignment',$wwassignment); + // update event + _wwassignment_delete_events($wwassignment->id); + _wwassignment_create_events($wwsetname,$wwassignment->id,$wwsetdata['open_date'],$wwsetdata['due_date'],$cid); + return true; +} ////////////////////////////////////////////////////////////////// //Functions that ensure creation of WeBWorK Data @@ -208,15 +276,9 @@ //error_log("config_data ".print_r($block_config,true)); if ( isset($block_config) && isset($block_config->webwork_link_id) ) { return $block_config->webwork_link_id; + } else { + return -1; } -// $wwassignmentbridge = get_record('wwassignment_bridge','course', $courseid); -// if((isset($wwassignmentbridge)) && (isset($wwassignmentbridge->webwork_course))) { -// return $wwassignmentbridge->webwork_course; -// } -// if(!$silent) { -// print_error('webwork_course_map_failure','wwassignment'); -// } - return -1; } /** |
From: dpvc v. a. <we...@ma...> - 2009-10-03 16:57:22
|
Log Message: ----------- Handle formula 'constants' properly Modified Files: -------------- pg/lib/Parser: Differentiation.pm Revision Data ------------- Index: Differentiation.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Differentiation.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -Llib/Parser/Differentiation.pm -Llib/Parser/Differentiation.pm -u -r1.15 -r1.16 --- lib/Parser/Differentiation.pm +++ lib/Parser/Differentiation.pm @@ -628,7 +628,8 @@ ######################################################################### sub Parser::Constant::D { - my $self = shift; + my $self = shift; my $x = shift; + return $self->{def}{value}{tree}->D($x) if Value::isFormula($self->{def}{value}); $self->Item("Number")->new($self->{equation},0); } |
From: dpvc v. a. <we...@ma...> - 2009-10-03 16:56:43
|
Log Message: ----------- Handle variables in formula 'constants' properly Modified Files: -------------- pg/lib/Parser: Constant.pm Revision Data ------------- Index: Constant.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Constant.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -Llib/Parser/Constant.pm -Llib/Parser/Constant.pm -u -r1.16 -r1.17 --- lib/Parser/Constant.pm +++ lib/Parser/Constant.pm @@ -25,6 +25,8 @@ }, $class; $c->weaken; $c->{isConstant} = 1 if $const->{isConstant}; + $equation->{variables} = {%{$equation->{variables}},%{$const->{value}{variables}}} + if Value::isFormula($const->{value}); return $c; } @@ -60,6 +62,15 @@ } # +# Include variables from constant formulas +# +sub getVariables { + my $self = shift; my $data = $self->{def}{value}; + return {} unless Value::isFormula($data); + return $data->{tree}->getVariables; +} + +# # Return the constant's name # sub string { |
From: dpvc v. a. <we...@ma...> - 2009-10-03 16:56:17
|
Log Message: ----------- Reduction rule should be off by default Modified Files: -------------- pg/macros: parserPrime.pl Revision Data ------------- Index: parserPrime.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserPrime.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/parserPrime.pl -Lmacros/parserPrime.pl -u -r1.2 -r1.3 --- macros/parserPrime.pl +++ macros/parserPrime.pl @@ -126,7 +126,7 @@ precedence => 8.5, associativity => "right", type => "unary", string => "'", class => "parser::Prime::UOP::prime", isCommand => 1 }); - $context->reduction->set("(f)'" => 1); + $context->reduction->set("(f)'" => 0); $context->flags->set(prime_variable => $x) if defined($x); } |
From: dpvc v. a. <we...@ma...> - 2009-10-03 16:15:22
|
Log Message: ----------- Accidentally had left 'prime' as Modified Files: -------------- pg/macros: parserPrime.pl Revision Data ------------- Index: parserPrime.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserPrime.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/parserPrime.pl -Lmacros/parserPrime.pl -u -r1.1 -r1.2 --- macros/parserPrime.pl +++ macros/parserPrime.pl @@ -122,7 +122,7 @@ my $self = shift; my $x = shift; my $context = main::Context(); if (Value::isContext($x)) {$context = $x; $x = shift} - $context->operators->add("`"=>{ + $context->operators->add("'"=>{ precedence => 8.5, associativity => "right", type => "unary", string => "'", class => "parser::Prime::UOP::prime", isCommand => 1 }); |
From: dpvc v. a. <we...@ma...> - 2009-10-02 18:01:24
|
Log Message: ----------- New MathObject to implement differentiation via prime operator Added Files: ----------- pg/macros: parserPrime.pl Revision Data ------------- --- /dev/null +++ macros/parserPrime.pl @@ -0,0 +1,216 @@ +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2009 The WeBWorK Project, http://openwebwork.sf.net/ +# $CVSHeader: pg/macros/parserPrime.pl,v 1.1 2009/10/02 17:44:54 dpvc Exp $ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +=head1 NAME + +parserPrime.pl - defines a prime operator (') to perform differentiation + (can be used in student answers as well). + +=head1 DESCRIPTION + +This file defines the code necessary to make the prime (') operator perform +differentiation within a Formula object. For example, Formula("(x^2)'") would +equal Formula("2*x"), and Formula("(x^2)''") would equal Real(2). The context +also includes reduction rules to replace the prime notaiton by the actual +derivative. + +To accomplish this, put the line + + loadMacros("parserPrime.pl"); + +at the beginning of your problem file, then set the Context to the one you wish +to use in the problem. Then use the command: + + parser::Prime->Enable; + +(You can also pass the Enable command a context pointer if you wish to +alter a context other than the current one.) + +Once this is done, you will be able to enter primes in your Formulas +to refer to differentiation. For example: + + Formula("(3x^2+2x+1)'") + +would mean the derivative of 3x^2+2x+1 and would be equivalent to + + Formula("3*2*x+2") + +The variable of differentiation is taken from the variables used in +the formula being differentiated. If there is more than one variable +used, the first one alphabetically is used. For example + + Formula("(ln(x))' + (x^2+3y)'") + +would produce the equivalent to + + Formula("(1/x) + (2*x+0)"). + +This can have unexpected results, however, since. + + Formula("(x^2)' + (y^2)'") + +would generate + + Formula("2*x + 2*y") + +which may not be what you want. In order to specify the variable for +differentiation, you can list it in the Enable() call. For example: + + parser::Prime->Enable("x"); + +would make + + Formula("(x^2)' + (y^2)'") + +generate + + Formula("2*x + 0") + +rather than the default 2x+2y. + +The prime operator also defines a reduction rule that allows the prime +notation to be replaced by the actual derivative when the Formula is +reduced. This is off by default, but you can set it via + + Context()->reduction->set("(f)'"=>1); + +so that it will be on for all reductions, or specify it for a single +reduction as follows: + + $f = Formula("(x^2)'")->reduce("(f)'"=>1); + +to obtain $f as Formula("2*x"). + +Note that once the prime has been added to the Context, student +answers will be allowed to include primes as well, so if you want +students to actually perform the differentiation themselves, you may +wish to disable the prime at the end of the problem (so it will not be +active while student answers are being parsed). To do that use + + parser::Prime->Disable; + +(You can pass Disable a context pointer to remove the prime operator +from a context other than the current one.) + +=cut + +sub _parserPrime_init {}; # don't load a second time + +########################################## +# +# Package to enable and disable the prime operator +# +package parser::Prime; + +# +# Add prime to the given or current context +# +sub Enable { + my $self = shift; my $x = shift; + my $context = main::Context(); + if (Value::isContext($x)) {$context = $x; $x = shift} + $context->operators->add("`"=>{ + precedence => 8.5, associativity => "right", type => "unary", string => "'", + class => "parser::Prime::UOP::prime", isCommand => 1 + }); + $context->reduction->set("(f)'" => 1); + $context->flags->set(prime_variable => $x) if defined($x); +} + +# +# Remove prime from the context +# +sub Disable { + my $self = shift; my $context = shift || main::Context(); + $context->operators->remove("'"); +} + +########################################## +# +# Prime operator is a subclass of the unary operator class +# +package parser::Prime::UOP::prime; +our @ISA = ('Parser::UOP'); + +# +# Do a typecheck on the operand +# +sub _check { + my $self = shift; + return if $self->checkInfinite || $self->checkString || + $self->checkList || $self->checkNumber; + $self->{type} = {%{$self->{op}->typeRef}}; +} + +# +# A hack to prevent double-primes from inserting parentheses +# in string and TeX output (change the precedence to hide it) +# +sub string { + my ($self,$precedence,$showparens,$position,$outerRight) = @_; + my $uop = $self->{def}; $precedence -= .01 if $uop->{precedence} == $precedence; + return $self->SUPER::string($precedence,$showparens,$position,$outerRight); +} +sub TeX { + my ($self,$precedence,$showparens,$position,$outerRight) = @_; + my $uop = $self->{def}; $precedence -= .01 if $uop->{precedence} == $precedence; + return $self->SUPER::TeX($precedence,$showparens,$position,$outerRight); +} + +# +# Produce a perl version of the derivative +# +sub perl { + my $self = shift; + return $self->{op}->D($self->getVar)->perl; +} + +# +# Evaluate the derivative +# +sub eval { + my $self = shift; + return $self->{op}->D($self->getVar)->eval; +} + +# +# Reduce by replacing with derivative +# +sub reduce { + my $self = shift; + return $self unless $self->context->{reduction}{"(f)'"}; + return $self->{op}->D($self->getVar); +} + +sub getVar { + my $self = shift; + return $self->context->flag("prime_variable") || + (keys(%{$self->getVariables}))[0] || + (keys(%{$self->{equation}{variables}}))[0] || 'x'; +} + + +# +# Handle derivative by taking derivative of a prime by taking +# derivative of the prime's value (which is itself a derivative) +# +sub D { + my $self = shift; my $x = shift; + return $self->{op}->D($x)->D($x); +} + +1; + |
From: Mike G. v. a. <we...@ma...> - 2009-10-02 11:42:04
|
Log Message: ----------- near final version of grade updating process. This has only two database accesses per update and should be fairly fast. It still puts a number of "reassuring" comments in the error log to let you know what it is doing. We'll take these out later. Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.12 retrieving revision 1.13 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.12 -r1.13 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -533,35 +533,43 @@ $timenow = time(); $lastcron = get_field("modules","lastcron","name","wwassignment"); error_log ("lastcron is $lastcron and time now is $timenow"); - $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid, cm.id as wwinstanceid - FROM {$CFG->prefix}wwassignment a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m - WHERE m.name='wwassignment' AND m.id=cm.module AND cm.instance=a.id"; - + //error_log ("sql string = $sql"); // Could we speed this up by getting all of the log records pertaining to webwork in one go? // Or perhaps just the log records which have occured after the lastcron date // Then create a hash with wwassignment->id => timemodified // means just one database lookup + $logRecords = get_logs("l.module LIKE \"wwassignment\" AND l.time >$lastcron ", "l.time ASC"); $wwmodificationtime=array(); foreach ($logRecords as $record) { - $wwid =$record->info; - $wwmodificationtime["$wwid"] = $record->time; + $wwmodtimes[$wwid =$record->info] = $record->time; } - error_log("last modification times".print_r($wwmodificationtime,true)); + + // Create an array with the wwid values + $idValues= "( ".implode(",", array_keys($wwmodtimes) ). " )"; + + //error_log("values string $idValues"); + //error_log("last modification times".print_r($wwmodtimes,true)); + + $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid, cm.id as wwinstanceid + FROM {$CFG->prefix}wwassignment a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m + WHERE m.name='wwassignment' AND m.id=cm.module AND cm.instance=a.id AND a.id IN $idValues"; + + $sql3 = "SELECT a.* FROM {$CFG->prefix}wwassignment a WHERE a.id IN $idValues"; + + //error_log("last modification times".print_r($wwmodificationtime,true)); if ($rs = get_recordset_sql($sql)) { while ($wwassignment = rs_fetch_next_record($rs)) { if (!$wwassignment->cmidnumber) { // is this ever needed? $wwassignment->cmidnumber =_wwassignment_cmid() ; } - //$logdata = get_logs("l.info = $wwassignment->id"); # the instance number of this assignment is stored in info - //$most_recent_record = array_shift($logdata); - $wwassignment->timemodified = $wwmodificationtime[$wwassignment->id]; + $wwassignment->timemodified = $wwmodtimes[$wwassignment->id]; if ($wwassignment->timemodified > $lastcron) { error_log("instance needs update. timemodified ".$wwassignment->timemodified. - " lastcron $lastcron course id".$wwassignment->course." wwassignment id ".$wwassignment->id." wwinstance id".$wwassignment->wwinstanceid. - " set name ".$wwassignment->name); + ", lastcron $lastcron, course id ".$wwassignment->course.", wwassignment id ".$wwassignment->id. + ", set name ".$wwassignment->name.", cm.id ".$wwassignment->wwinstanceid); if ($wwassignment->grade != 0) { wwassignment_update_grades($wwassignment); } else { @@ -569,8 +577,8 @@ } } else { error_log("no update needed. timemodified ".$wwassignment->timemodified. - " lastcron $lastcron course id".$wwassignment->course." wwassignment id ".$wwassignment->id." wwinstance id".$wwassignment->wwinstanceid. - " set name ".$wwassignment->name); + ", lastcron $lastcron, course id ".$wwassignment->course.", wwassignment id ".$wwassignment->id. + ", set name ".$wwassignment->name.", cm.id ".$wwassignment->wwinstanceid); } } |
From: Mike G. v. a. <we...@ma...> - 2009-10-02 02:40:39
|
Log Message: ----------- only look at log records after the lastcron date Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.11 retrieving revision 1.12 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.11 -r1.12 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -542,7 +542,7 @@ // Or perhaps just the log records which have occured after the lastcron date // Then create a hash with wwassignment->id => timemodified // means just one database lookup - $logRecords = get_logs("l.module LIKE \"wwassignment\" ", "l.time ASC"); + $logRecords = get_logs("l.module LIKE \"wwassignment\" AND l.time >$lastcron ", "l.time ASC"); $wwmodificationtime=array(); foreach ($logRecords as $record) { $wwid =$record->info; @@ -550,7 +550,6 @@ } error_log("last modification times".print_r($wwmodificationtime,true)); - if ($rs = get_recordset_sql($sql)) { while ($wwassignment = rs_fetch_next_record($rs)) { if (!$wwassignment->cmidnumber) { // is this ever needed? |
From: Mike G. v. a. <we...@ma...> - 2009-10-02 02:27:21
|
Log Message: ----------- This is method only requires one database lookup to the log table per update Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.10 retrieving revision 1.11 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.10 -r1.11 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -538,14 +538,27 @@ WHERE m.name='wwassignment' AND m.id=cm.module AND cm.instance=a.id"; //error_log ("sql string = $sql"); + // Could we speed this up by getting all of the log records pertaining to webwork in one go? + // Or perhaps just the log records which have occured after the lastcron date + // Then create a hash with wwassignment->id => timemodified + // means just one database lookup + $logRecords = get_logs("l.module LIKE \"wwassignment\" ", "l.time ASC"); + $wwmodificationtime=array(); + foreach ($logRecords as $record) { + $wwid =$record->info; + $wwmodificationtime["$wwid"] = $record->time; + } + error_log("last modification times".print_r($wwmodificationtime,true)); + + if ($rs = get_recordset_sql($sql)) { while ($wwassignment = rs_fetch_next_record($rs)) { if (!$wwassignment->cmidnumber) { // is this ever needed? $wwassignment->cmidnumber =_wwassignment_cmid() ; } - $logdata = get_logs("l.info = $wwassignment->id"); # the instance number of this assignment is stored in info - $most_recent_record = array_shift($logdata); - $wwassignment->timemodified = $most_recent_record->time; + //$logdata = get_logs("l.info = $wwassignment->id"); # the instance number of this assignment is stored in info + //$most_recent_record = array_shift($logdata); + $wwassignment->timemodified = $wwmodificationtime[$wwassignment->id]; if ($wwassignment->timemodified > $lastcron) { error_log("instance needs update. timemodified ".$wwassignment->timemodified. " lastcron $lastcron course id".$wwassignment->course." wwassignment id ".$wwassignment->id." wwinstance id".$wwassignment->wwinstanceid. |
From: Mike G. v. a. <we...@ma...> - 2009-10-02 00:10:38
|
Log Message: ----------- Correct the matching of the log info with the other data improve the error log messages Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.9 retrieving revision 1.10 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.9 -r1.10 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -543,18 +543,22 @@ if (!$wwassignment->cmidnumber) { // is this ever needed? $wwassignment->cmidnumber =_wwassignment_cmid() ; } - $logdata = get_logs("l.info = $wwassignment->wwinstanceid"); # the instance number of this assignment is stored in info + $logdata = get_logs("l.info = $wwassignment->id"); # the instance number of this assignment is stored in info $most_recent_record = array_shift($logdata); $wwassignment->timemodified = $most_recent_record->time; if ($wwassignment->timemodified > $lastcron) { - error_log("instance needs update. timemodified ".$wwassignment->timemodified." lastcron $lastcron wwassignment instance id ".$wwassignment->id." set name ".$wwassignment->webwork_set); + error_log("instance needs update. timemodified ".$wwassignment->timemodified. + " lastcron $lastcron course id".$wwassignment->course." wwassignment id ".$wwassignment->id." wwinstance id".$wwassignment->wwinstanceid. + " set name ".$wwassignment->name); if ($wwassignment->grade != 0) { wwassignment_update_grades($wwassignment); } else { wwassignment_grade_item_update($wwassignment); } } else { - error_log("no update needed. timemodified ".$wwassignment->timemodified." lastcron $lastcron wwassignment instance id ".$wwassignment->id." set name ".$wwassignment->webwork_set); + error_log("no update needed. timemodified ".$wwassignment->timemodified. + " lastcron $lastcron course id".$wwassignment->course." wwassignment id ".$wwassignment->id." wwinstance id".$wwassignment->wwinstanceid. + " set name ".$wwassignment->name); } } |
From: Mike G. v. a. <we...@ma...> - 2009-10-01 23:09:12
|
Log Message: ----------- remove try clauses -- they didn't work on hosted, and presumably on other older php versions Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.8 retrieving revision 1.9 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.8 -r1.9 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -520,11 +520,11 @@ //wwassignment_refresh_events(); //FIXME: Add a call that updates all grades in all courses //wwassignment_update_grades(null,0); - try { + //try { // try didn't work on some php systems -- leave it out. wwassignment_update_dirty_sets(); - } catch (Exception $e) { - error_log("\n Unable to run wwassignment_update_dirty_sets ".$e->getMessage()); - } + //} catch (Exception $e) { + //error_log("\n Unable to run wwassignment_update_dirty_sets ".$e->getMessage()); + //} error_log("End wwassignment_cron"); return true; } |
From: dpvc v. a. <we...@ma...> - 2009-10-01 22:22:46
|
Log Message: ----------- Handle arbitrary variable names Modified Files: -------------- pg/lib: Parser.pm pg/lib/Parser: Variable.pm Revision Data ------------- Index: Parser.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.55 -r1.56 --- lib/Parser.pm +++ lib/Parser.pm @@ -718,13 +718,24 @@ $vars = [sort(keys %{$self->{variables}})] unless $vars; $vars = [$vars] unless ref($vars) eq 'ARRAY'; my $n = scalar(@{$vars}); my $vnames = ''; my %isArg; + my $variables = $self->context->variables; if ($n > 0) { my @v = (); - foreach my $x (@{$vars}) {CORE::push(@v,"\$".$x); $isArg{$x} = 1} + foreach my $x (@{$vars}) { + my $perl = $variables->get($x)->{perl} || "\$".$x; + substr($perl,1) =~ s/([^a-z0-9_])/"_".ord($1)/ge; + CORE::push(@v,$perl); + $isArg{$x} = 1; + } $vnames = "my (".join(',',@v).") = \@_;"; } - foreach my $x (keys %{$self->{variables}}) - {$vnames .= "\n my \$$x = main::Formula('$x');" unless $isArg{$x}} + foreach my $x (keys %{$self->{variables}}) { + unless ($isArg{$x}) { + my $perl = $variables->get($x)->{perl} || "\$".$x; + substr($perl,1) =~ s/([^a-z0-9_])/"_".ord($1)/ge; + $vnames .= "\n my $perl = main::Formula('$x');"; + } + } my $context = $self->context; my $fn = eval "package main; Index: Variable.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Variable.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -Llib/Parser/Variable.pm -Llib/Parser/Variable.pm -u -r1.14 -r1.15 --- lib/Parser/Variable.pm +++ lib/Parser/Variable.pm @@ -116,8 +116,9 @@ my $self = shift; my $value = $self->{equation}{values}{$self->{name}}; return $value if defined($value); - return $self->{def}{perl} if defined $self->{def}{perl}; - return '$'.$self->{name}; + my $perl = $self->{def}{perl} || '$'.$self->{name}; + substr($perl,1) =~ s/([^a-z0-9_])/"_".ord($1)/ge; + return $perl; } ######################################################################### |
From: dpvc v. a. <we...@ma...> - 2009-10-01 22:21:35
|
Log Message: ----------- count {\rm } as a blank string Modified Files: -------------- pg/macros: parserMultiAnswer.pl Revision Data ------------- Index: parserMultiAnswer.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserMultiAnswer.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/parserMultiAnswer.pl -Lmacros/parserMultiAnswer.pl -u -r1.11 -r1.12 --- macros/parserMultiAnswer.pl +++ macros/parserMultiAnswer.pl @@ -314,7 +314,7 @@ # sub check_string { my $s = shift; - $s = shift unless defined($s) && $s =~ m/\S/; + $s = shift unless defined($s) && $s =~ m/\S/ && $s ne '{\rm }'; return $s; } |
From: Mike G. v. a. <we...@ma...> - 2009-10-01 21:57:19
|
Log Message: ----------- added some documentation Modified Files: -------------- webwork2/lib/WeBWorK/Utils: CourseManagement.pm Revision Data ------------- Index: CourseManagement.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Utils/CourseManagement.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -Llib/WeBWorK/Utils/CourseManagement.pm -Llib/WeBWorK/Utils/CourseManagement.pm -u -r1.47 -r1.48 --- lib/WeBWorK/Utils/CourseManagement.pm +++ lib/WeBWorK/Utils/CourseManagement.pm @@ -1168,11 +1168,11 @@ } -sub get_SeedCE { +sub get_SeedCE { # helper subroutine to produce a stripped down seed Course Environment from an arbitrary course environment my $ce = shift; warn "get_SeedCE needs current Course environment to create seed CE" unless ref($ce) ; my %seedCE=(); - my @conf_items = qw( webwork_dir webwork_url pg_dir courseName) ; + my @conf_items = qw( webwork_dir webwork_url pg_dir courseName) ; # items to transfer. courseName is often overridden foreach my $item (@conf_items) { $seedCE{$item} = $ce->{$item}; } |
From: Mike G. v. a. <we...@ma...> - 2009-10-01 21:41:30
|
Log Message: ----------- modified the grade_users_sets() call so that it returns the actual grade of the set (properly weighted by the value of each problem) Modified Files: -------------- webwork2/lib: WebworkSOAP.pm Revision Data ------------- Index: WebworkSOAP.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WebworkSOAP.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/WebworkSOAP.pm -Llib/WebworkSOAP.pm -u -r1.13 -r1.14 --- lib/WebworkSOAP.pm +++ lib/WebworkSOAP.pm @@ -193,15 +193,21 @@ my ($self,$authenKey,$courseName,$userIDs,$setID) = @_; my $soapEnv = new WebworkSOAP($authenKey,$courseName); my @grades; - foreach my $userID (@{$userIDs}) { - my @problemData = $soapEnv->{db}->getAllUserProblems($userID,$setID); + #open (LOG, ">>/opt/webwork/tmp_log") or die "Can't open log file"; + #print LOG "\n\nhi there\n\n"; + foreach my $userID (@{$userIDs}) { + my @problemData = $soapEnv->{db}->getAllMergedUserProblems($userID,$setID); + my $grade = 0; for(my $i=0;$i<@problemData;$i++) { - $grade += @problemData[$i]->status; + #print LOG "$userID problem Data",join(" ", %{$problemData[$i]}),"\n\n"; + $grade += ($problemData[$i]->status)*($problemData[$i]->value); + #print LOG "grade is $grade\n"; } push(@grades,$grade); } + #close(LOG); return array_to_soap_string( @grades ); } |
From: Mike G. v. a. <we...@ma...> - 2009-10-01 21:35:26
|
Log Message: ----------- Add upgrade_dirty_sets() function that only updates instances of wwassignment that have been touched since the last cron job. Currently the grades are updated. Modified Files: -------------- wwmoodle/wwassignment4/moodle/mod/wwassignment: lib.php Revision Data ------------- Index: lib.php =================================================================== RCS file: /webwork/cvs/system/wwmoodle/wwassignment4/moodle/mod/wwassignment/lib.php,v retrieving revision 1.7 retrieving revision 1.8 diff -Lwwassignment4/moodle/mod/wwassignment/lib.php -Lwwassignment4/moodle/mod/wwassignment/lib.php -u -r1.7 -r1.8 --- wwassignment4/moodle/mod/wwassignment/lib.php +++ wwassignment4/moodle/mod/wwassignment/lib.php @@ -270,7 +270,7 @@ */ function wwassignment_update_grades($wwassignment=null, $userid=0, $nullifnone=true) { debugLog("Begin wwassignment_update_grades"); - debugLog("inputs wwassignment = " . print_r($wwassignment,true)); + //debugLog("inputs wwassignment = " . print_r($wwassignment,true)); debugLog("userid = $userid"); global $CFG; if (!function_exists('grade_update')) { //workaround for buggy PHP versions @@ -290,9 +290,7 @@ $grades[$k]->rawgrade = null; } } - debugLog("call wwassignment to update grade_item and record grades in gradebook "); - //debugLog(print_r($grades,true)); - wwassignment_grade_item_update($wwassignment, $grades); + wwassignment_grade_item_update($wwassignment, $grades); } else { wwassignment_grade_item_update($wwassignment); } @@ -314,7 +312,7 @@ $wwassignment->cmidnumber =_wwassignment_cmid() ; } - debugLog("processing next grade wwassignment is ".print_r($wwassignment,true) ); + //debugLog("processing next grade wwassignment is ".print_r($wwassignment,true) ); if ($wwassignment->grade != 0) { wwassignment_update_grades($wwassignment); } else { @@ -379,7 +377,7 @@ # grade_update() defined in gradelib.php # $grades=NULL means update grade_item table only, otherwise post grades in grade_grades debugLog("End wwassignment_grade_item_update"); - error_log("update grades for courseid: ". $wwassignment->courseid . " assignment id: ".$wwassignment->id); + error_log("update grades for courseid: ". $wwassignment->courseid . " assignment id: ".$wwassignment->id." time modified ".$wwassignment->timemodified); return grade_update('mod/wwassignment', $wwassignment->courseid, 'mod', 'wwassignment', $wwassignment->id, 0, $grades, $params); } /** @@ -511,7 +509,8 @@ } /** -* @desc Function that is run by the cron job. This makes sure that all data is pushed to webwork. +* @desc Function that is run by the cron job. This makes sure that +* the grades and all other data are pulled from webwork. * returns true if successful */ function wwassignment_cron() { @@ -520,11 +519,50 @@ //FIXME: Add a call that updates all events with dates (in case people forgot to push) //wwassignment_refresh_events(); //FIXME: Add a call that updates all grades in all courses - wwassignment_update_grades(null,0); + //wwassignment_update_grades(null,0); + try { + wwassignment_update_dirty_sets(); + } catch (Exception $e) { + error_log("\n Unable to run wwassignment_update_dirty_sets ".$e->getMessage()); + } error_log("End wwassignment_cron"); return true; } - +function wwassignment_update_dirty_sets() { // update grades for all instances which have been modified since last cronjob + global $CFG; + $timenow = time(); + $lastcron = get_field("modules","lastcron","name","wwassignment"); + error_log ("lastcron is $lastcron and time now is $timenow"); + $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid, cm.id as wwinstanceid + FROM {$CFG->prefix}wwassignment a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m + WHERE m.name='wwassignment' AND m.id=cm.module AND cm.instance=a.id"; + + //error_log ("sql string = $sql"); + if ($rs = get_recordset_sql($sql)) { + while ($wwassignment = rs_fetch_next_record($rs)) { + if (!$wwassignment->cmidnumber) { // is this ever needed? + $wwassignment->cmidnumber =_wwassignment_cmid() ; + } + $logdata = get_logs("l.info = $wwassignment->wwinstanceid"); # the instance number of this assignment is stored in info + $most_recent_record = array_shift($logdata); + $wwassignment->timemodified = $most_recent_record->time; + if ($wwassignment->timemodified > $lastcron) { + error_log("instance needs update. timemodified ".$wwassignment->timemodified." lastcron $lastcron wwassignment instance id ".$wwassignment->id." set name ".$wwassignment->webwork_set); + if ($wwassignment->grade != 0) { + wwassignment_update_grades($wwassignment); + } else { + wwassignment_grade_item_update($wwassignment); + } + } else { + error_log("no update needed. timemodified ".$wwassignment->timemodified." lastcron $lastcron wwassignment instance id ".$wwassignment->id." set name ".$wwassignment->webwork_set); + } + + } + rs_close($rs); + } + error_log("done with updating dirty sets"); + return(true); +} /** |