[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface lonhtmlcommon.pm lonrequestcourse.pm lonuserutils.pm

raeburn raeburn@source.lon-capa.org
Mon, 29 Nov 2010 04:40:13 -0000


This is a MIME encoded message

--raeburn1291005613
Content-Type: text/plain

raeburn		Mon Nov 29 04:40:13 2010 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	lonhtmlcommon.pm lonrequestcourse.pm 
                     	lonuserutils.pm 
  Log:
  - Customization for GCI_3
    - Course timezone specified when creating a new Concept Test.
  
  
--raeburn1291005613
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20101129044013.txt"

Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.253.2.5 loncom/interface/lonhtmlcommon.pm:1.253.2.6
--- loncom/interface/lonhtmlcommon.pm:1.253.2.5	Mon Nov  8 23:27:58 2010
+++ loncom/interface/lonhtmlcommon.pm	Mon Nov 29 04:40:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.253.2.5 2010/11/08 23:27:58 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.253.2.6 2010/11/29 04:40:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -410,7 +410,7 @@
 ##############################################
 sub date_setter {
     my ($formname,$dname,$currentvalue,$special,$includeempty,$state,
-        $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_;
+        $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink,$hide_timezone) = @_;
     my $now = time;
     my $wasdefined=1;
     if (! defined($state) || $state ne 'disabled') {
@@ -563,7 +563,10 @@
         $cal_link = qq{<a href="javascript:$dname\_opencalendar()">};
     }
     #
-    my $tzone = ' '.$tzname.' ';
+    my $tzone;
+    unless ($hide_timezone) {
+        $tzone = ' '.$tzname.' ';
+    }
     if ($no_hh_mm_ss) {
         $result .= &mt('[_1] [_2] [_3] ',
                        $monthselector,$dayselector,$yearselector).
@@ -643,7 +646,7 @@
 ##############################################
 ##############################################
 sub get_date_from_form {
-    my ($dname) = @_;
+    my ($dname,$timezone) = @_;
     my ($sec,$min,$hour,$day,$month,$year);
     #
     if (defined($env{'form.'.$dname.'_second'})) {
@@ -693,7 +696,11 @@
     if (($year<1970) || ($year>2037)) { return undef; }
     if (defined($sec) && defined($min)   && defined($hour) &&
         defined($day) && defined($month) && defined($year)) {
-        my $timezone = &Apache::lonlocal::gettimezone();
+        if (defined($timezone)) {
+            if (&Apache::lonlocal::gettimezone($timezone) eq 'local') {
+                $timezone = &Apache::lonlocal::gettimezone();
+            }
+        }
         my $dt = DateTime->new( year   => $year,
                                 month  => $month,
                                 day    => $day,
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.41.2.8 loncom/interface/lonrequestcourse.pm:1.41.2.9
--- loncom/interface/lonrequestcourse.pm:1.41.2.8	Mon Nov  8 21:44:55 2010
+++ loncom/interface/lonrequestcourse.pm	Mon Nov 29 04:40:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.41.2.8 2010/11/08 21:44:55 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.41.2.9 2010/11/29 04:40:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -600,6 +600,7 @@
                                               cdescr      => 'text',
                                               concepttest => 'radio',
                                             );
+        $elements{'new'}{'enrollment'}{'timezone'} = 'selectbox';
         if (&show_cloneable()) {
             $elements{'new'}{'courseinfo'}{'clonecrs'} = 'selectbox';
             $elements{'new'}{'courseinfo'}{'clonedom'} = 'hidden';
@@ -1751,12 +1752,12 @@
                 &mt('No').'</label></span>'. 
                 &Apache::lonhtmlcommon::row_closure(1).
                 &date_setting_table($starttime,$endtime,$formname,'enroll',
-                                    $hasauto,%enrolltitles);
+                                    $hasauto,$dom,%enrolltitles);
         }
     }
     my $access_dates = 
         &date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
-                            %accesstitles);
+                            $dom,%accesstitles);
     if ($sections) {
         $output .=  $sections;
     }
@@ -1773,8 +1774,16 @@
         }
         $output .= &Apache::lonhtmlcommon::row_headline('Access').
                    '<h3>'.$header.'</h3>'.
-                   &Apache::lonhtmlcommon::row_closure(1).
-                   $access_dates;
+                   &Apache::lonhtmlcommon::row_closure(1);
+        if ($dom eq 'gcitest') {
+            my $includeempty = 1;
+            my $timezone = &Apache::lonlocal::gettimezone();
+            $output .= &Apache::lonhtmlcommon::row_title('Time zone').
+                       &Apache::loncommon::select_timezone('timezone',$timezone,
+                                                           undef,$includeempty).
+                       &Apache::lonhtmlcommon::row_closure(1);
+        }
+        $output .= $access_dates;
     }
     if ($dom eq 'gcitest') {
         return $output;
@@ -1843,16 +1852,22 @@
 }
 
 sub date_setting_table {
-    my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_;
+    my ($starttime,$endtime,$formname,$prefix,$hasauto,$dom,%datetitles) = @_;
     my ($perpetual,$table);
     my $no_hh_mm_ss = 1;
+    my $hide_timezone;
     if (&Apache::loncommon::needs_gci_custom()) {
         $no_hh_mm_ss = '';
+        if ($dom eq 'gcitest') {
+            if ($prefix eq 'access') {
+                $hide_timezone = 1;
+            }
+        }
     }
     my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
-                                                        $starttime,'','','',$no_hh_mm_ss,'','','',1);
+                                                        $starttime,'','','',$no_hh_mm_ss,'','','',1,$hide_timezone);
     my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end',
