[LON-CAPA-cvs] cvs: modules /gci londocsgci.pm

gci gci@source.lon-capa.org
Mon, 29 Nov 2010 04:33:35 -0000


gci		Mon Nov 29 04:33:35 2010 EDT

  Modified files:              
    /modules/gci	londocsgci.pm 
  Log:
  - Customization for GCI_3
    - Timezone can be set for a Concept Test. 
  
  
Index: modules/gci/londocsgci.pm
diff -u modules/gci/londocsgci.pm:1.15 modules/gci/londocsgci.pm:1.16
--- modules/gci/londocsgci.pm:1.15	Tue Nov 16 02:28:10 2010
+++ modules/gci/londocsgci.pm	Mon Nov 29 04:33:35 2010
@@ -2,7 +2,7 @@
 # Custom Edit Course Routines for Assembly of Valid Concept Tests from
 # Geoscience Concept Inventory. 
 #
-# $Id: londocsgci.pm,v 1.15 2010/11/16 02:28:10 gci Exp $
+# $Id: londocsgci.pm,v 1.16 2010/11/29 04:33:35 gci Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -219,25 +219,35 @@
       } else {
           $r->print('<fieldset><legend>'.&mt('Modify Test').'</legend>'.
                     &mt('Currently no student submissions have been recorded, so you may modify the contents of the Concept Test.').
-                    '<br /><form name="changetest" method="post" action="/adm/coursedocs">'.
+                    '<br /><br /><form name="changetest" method="post" action="/adm/coursedocs">'.
                     '<input type="hidden" name="concepttest" value="editmyown" />'.
                     '<input type="submit" name="modifytest" value="'.&mt('Edit Concept Test').'" /></form></fieldset></p>');
       }
       my ($crsparms,$ineffect,$parmlev) = &current_parms($cdom,$cnum);
       my $formname = 'datesform';
       my $datebutton = &mt('Save');
+      my $hide_timezone = 1;
       my $startform =
           &Apache::lonhtmlcommon::date_setter($formname,'opendate',
-                                              $crsparms->{'opendate'});
+                                              $crsparms->{'opendate'},'','','',
+                                              '','','','','',$hide_timezone);
       my $endform =
           &Apache::lonhtmlcommon::date_setter($formname,'duedate',
-                                                           $crsparms->{'duedate'});
+                                              $crsparms->{'duedate'},'','','',
+                                              '','','','','',$hide_timezone);
+      my $includeempty = 1;
+      my $timezone = &Apache::lonlocal::gettimezone();
+      my $tzform = &Apache::loncommon::select_timezone('timezone',$timezone,
+                                                       undef,$includeempty);
       $r->print('<p><fieldset><legend>'.&mt('Test Availability').'</legend>'.
                 &mt('Open and close dates for test items for the concept test are currently set as follows:').
-                '<br />'.
+                '<br /><br />'.
                 '<form name="'.$formname.'" method="post" '.
                 'action="/adm/coursedocs">'.
                 &Apache::lonhtmlcommon::start_pick_box().
+                &Apache::lonhtmlcommon::row_title(&mt('Time zone')).
+                $tzform.
+                &Apache::lonhtmlcommon::row_closure(1).         
                 &Apache::lonhtmlcommon::row_title(&mt('Open date')).
                 $startform.
                 &Apache::lonhtmlcommon::row_closure(1).
@@ -547,8 +557,18 @@
 sub store_dates_parms {
     my ($cdom,$cnum) = @_;
     my $topsymb = '___0___uploaded/'.$cdom.'/'.$cnum.'/default.sequence';
+    my $tz_change; 
+    my $timezone =  &Apache::lonlocal::gettimezone();
+    if ($env{'form.timezone'} ne '') {
+        if (&Apache::lonlocal::gettimezone($env{'form.timezone'}) ne 'local') {
+            if ($timezone ne $env{'form.timezone'}) {
+                $tz_change = 1;
+                $timezone = $env{'form.timezone'};
+            }
+        }
+    }
     my ($opendate,$duedate) = 
-        &Apache::lonuserutils::get_dates_from_form('opendate','duedate');
+        &Apache::lonuserutils::get_dates_from_form('opendate','duedate',$timezone);
     my %dates = (
                   opendate => {
                                value => $opendate,
@@ -566,11 +586,14 @@
                                    '0_'.$date,14,$dates{$date}{'value'},
                                    $dates{$date}{'type'},undef,$cdom);
     }
+    if ($tz_change) {
+        &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.timezone' => $timezone});
+    }
     my $output = &mt('Open and Close dates set for test items').'<ul>'.
                  '<li>'.&mt('Concept Test Questions open:').' '.
-                        &Apache::lonlocal::locallocaltime($opendate).'</li>'.
+                        &Apache::lonlocal::locallocaltime($opendate,$timezone).'</li>'.
                  '<li>'.&mt('Concept Test Questions close:').' '.
-                        &Apache::lonlocal::locallocaltime($duedate).'</li>'.
+                        &Apache::lonlocal::locallocaltime($duedate,$timezone).'</li>'.
                  '</ul>';
     return $output;
 }