--- loncom/interface/loncommon.pm 2013/01/21 02:33:22 1.1075.2.29 +++ loncom/interface/loncommon.pm 2013/04/30 13:25:45 1.1075.2.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1075.2.29 2013/01/21 02:33:22 raeburn Exp $ +# $Id: loncommon.pm,v 1.1075.2.34 2013/04/30 13:25:45 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; } @@ -990,7 +1000,7 @@ sub select_language { my ($name,$selected,$includeempty) = @_; my %langchoices; if ($includeempty) { - %langchoices = ('' => &mt('No language preference')); + %langchoices = ('' => 'No language preference'); } foreach my $id (&languageids()) { my $code = &supportedlanguagecode($id); @@ -998,6 +1008,7 @@ sub select_language { $langchoices{$code} = &plainlanguagedescription($id); } } + %langchoices = &Apache::lonlocal::texthash(%langchoices); return &select_form($selected,$name,\%langchoices); } @@ -1029,6 +1040,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 +1099,8 @@ sub linked_select_forms { $secondselectname, $hashref, $menuorder, + $onchangefirst, + $onchangesecond ) = @_; my $second = "document.$formname.$secondselectname"; my $first = "document.$formname.$firstselectname"; @@ -1138,7 +1157,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 +1170,11 @@ END $result .= "\n"; my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; $result .= $middletext; - $result .= "{$firstdefault}->{'default'}; my @secondorder = sort(keys(%select2)); @@ -5695,7 +5718,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; } @@ -6421,6 +6445,11 @@ div.LC_edit_problem_saves { padding-bottom: 5px; } +.LC_edit_opt { + padding-left: 1em; + white-space: nowrap; +} + img.stift { border-width: 0; vertical-align: middle; @@ -6677,7 +6706,7 @@ ul#LC_secondary_menu li ul li { vertical-align: top; border-left: 1px solid black; border-right: 1px solid black; - background-color: $data_table_light + background-color: $data_table_light; list-style:none; float: none; } @@ -7762,11 +7791,9 @@ sub LCprogressbar { $LCcurrentid=$$.'_'.$LCidcnt; my $starting=&mt('Starting'); my $content=(<
$starting
-

ENDPROGBAR &r_print($r,$content.&LCprogressbar_script($LCcurrentid)); } @@ -8180,7 +8207,19 @@ sub get_sections { my %sectioncount; my $now = time; - if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) { + my $check_students = 1; + my $only_students = 0; + if (ref($possible_roles) eq 'ARRAY') { + if (grep(/^st$/,@{$possible_roles})) { + if (@{$possible_roles} == 1) { + $only_students = 1; + } + } else { + $check_students = 0; + } + } + + if ($check_students) { my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); my $sec_index = &Apache::loncoursedata::CL_SECTION(); my $status_index = &Apache::loncoursedata::CL_STATUS(); @@ -8207,6 +8246,9 @@ sub get_sections { } } } + if ($only_students) { + return %sectioncount; + } my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); foreach my $user (sort(keys(%courseroles))) { if ($user !~ /^(\w{2})/) { next; } @@ -10063,7 +10105,7 @@ sub upload_embedded { $output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'
'; next; } elsif ($fname=~/\.(\d+)\.(\w+)$/) { - $output .= &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'
'; + $output .= &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'
'; next; } $env{'form.embedded_item_'.$i.'.filename'}=$fname; @@ -10765,8 +10807,8 @@ sub process_decompression { my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; my ($dir,$error,$warning,$output); if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { - $error = &mt('File name not a supported archive file type.'). - '
'.&mt('File name should end with one of: [_1].', + $error = &mt('Filename not a supported archive file type.'). + '
'.&mt('Filename should end with one of: [_1].', '.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); } else { my $docuhome = &Apache::lonnet::homeserver($docuname,$docudom); @@ -13154,7 +13196,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"; @@ -13163,7 +13205,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"; @@ -13194,7 +13236,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"; @@ -13241,7 +13284,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 '') { @@ -13510,6 +13557,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'} = '';