--- loncom/interface/loncommon.pm 2013/01/28 15:52:51 1.1075.2.30 +++ loncom/interface/loncommon.pm 2013/03/01 22:01:08 1.1075.2.31 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.30 2013/01/28 15:52:51 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.31 2013/03/01 22:01:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -528,7 +528,8 @@ ENDAUTHORBRW } sub coursebrowser_javascript { - my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_; + my ($domainfilter,$sec_element,$formname,$role_element,$crstype, + $credits_element) = @_; my $wintitle = 'Course_Browser'; if ($crstype eq 'Community') { $wintitle = 'Community_Browser'; @@ -591,8 +592,9 @@ sub coursebrowser_javascript { } $id_functions ENDSTDBRW - if (($sec_element ne '') || ($role_element ne '')) { - $output .= &setsec_javascript($sec_element,$formname,$role_element); + if (($sec_element ne '') || ($role_element ne '') || ($credits_element ne '')) { + $output .= &setsec_javascript($sec_element,$formname,$role_element, + $credits_element); } $output .= ' // ]]> @@ -749,7 +751,7 @@ ENDUSERBRW } sub setsec_javascript { - my ($sec_element,$formname,$role_element) = @_; + my ($sec_element,$formname,$role_element,$credits_element) = @_; my (@courserolenames,@communityrolenames,$rolestr,$courserolestr, $communityrolestr); if ($role_element ne '') { @@ -844,6 +846,14 @@ function setRole(crstype) { } |; } + if ($credits_element) { + $setsections .= qq| +function setCredits(defaultcredits) { + document.$formname.$credits_element.value = defaultcredits; + return; +} +|; + } return $setsections; } @@ -1029,6 +1039,12 @@ linked_select_forms takes the following =item * $menuorder, the order of values in the first menu +=item * $onchangefirst, additional javascript call to execute for an onchange + event for the first tag + =back Below is an example of such a hash. Only the 'text', 'default', and @@ -1082,6 +1098,8 @@ sub linked_select_forms { $secondselectname, $hashref, $menuorder, + $onchangefirst, + $onchangesecond ) = @_; my $second = "document.$formname.$secondselectname"; my $first = "document.$formname.$firstselectname"; @@ -1138,7 +1156,7 @@ function select1_changed() { END # output the initial values for the selection lists - $result .= "\n"; my @order = sort(keys(%{$hashref})); if (ref($menuorder) eq 'ARRAY') { @order = @{$menuorder}; @@ -1151,7 +1169,11 @@ END $result .= "\n"; my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; $result .= $middletext; - $result .= "{$firstdefault}->{'default'}; my @secondorder = sort(keys(%select2)); @@ -13155,7 +13177,7 @@ sub commit_customrole { } sub commit_standardrole { - my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_; + my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,$credits) = @_; my ($output,$logmsg,$linefeed); if ($context eq 'auto') { $linefeed = "\n"; @@ -13164,7 +13186,7 @@ sub commit_standardrole { } if ($three eq 'st') { my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end, - $one,$two,$sec,$context); + $one,$two,$sec,$context,$credits); if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) { $output = $logmsg.' '.&mt('Error: ').$result."\n"; @@ -13195,7 +13217,8 @@ sub commit_standardrole { } sub commit_studentrole { - my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_; + my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context, + $credits) = @_; my ($result,$linefeed,$oldsecurl,$newsecurl); if ($context eq 'auto') { $linefeed = "\n"; @@ -13242,7 +13265,11 @@ sub commit_studentrole { } } if (($expire_role_result eq 'ok') || ($secchange == 0)) { - $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context); + $modify_section_result = + &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef, + undef,undef,undef,$sec, + $end,$start,'','',$cid, + '',$context,$credits); if ($modify_section_result =~ /^ok/) { if ($secchange == 1) { if ($sec eq '') { @@ -13511,6 +13538,9 @@ sub construct_course { } else { $cenv{'internal.courseowner'} = $args->{'curruser'}; } + if ($args->{'defaultcredits'}) { + $cenv{'internal.defaultcredits'} = $args->{'defaultcredits'}; + } my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner. if ($args->{'crssections'}) { $cenv{'internal.sectionnums'} = '';