--- loncom/interface/loncommon.pm 2013/01/15 17:37:45 1.1111 +++ loncom/interface/loncommon.pm 2013/03/19 00:37:03 1.1117 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1111 2013/01/15 17:37:45 raeburn Exp $ +# $Id: loncommon.pm,v 1.1117 2013/03/19 00:37:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -531,7 +531,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'; @@ -594,8 +595,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 .= ' // ]]> @@ -752,7 +754,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 '') { @@ -847,6 +849,14 @@ function setRole(crstype) { } |; } + if ($credits_element) { + $setsections .= qq| +function setCredits(defaultcredits) { + document.$formname.$credits_element.value = defaultcredits; + return; +} +|; + } return $setsections; } @@ -1001,6 +1011,7 @@ sub select_language { $langchoices{$code} = &plainlanguagedescription($id); } } + %langchoices = &Apache::lonlocal::texthash(%langchoices); return &select_form($selected,$name,\%langchoices); } @@ -1059,6 +1070,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 @@ -1112,6 +1129,8 @@ sub linked_select_forms { $secondselectname, $hashref, $menuorder, + $onchangefirst, + $onchangesecond ) = @_; my $second = "document.$formname.$secondselectname"; my $first = "document.$formname.$firstselectname"; @@ -1168,7 +1187,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}; @@ -1181,7 +1200,11 @@ END $result .= "\n"; my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; $result .= $middletext; - $result .= "{$firstdefault}->{'default'}; my @secondorder = sort(keys(%select2)); @@ -4981,7 +5004,7 @@ sub CSTR_pageheader { my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; my ($udom,$uname,$thisdisfn)= - ($trailfile =~ m{^\Q$londocroot\E/priv/([^/]+)/([^/]+)/(.*)$}); + ($trailfile =~ m{^\Q$londocroot\E/priv/([^/]+)/([^/]+)(?:|/(.*))$}); my $formaction = "/priv/$udom/$uname/$thisdisfn"; $formaction =~ s{/+}{/}g; @@ -5724,7 +5747,8 @@ table.LC_nested tr.LC_empty_row td { padding: 8px; } -table.LC_data_table tr.LC_empty_row td { +table.LC_data_table tr.LC_empty_row td, +table.LC_data_table tr.LC_footer_row td { background-color: $sidebg; } @@ -13175,7 +13199,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"; @@ -13184,7 +13208,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"; @@ -13215,7 +13239,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"; @@ -13262,7 +13287,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 '') { @@ -13284,7 +13313,7 @@ sub commit_studentrole { } } } else { - if ($secchange) { + if ($secchange) { $$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; } else { $$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed; @@ -13531,6 +13560,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'} = '';