-                                                      $endtime,'','','',$no_hh_mm_ss,'','','',1);
+                                                      $endtime,'','','',$no_hh_mm_ss,'','','',1,$hide_timezone);
     my $closure = '';
     if ($prefix eq 'access') {
         unless (&Apache::loncommon::needs_gci_custom()) {
@@ -2445,14 +2460,26 @@
             $inst_values .= '<td>'.&mt('None').'</td>';
         }
     }
+    my $tz;
+    if ($dom eq 'gcitest') {
+        if (&Apache::lonlocal::gettimezone($env{'form.timezone'}) ne 'local') {
+            $tz = $env{'form.timezone'};
+        } else {
+            $tz = &Apache::lonlocal::gettimezone();
+        }
+        $enroll_headers .= '<th>'.&mt('Time Zone').'</th>';
+    }
     $enroll_headers .= '<th>'.&mt('Access Starts').'</th>'.
                        '<th>'.&mt('Access Ends').'</th>';
-    my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
-    $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessstart).'</td>';
+    my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend',$tz);
+    if ($dom eq 'gcitest') {
+        $enroll_values .= '<td>'.$tz.'</td>'; 
+    }
+    $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessstart,$tz).'</td>';
     if ($accessend == 0) {
         $enroll_values .= '<td>'.&mt('No end date').'</td>';
     } else {
-        $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessend).'</td>';
+        $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessend,$tz).'</td>';
     }
 
     my $container = 'Course';
@@ -2563,9 +2590,9 @@
 }
 
 sub dates_from_form {
-    my ($startname,$endname) = @_;
-    my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
-    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form($endname);
+    my ($startname,$endname,$timezone) = @_;
+    my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname,$timezone);
+    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form($endname,$timezone);
     if ($endname eq 'accessend') {
         if (exists($env{'form.no_end_date'}) ) {
             $enddate = 0;
@@ -2630,7 +2657,7 @@
                   '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').'&nbsp;'.$title.'</h3>'.
                   &Apache::lonhtmlcommon::row_closure(1).
                   &Apache::lonhtmlcommon::row_title($desctitle).
-                 '<input type="text" size="60" name="cdescr" value="'.$description.'" />';
+                  '<input type="text" size="60" name="cdescr" value="'.$description.'" />';
     my $showclone;
     if ($dom eq 'gcitest') {
         $showclone = &show_cloneable();
@@ -3072,7 +3099,7 @@
             push(@baduname,$uname.':'.$udom);
         }
     }
-    my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
+    my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend',$env{'form.timezone'});
     my $autodrops = 0;
     if ($env{'form.autodrops'}) {
         $autodrops = $env{'form.autodrops'}; 
@@ -3136,6 +3163,7 @@
                     personnel      => \%personnel,
                   };
     if ($dom eq 'gcitest') {
+  
         if ($env{'form.concepttest'} eq 'editmyown') {
             $details->{'firstres'} = 'nav'; 
         } else {
@@ -3248,12 +3276,19 @@
                 }
                 if ($dom eq 'gcitest') {
                     my $caller = 'requestcrs';
+                    my $timezone;
+                    if (&Apache::lonlocal::gettimezone($env{'form.timezone'}) ne 'local') {
+                        $timezone = $env{'form.timezone'};
+                    } else {
+                        $timezone = Apache::lonlocal::gettimezone();
+                    }
                     &acquire_cc_role($dom,$cnum,'cc./'.$dom.'/'.$cnum);
                     my %parmresult =
                         &store_crsparms($dom,$cnum,$now,$accessstart,$accessend);
                     &Apache::londocsgci::setdefaults();
                     my %crsenvhash = (
                                        suppress_tries => 'yes',
+                                       timezone       => $timezone,
                                      );
                     my $putresult =  &Apache::lonnet::put('environment',\%crsenvhash,$dom,$cnum);
                     if ($env{'form.concepttest'} eq 'cloning') {
@@ -3273,8 +3308,8 @@
                                 }
                                 $output .= '<ul>'.
                                            '<li>'.&mt('Access starts:').' '.
-                                                  &Apache::lonlocal::locallocaltime($accessstart).'</li>'.
-                                           '<li>'.&mt('Access ends:').' '.&Apache::lonlocal::locallocaltime($accessend).'</li>'.
+                                                  &Apache::lonlocal::locallocaltime($accessstart,$timezone).'</li>'.
+                                           '<li>'.&mt('Access ends:').' '.&Apache::lonlocal::locallocaltime($accessend,$timezone).'</li>'.
                                            '</ul><br />';
                                 $r->print($output);
                                 $output = '';
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.109.2.10 loncom/interface/lonuserutils.pm:1.109.2.11
--- loncom/interface/lonuserutils.pm:1.109.2.10	Mon Nov 15 17:57:35 2010
+++ loncom/interface/lonuserutils.pm	Mon Nov 29 04:40:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.109.2.10 2010/11/15 17:57:35 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.109.2.11 2010/11/29 04:40:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1223,15 +1223,15 @@
 
 
 sub get_dates_from_form {
-    my ($startname,$endname) = @_;
+    my ($startname,$endname,$timezone) = @_;
     if ($startname eq '') {
         $startname = 'startdate';
     }
     if ($endname eq '') {
         $endname = 'enddate';
     }
-    my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
-    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form($endname);
+    my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname,$timezone);
+    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form($endname,$timezone);
     if ($env{'form.no_end_date'}) {
         $enddate = 0;
     }

--raeburn1291005613--