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

raeburn raeburn at source.lon-capa.org
Sun Feb 9 21:11:46 EST 2020


raeburn		Mon Feb 10 02:11:46 2020 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - Bug 5349: Parameter management by users with a section-specific role ...
   - No setting user-specific parameter if student not in current section
   - In overview mode, input elements enabled for current section 
   - Date shift only applies to date parameters for current section
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.593 loncom/interface/lonparmset.pm:1.594
--- loncom/interface/lonparmset.pm:1.593	Tue Jan 14 21:09:19 2020
+++ loncom/interface/lonparmset.pm	Mon Feb 10 02:11:46 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.593 2020/01/14 21:09:19 raeburn Exp $
+# $Id: lonparmset.pm,v 1.594 2020/02/10 02:11:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3070,7 +3070,21 @@
                         "'".$uname."'","'".$udom."'").
                     '</p>';
                 $uname='';
-                $csec=$env{'form.csec'};
+                if ($env{'request.course.sec'} ne '') {
+                    $csec=$env{'request.course.sec'};
+                } else {
+                    $csec=$env{'form.csec'};
+                }
+                $cgroup=$env{'form.cgroup'};
+            } elsif ($env{'request.course.sec'} ne '') {
+                if ($csec ne $env{'request.course.sec'}) {
+                    $message='<span class="LC_error">'.
+                              &mt("User '[_1]' at domain '[_2]' not in section '[_3]'",
+                                  $uname,$udom,$env{'request.course.sec'}).
+                              '</span>';
+                    $uname='';
+                    $csec=$env{'request.course.sec'};
+                }
                 $cgroup=$env{'form.cgroup'};
             } else {
                 my %name=&Apache::lonnet::userenvironment($udom,$uname,
@@ -4388,6 +4402,7 @@
     $tableopen=0;
     my $foundkeys=0;
     my %keyorder=&standardkeyorder();
+    my $readonlyall = $readonly;
 
     my ($secidx,%grouphash);
     if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
@@ -4449,6 +4464,7 @@
             my ($middle,$part,$name)=
                 ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/);
             my $section=&mt('All Students');
+            $readonly = $readonlyall;
             my $showval = $$resourcedata{$thiskey}; 
             if ($middle=~/^\[(.*)\]/) {
                 my $issection=$1;
@@ -5385,9 +5401,10 @@
 # @param {integer} $shift - time to shift, in seconds
 # @returns {string} - error name or 'ok'
 sub dateshift {
-    my ($shift)=@_;
+    my ($shift,$numchanges)=@_;
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+    my $sec = $env{'request.course.sec'};
     my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
 # ugly retro fix for broken version of types
     foreach my $key (keys(%data)) {
@@ -5402,7 +5419,11 @@
 # go through all parameters and look for dates
     foreach my $key (keys(%data)) {
        if ($data{$key.'.type'}=~/^date_(start|end)$/) {
+          if ($sec ne '') {
+              next unless ($key =~ /^$env{'request.course.id'}\.\[$sec\]\./);
+          }
           my $newdate=$data{$key}+$shift;
+          $$numchanges ++;
           $storecontent{$key}=$newdate;
        }
     }
@@ -5814,9 +5835,13 @@
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
-
+    my $sec = $env{'request.course.sec'};
     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
         text=>"Shifting Dates"});
+    my $submit_text = &mt('Shift all dates accordingly');
+    if ($sec ne '') {
+        $submit_text = &mt("Shift all dates set explicitly for section '[_1]', accordingly",$sec);
+    }
     my $start_page=&Apache::loncommon::start_page('Shift Dates');
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
     $r->print($start_page.$breadcrumbs);
@@ -5832,7 +5857,7 @@
               '</td></tr></table>'.
               '<input type="hidden" name="action" value="dateshift2" />'.
               '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
-              '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
+              '<input type="submit" value="'.$submit_text.'" /></form>');
     &endSettingsScreen($r);
     $r->print(&Apache::loncommon::end_page());
 }
@@ -5844,6 +5869,7 @@
     my ($r) = @_;
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+    my $sec = $env{'request.course.sec'};
     my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
     &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
         text=>"Shifting Dates"});
@@ -5852,14 +5878,35 @@
     $r->print($start_page.$breadcrumbs);
     &startSettingsScreen($r,'parmset',$crstype);
     my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
-    $r->print('<h2>'.&mt('Shift Dates').'</h2>'.
-              '<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
-              &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
-              &Apache::lonlocal::locallocaltime($timeshifted)).'</p>');
+    $r->print('<h2>'.&mt('Shift Dates').'</h2>');
+    if ($sec ne '') {
+        $r->print('<p>'.
+                  &mt("Shift all dates set explicitly for section '[_1]', such that [_2] becomes [_3]",
+                      $sec,&Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+                      &Apache::lonlocal::locallocaltime($timeshifted)).
+                  '</p>');
+    } else {
+        $r->print('<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
+                            &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+                            &Apache::lonlocal::locallocaltime($timeshifted)).
+                  '</p>');
+    }
     my $delta=$timeshifted-$env{'form.timebase'};
-    &dateshift($delta);
+    my $numchanges = 0;
+    my $result = &dateshift($delta,\$numchanges);
+    if ($result eq 'ok') {
+        $r->print(
+            &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
+                                                    $numchanges)));
+    } elsif ($result eq 'con_delayed') {
+        $r->print(
+            &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
+                                                        $numchanges)));
+    } else {
+        $r->print(
+            &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
+    }
     $r->print(
-        &Apache::lonhtmlcommon::confirm_success(&mt('Done')).
         '<br /><br />'.
         &Apache::lonhtmlcommon::actionbox(
             ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));




More information about the LON-CAPA-cvs mailing list