[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm lonhomework.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 17 Mar 2005 21:56:04 -0000


albertel		Thu Mar 17 16:56:04 2005 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm bridgetask.pm 
  Log:
  - skelton of check_task_access there
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.199 loncom/homework/lonhomework.pm:1.200
--- loncom/homework/lonhomework.pm:1.199	Thu Mar 17 16:20:23 2005
+++ loncom/homework/lonhomework.pm	Thu Mar 17 16:56:04 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.199 2005/03/17 21:20:23 albertel Exp $
+# $Id: lonhomework.pm,v 1.200 2005/03/17 21:56:04 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -162,8 +162,11 @@
     $request->print(&Apache::lontexconvert::footer());
 }
 
-$Apache::lonxml::browse='';
+sub proctor_checked_in {
+    return 0;
+}
 
+$Apache::lonxml::browse='';
 sub check_ip_acc {
     my ($acc)=@_;
     if (!defined($acc) || $acc =~ /^\s*$/) { return 1; }
@@ -211,8 +214,39 @@
 }
 
 sub check_task_access {
-    return &check_access;
+    #does it pass normal muster
+    my ($status,$datemsg)=&check_access;
+    if ($status eq 'SHOW_ANSWER' ||
+	$status eq 'CLOSED' ||
+	$status eq 'CANNOT_ANSWER' ||
+	$status eq 'INVALID_ACCESS' ||
+	$status eq 'UNAVAILABLE') {
+	return ($status,$datemsg);
+    }
+
+    
+    my ($id)=@_;
+    my @slots=split(':',&Apache::lonnet::EXT("resource.$id.available"));
+#    if (!@slots) {
+#	return ($status,$datemsg);
+#    }
+    my $slotstatus='NOT_IN_A_SLOT';
+    foreach my $slot (@slots) {
+	my %slot=&Apache::lonnet::get_slot($slot);
+	if ($slot{'starttime'} < time &&
+	    $slot{'endtime'} > time &&
+	    &check_ip_access($slot{'ip'})) {
+	    $slotstatus='IN_A_SLOT';
+	    last;
+	}
+    }
+    if ($slotstatus eq 'IN_A_SLOT' &&
+	&proctor_checked_in()) {
+	$slotstatus='CAN_ANSWER';
+    }
+    return ($slotstatus,$datemsg);
 }
+
 # JB, 9/24/2002: Any changes in this function may require a change
 # in lonnavmaps::resource::getDateStatus.
 sub check_access {
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.2 loncom/homework/bridgetask.pm:1.3
--- loncom/homework/bridgetask.pm:1.2	Thu Mar 17 16:21:11 2005
+++ loncom/homework/bridgetask.pm	Thu Mar 17 16:56:04 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.2 2005/03/17 21:21:11 albertel Exp $
+# $Id: bridgetask.pm,v 1.3 2005/03/17 21:56:04 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -64,6 +64,7 @@
 	if (( $status eq 'CLOSED' ) ||
 	    ( $status eq 'BANNED') ||
 	    ( $status eq 'UNAVAILABLE') ||
+	    ( $status eq 'NOT_IN_A_SLOT') ||
 	    ( $status eq 'INVALID_ACCESS')) {
 	    my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
 	    if ( $target eq "web" ) {
@@ -71,6 +72,10 @@
 		my $msg=$body_tag_start;
 		if ($status eq 'UNAVAILABLE') {
 		    $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
+		} elsif ($status eq 'NOT_IN_A_SLOT') {
+		    $msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>';
+		} elsif ($status eq 'IN_A_SLOT') {
+		    $msg.='<h1>'.&mt('You need the Proctor to validate you.').'</h1>';
 		} elsif ($status ne 'NOT_YET_VIEWED') {
 		    $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
 		}