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

raeburn raeburn at source.lon-capa.org
Fri Apr 29 19:24:59 EDT 2022


raeburn		Fri Apr 29 23:24:59 2022 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - "Edit Resource Parameters - Overview Mode" - order by "realm" is replaced
    with order based on location in course (same as navmap display). 
  
  
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.607 loncom/interface/lonparmset.pm:1.608
--- loncom/interface/lonparmset.pm:1.607	Thu Apr 28 15:30:34 2022
+++ loncom/interface/lonparmset.pm	Fri Apr 29 23:24:59 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.607 2022/04/28 15:30:34 raeburn Exp $
+# $Id: lonparmset.pm,v 1.608 2022/04/29 23:24:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2074,6 +2074,7 @@
 # @param {hash reference} $uris - hash resource/map id -> resource src
 # @param {hash reference} $keyorder - hash parameter key -> appearance rank for this parameter when looking through every resource and every parameter, starting at 100 (integer)
 # @param {hash reference} $defkeytype - hash parameter name -> parameter type
+# @param {string} $pssymb - resource symb (when a single resource is selected)
 sub extractResourceInformation {
     my $ids = shift;
     my $typep = shift;
@@ -3033,19 +3034,33 @@
 #
 # @param {Apache2::RequestRec} $r - the Apache request
 # @param {string} $sortorder - realmstudent|studentrealm
+# @param {string} $context - newoverview|overview
 sub sortmenu {
-    my ($r,$sortorder)=@_;
-    $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
-    if ($sortorder eq 'realmstudent') {
-       $r->print(' checked="checked"');
+    my ($r,$sortorder,$context)=@_;
+    my %text;
+    if ($context eq 'newoverview') {
+        %text = &Apache::lonlocal::texthash (
+                   realmstudent => 'Sort by location in course first, then student (group/section)',
+                   studentrealm => 'Sort by student (group/section) first, then location in course',
+        );
+    } else {
+        %text = &Apache::lonlocal::texthash (
+                   realmstudent => 'Sort by realm first, then student (group/section)',
+                   studentrealm => 'Sort by student (group/section) first, then realm',
+        );
     }
-    $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
-    $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
+    my %sortchecked = (
+       realmstudent => ' checked="checked"',
+       studentrealm => '',
+    );
     if ($sortorder eq 'studentrealm') {
-       $r->print(' checked="checked"');
+        $sortchecked{'studentrealm'} = $sortchecked{'realmstudent'};
+        $sortchecked{'realmstudent'} = '';
+    }
+    foreach my $sorttype ('realmstudent','studentrealm') {
+        $r->print('<br /><label><input type="radio" name="sortorder" value="'.$sorttype.'"'.$sortchecked{$sorttype}.' />'.
+                  $text{$sorttype}.'</label>');
     }
-    $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
-          '</label>');
 }
 
 # Returns a hash parameter key -> order (integer) giving the order for some parameters.
@@ -4687,9 +4702,12 @@
 # @param {string} $caller - name of the calling sub (overview|newoverview)
 # @param {hash reference} $classlist - from loncoursedata::get_classlist
 # @param {boolean} $readonly - true if editing not allowed
+# @param {string} $parmlev - full|map
+# @param {hash reference} $hash_for_realm - keys: realm, values: numeric order  
+# @param {string} $pschp - selected map pc, or 'all'
 # @returns{integer} - number of $listdata parameters processed
 sub listdata {
-    my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_;
+    my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly,$parmlev,$hash_for_realm,$pschp)=@_;
     
 # Start list output
 
@@ -4715,6 +4733,20 @@
     foreach my $key (sort {
         my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
         my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
+        my ($aid,$bid);
+        if ($caller eq 'newoverview') {
+            if (ref($hash_for_realm) eq 'HASH') {
+                if (($parmlev eq 'map') && ($pschp eq 'all')) {
+                    my ($aurl) = ($ares =~ /^(.+\.(?:sequence|page))___\(all\)$/);
+                    my ($burl) = ($bres =~ /^(.+\.(?:sequence|page))___\(all\)$/);
+                    $aid = $hash_for_realm->{$aurl};
+                    $bid = $hash_for_realm->{$burl};
+                } elsif ($parmlev eq 'full') {
+                    $aid = $hash_for_realm->{$ares};
+                    $bid = $hash_for_realm->{$bres};
+                }
+            }
+        }
 
         # get the numerical order for the param
         $aparm=$keyorder{'parameter_0_'.$aparm};
@@ -4724,7 +4756,21 @@
 
         if ($sortorder eq 'realmstudent') {
             if ($ares     ne $bres    ) {
-                $result = ($ares     cmp $bres);
+                if ($caller eq 'newoverview') {
+                    if (ref($hash_for_realm) eq 'HASH') {
+                        if (($parmlev eq 'map') && ($pschp eq 'all')) {
+                            $result = ($aid <=> $bid);
+                        } elsif ($parmlev eq 'full') {
+                            $result = ($aid <=> $bid);
+                        } else {
+                            $result = ($ares cmp $bres);
+                        }
+                    } else {
+                        $result = ($ares cmp $bres);
+                    }
+                } else {
+                    $result = ($ares cmp $bres);
+                }
             } elsif ($astudent ne $bstudent) {
                 $result = ($astudent cmp $bstudent);
             } elsif ($apart    ne $bpart   ) {
@@ -4734,7 +4780,21 @@
             if      ($astudent ne $bstudent) {
                 $result = ($astudent cmp $bstudent);
             } elsif ($ares     ne $bres    ) {
-                $result = ($ares     cmp $bres);
+                if ($caller eq 'newoverview') {
+                    if (ref($hash_for_realm) eq 'HASH') {
+                        if (($parmlev eq 'map') && ($pschp eq 'all')) {
+                            $result = ($aid <=> $bid);
+                        } elsif ($parmlev eq 'full') {
+                            $result = ($aid <=> $bid);
+                        } else {
+                            $result = ($ares cmp $bres);
+                        }
+                    } else {
+                        $result = ($ares cmp $bres);
+                    }
+                } else {
+                    $result = ($ares cmp $bres);
+                }
             } elsif ($apart    ne $bpart   ) {
                 $result = ($apart    cmp $bpart);
             }
@@ -4814,6 +4874,12 @@
             }
             if ($is_map) {
                 my $leveltitle = &mt('Folder/Map');
+                my $title = &Apache::lonnet::gettitle($1);
+                if (ref($hash_for_realm) eq 'HASH') {
+                    if ($hash_for_realm->{$mapurl} eq '1') {
+                        $title = &mt('Main Content');
+                    }
+                }
                 unless (($name eq 'hiddenresource') || ($name eq 'encrypturl')) {   
                     if ($caller eq 'newoverview') {
                         my $altkey = $thiskey;
@@ -4830,7 +4896,7 @@
                         $is_recursive = 1;
                     }
                 }
-                $realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>';
+                $realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.$title.' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>';
             } elsif ($middle) {
                 my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
                 $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').
@@ -5979,7 +6045,7 @@
     $r->print('<div>');
     my $sortorder=$env{'form.sortorder'};
     unless ($sortorder) { $sortorder='realmstudent'; }
-    &sortmenu($r,$sortorder);
+    &sortmenu($r,$sortorder,'newoverview'));
     $r->print('</div></div>');
 
     $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
@@ -6004,7 +6070,15 @@
 
 # List data
 
-        &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
+        my $hash_for_realm;
+        if (($parmlev eq 'map') && (keys(%allmaps))) {
+            %{$hash_for_realm} = reverse(%allmaps);
+        } elsif (($parmlev eq 'full') && (keys(%symbp))) {
+            for (my $i=0; $i<@ids; $i++) {
+                $hash_for_realm->{$symbp{$ids[$i]}} = $i;
+            }
+        }
+        &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly,$parmlev,$hash_for_realm,$pschp);
     }
     $r->print(&tableend());
     unless ($readonly) {
@@ -6111,7 +6185,7 @@
 
     my $sortorder=$env{'form.sortorder'};
     unless ($sortorder) { $sortorder='realmstudent'; }
-    &sortmenu($r,$sortorder);
+    &sortmenu($r,$sortorder,'overview');
 
     my $submitbutton = '<input type="submit" value="'.&mt('Save').'" />';
 


More information about the LON-CAPA-cvs mailing list