[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Mon, 07 Dec 2009 17:11:49 -0000


raeburn		Mon Dec  7 17:11:49 2009 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	loncommon.pm 
  Log:
  - Customization for GCI_3.
    - CSS styles for simplified tabbed interface for GCI. 
    - Routines to determine if tabbed interface should be displayed. 
      &needs_gci_custom - checks if user is a Contributor 
      (Inventory/Submissions in gci domain) or CC in course in gcitest domain 
      &check_for_gci_dc - checks if user is DC in gci or gcitest
      &existing_gcitest_courses - gathers information about existing 
                                  Concept Test courses for which user is a CC.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.925 loncom/interface/loncommon.pm:1.925.2.1
--- loncom/interface/loncommon.pm:1.925	Thu Dec  3 17:50:42 2009
+++ loncom/interface/loncommon.pm	Mon Dec  7 17:11:49 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.925 2009/12/03 17:50:42 bisitz Exp $
+# $Id: loncommon.pm,v 1.925.2.1 2009/12/07 17:11:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6419,6 +6419,36 @@
   line-height: 150%;
 }
 
+#gciheader {
+  float:left;
+  width:100%;
+  background:#DAE0D2 url("/gcimenu_bg.gif") repeat-x bottom;
+  font-size:93%;
+  line-height:normal;
+}
+#gciheader ul {
+  margin:0;
+  padding:10px 10px 0;
+  list-style:none;
+}
+#gciheader li {
+  float:left;
+  background:url("/gcimenu_left.gif") no-repeat left top;
+  margin:0;
+  padding:0 0 0 9px;
+}
+#gciheader a {
+  display:block;
+  background:url("/gcimenu_right.gif") no-repeat right top;
+  padding:5px 15px 4px 6px;
+}
+#gciheader #current {
+  background-image:url("/gcimenu_left_on.gif");
+}
+#gciheader #current a {
+  background-image:url("/gcimenu_right_on.gif");
+  padding-bottom:5px;
+}
 
 END
 }
@@ -10681,6 +10711,86 @@
     return ($symb,$enc);
 }
 
+sub needs_gci_custom {
+    my $custommenu;
+    my $numdc = &check_for_gci_dc();
+    unless ($numdc) {
+        my $then=$env{'user.login.time'};
+        my $now = time;
+        my %cnums = (
+                        review => '9615072b469884921gcil1',
+                        submit => '1H96711d710194bfegcil1',
+                    );
+        if ($env{'user.role.st./gci/'.$cnums{'review'}}) {
+            my ($start,$end) =
+                split('.',$env{'user.role.st./gci/'.$cnums{'review'}});
+            if (((!$start) || ($start && $start <= $now)) &&
+                ((!$end) || ($end > $now))) {
+                $custommenu = 1;
+                if ($env{'user.role.cc./gci/'.$cnums{'review'}}) {
+                    my ($ccstart,$ccend) =
+                        split('.',$env{'user.role.cc./gci/'.$cnums{'review'}});
+                    if (((!$start) || ($start && $start <= $now)) &&
+                            ((!$end) || ($end > $now))) {
+                        $custommenu = '';
+                    }
+                }
+            }
+        }
+    }
+    return $custommenu;
+}
+
+sub check_for_gci_dc {
+    my $then=$env{'user.login.time'};
+    my $numdc = 0;
+    foreach my $dom ('gci','gcitest') {
+        if ($env{'user.role.dc./'.$dom.'/'}) {
+            my $livedc = 1;
+            my ($tstart,$tend)=split(/\./,$env{'user.role.dc./'.$dom.'/'});
+            if ($tstart && $tstart>$then) { $livedc = 0; }
+            if ($tend   && $tend  <$then) { $livedc = 0; }
+            if ($livedc) {
+                $numdc++;
+            }
+        }
+    }
+    return $numdc;
+}
+
+sub existing_gcitest_courses {
+    my %courses;
+    my $cdom = 'gcitest';
+    my $role = 'cc';
+    my $now = time;
+    foreach my $envkey (keys(%env)) {
+        my $cnum;
+        if ($envkey =~ m{^user\.role\.\Q$role\E\./\Q$cdom\E/($match_courseid)$}) {
+            $cnum = $1;
+        } else {
+            next;
+        }
+        my ($tstart,$tend) = split(':',$env{$envkey});
+        if (((!$tstart) || ($tstart < $now)) && ((!$tend) || ($tend > $now))) {
+            my %coursehash = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);
+            $courses{$cdom.'_'.$cnum}{'description'} = $coursehash{'description'};
+            $courses{$cdom.'_'.$cnum}{'owner'} = $coursehash{'internal.courseowner'};
+            if (defined($coursehash{'default_enrollment_start_date'}) ) {
+                $courses{$cdom.'_'.$cnum}{'startaccess'} =
+                    &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'});
+            }
+            if (defined($coursehash{'default_enrollment_end_date'}) ) {
+                $courses{$cdom.'_'.$cnum}{'endaccess'} =
+                    &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_end_date'});
+                if ($coursehash{'default_enrollment_end_date'} == 0) {
+                    $courses{$cdom.'_'.$cnum}{'endaccess'} = &mt('No ending date');
+                }
+            }
+        }
+    }
+    return %courses;
+}
+
 =pod
 
 =back