[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonparmset.pm

raeburn raeburn at source.lon-capa.org
Fri Sep 14 15:06:43 EDT 2018


raeburn		Fri Sep 14 19:06:43 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonparmset.pm 
  Log:
  - For 2.11
    Backport 1.575, 1.579, 1.580, 1.581, 1.583, 1.586
  
  
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.522.2.24 loncom/interface/lonparmset.pm:1.522.2.25
--- loncom/interface/lonparmset.pm:1.522.2.24	Mon Sep  3 20:23:37 2018
+++ loncom/interface/lonparmset.pm	Fri Sep 14 19:06:43 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.522.2.24 2018/09/03 20:23:37 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522.2.25 2018/09/14 19:06:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,7 +36,8 @@
 
 =head1 SYNOPSIS
 
-lonparmset provides an interface to setting course parameters. 
+lonparmset provides an interface to setting content parameters in a 
+course.
 
 =head1 DESCRIPTION
 
@@ -129,7 +130,7 @@
 
 =item print_td()
 
-=item print_usergroups()
+=item check_other_groups()
 
 =item parm_control_group()
 
@@ -1024,7 +1025,7 @@
             if (@{$usersgroups} > 1) {
                 my ($coursereply,$grp_parm,$controlgrp);
                 ($coursereply,$othergrp,$grp_parm,$controlgrp) =
-                    &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
+                    &&check_other_groups($$part{$which}.'.'.$$name{$which},
                        $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
                 if ($coursereply && $result > 3) {
                     if (defined($controlgrp)) {
@@ -1117,8 +1118,8 @@
     $r->print('</td>'."\n");
 }
 
-sub print_usergroups {
-    my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
+sub check_other_groups {
+    my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
     my $courseid = $env{'request.course.id'};
     my $output;
     my $symb = &symbcache($rid);
@@ -1133,7 +1134,6 @@
     if (($coursereply) && ($cgroup ne $resultgroup)) {
         if ($result > 3) {
             $bgcolor = '#AAFFAA';
-            $grp_parm = &valout($coursereply,$resulttype);
         }
         $grp_parm = &valout($coursereply,$resulttype);
         $output = '<td style="background-color:'.$bgcolor.';" align="center">';
@@ -1285,8 +1285,7 @@
 # from which you can select all desired parameters.
 #
 sub parmmenu {
-    my ($r,$allparms,$pscat,$keyorder)=@_;
-    my $tempkey;
+    my ($r)=@_;
     $r->print(<<ENDSCRIPT);
 <script type="text/javascript">
 // <![CDATA[
@@ -1365,7 +1364,7 @@
 ENDSCRIPT
 
     $r->print('<hr />');
-    &shortCuts($r,$allparms,$pscat,$keyorder);
+    &shortCuts($r);
     $r->print('<hr />');
 }
 # return a hash
@@ -1430,7 +1429,7 @@
         'retrypartial' => 'tries',
         'discussvote'  => 'misc',
         'examcode' => 'high_level_randomization',
-    );    
+    );
 }
 
 sub whatIsMyCategory {
@@ -1512,6 +1511,7 @@
                   .&mt($categories{$key})
                   .'</h4>'."\n");
         foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
+            next if ($tempkey eq '');
             $r->print('<span class="LC_nobreak">'
                      .'<label><input type="checkbox" name="pscat" '
                      .'value="'.$tempkey.'" ');
@@ -1531,7 +1531,7 @@
 # This function offers some links on the parameter section to get with one click a group a parameters
 #
 sub shortCuts {
-    my ($r,$allparms,$pscat,$keyorder)=@_;
+    my ($r)=@_;
 
     # Parameter Selection
     $r->print(
@@ -1701,12 +1701,12 @@
 # This function shows on table Mode the available Parameters for the selected Resources
 #
 sub displaymenu {
-    my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_;
+    my ($r,$allparms,$pscat,$keyorder,$divid)=@_;
 
     $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
 
-    &parmmenu($r,$allparms,$pscat,$keyorder);
+    &parmmenu($r);
     $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));
     &parmboxes($r,$allparms,$pscat,$keyorder);
     $r->print(&Apache::loncommon::end_scrollbox());
@@ -2329,7 +2329,7 @@
 
         # Step 2
         $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
-        &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll');
+        &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
 
         # Step 3
         $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
@@ -3764,10 +3764,8 @@
         $r->print(&mt('All users'));
         } elsif ($data{'scope_type'} eq 'user') {
         $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
-        } elsif ($data{'scope_type'} eq 'section') {
-        $r->print(&mt('Section: [_1]',$data{'scope'}));
-        } elsif ($data{'scope_type'} eq 'group') {
-        $r->print(&mt('Group: [_1]',$data{'scope'}));
+        } elsif ($data{'scope_type'} eq 'secgroup') {
+        $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
         }
         $r->print('<br />');
         if ($data{'realm_type'} eq 'all') {
@@ -3853,8 +3851,7 @@
         $data{'scope_type'} = 'user';
         $data{'scope'} = [$1,$2];
     } else {
-        #FIXME check for group scope
-        $data{'scope_type'} = 'section';
+        $data{'scope_type'} = 'secgroup';
     }
     $middle=~s/^\[(.*)\]//;
     }
@@ -4168,7 +4165,7 @@
     my $output;
     $output .= '<form action="" method="post">';
     $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
-    $output .= '<input type="submit" value="Continue" />';
+    $output .= '<input type="submit" value="'.&mt('Continue').'" />';
     return ($output);
 }
 
@@ -4190,7 +4187,10 @@
             my $put_result = &Apache::lonnet::put('environment',
                                         {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
 
-            $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
+            $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]',
+                          '<strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}.
+                          '</strong>',$put_result).
+                      '<br />');
         }
         $r->print(&continue());
     } elsif (exists($env{'form.fieldname'})) {
@@ -4202,12 +4202,17 @@
                             {'metadata.'.$meta_field.'.values'=>"",
                              'metadata.'.$meta_field.'.added'=>"$display_field",
                              'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
-        $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
+        $r->print(&mt('Added new Metadata Field [_1] with result [_2]',
+                      '<strong>'.$env{'form.fieldname'}.'</strong>',$put_result).
+                  '<br />');
         $r->print(&continue());
     } else {
         my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
         if ($fields) {
-            $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
+            $r->print(&mt('You may undelete previously deleted fields.').
+                      '<br />'.
+                      &mt('Check those you wish to undelete and click Undelete.').
+                      '<br />');
             $r->print('<form method="post" action="">');
             foreach my $key(keys(%$fields)) {
                 $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
@@ -4215,9 +4220,12 @@
             $r->print('<input type="submit" name="undelete" value="Undelete" />');
             $r->print('</form>');
         }
-        $r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata">');
+        $r->print('<hr />'.
+                  &mt('[_1]Or[_2] you may enter a new metadata field name.',
+                      '<strong>','</strong>').
+                 '<form method="post" action="/adm/parmset?action=addmetadata">');
         $r->print('<input type="text" name="fieldname" /><br />');
-        $r->print('<input type="submit" value="Add Metadata Field" />');
+        $r->print('<input type="submit" value="'.&mt('Add Metadata Field').'" />');
     }
     $r->print('</form>');
 }
@@ -4238,6 +4246,11 @@
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
     my $save_field = '';
+    my %lt = &Apache::lonlocal::texthash(
+                                           addm => 'Add Metadata Field',
+                                           ordm => 'Order Metadata Fields',
+                                           save => 'Save',
+                                        );
     if ($env{'form.restrictmeta'}) {
         foreach my $field (sort(keys(%env))) {
             if ($field=~m/^form.(.+)_(.+)$/) {
@@ -4276,28 +4289,25 @@
     my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
     # Now get possible added metadata fields
     my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
-    my $row_alt = 1;
     $output .= &Apache::loncommon::start_data_table();
     foreach my $field (sort(keys(%metadata_fields))) {
         if ($field ne 'courserestricted') {
-            $row_alt = $row_alt ? 0 : 1;
         $output.= &output_row($r, $field, $metadata_fields{$field});
     }
     }
     my $buttons = (<<ENDButtons);
-        <input type="submit" name="restrictmeta" value="Save" />
+        <input type="submit" name="restrictmeta" value="$lt{'save'}" />
         </form><br />
         <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
-        <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
+        <input type="submit" name="restrictmeta" value="$lt{'addm'}" />
         </form>
         <br />
         <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
-        <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
+        <input type="submit" name="restrictmeta" value="$lt{'ordm'}" />
 ENDButtons
     my $added_flag = 1;
     foreach my $field (sort(keys(%$added_metadata_fields))) {
-        $row_alt = $row_alt ? 0 : 1;
-        $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
+        $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag);
     }
     $output .= &Apache::loncommon::end_data_table();
     $r->print(<<ENDenv);
@@ -4542,7 +4552,7 @@
 my %standard_parms_types;
 
 sub load_parameter_names {
-    open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
+    open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
     while (my $configline=<$config>) {
     if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
     chomp($configline);
@@ -4557,6 +4567,7 @@
     close($config);
     $standard_parms{'int_pos'}      = 'Positive Integer';
     $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
+    $standard_parms{'scoreformat'}  = 'Format for display of score';
 }
 
 sub standard_parameter_names {


More information about the LON-CAPA-cvs mailing list