[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework lonhomework.pm

raeburn raeburn at source.lon-capa.org
Mon Aug 8 08:07:20 EDT 2016


raeburn		Mon Aug  8 12:07:20 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	lonhomework.pm 
  Log:
  - For 2.11
    - Backport 1.356.
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.344.2.3 loncom/homework/lonhomework.pm:1.344.2.4
--- loncom/homework/lonhomework.pm:1.344.2.3	Sat Aug  6 23:23:18 2016
+++ loncom/homework/lonhomework.pm	Mon Aug  8 12:07:20 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.344.2.3 2016/08/06 23:23:18 raeburn Exp $
+# $Id: lonhomework.pm,v 1.344.2.4 2016/08/08 12:07:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -208,12 +208,12 @@
 }
 
 sub check_slot_access {
-    my ($id,$type,$partlist)=@_;
+    my ($id,$type,$symb,$partlist)=@_;
 
     # does it pass normal muster
-    my ($status,$datemsg)=&check_access($id);
+    my ($status,$datemsg)=&check_access($id,$symb);
     
-    my $useslots = &Apache::lonnet::EXT("resource.0.useslots");
+    my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
     if ($useslots ne 'resource' && $useslots ne 'map' 
 	&& $useslots ne 'map_map') {
 	return ($status,$datemsg);
@@ -237,8 +237,8 @@
 	}
     }
 
-    my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent");
-    my $available = &Apache::lonnet::EXT("resource.0.available");
+    my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent",$symb);
+    my $available = &Apache::lonnet::EXT("resource.0.available",$symb);
     my @slots= (split(':',$availablestudent),split(':',$available));
 
 #    if (!@slots) {
@@ -248,6 +248,9 @@
     my ($returned_slot,$slot_name);
     my $now = time;
     my $num_usable_slots = 0;
+    unless ($symb) {
+        ($symb) = &Apache::lonnet::whichuser();
+    }
     foreach my $slot (@slots) {
 	$slot =~ s/(^\s*|\s*$)//g;
 	&Apache::lonxml::debug("getting $slot");
@@ -271,9 +274,10 @@
 	$slotstatus=$status;
     }
 
-    my ($is_correct,$got_grade,$checkinslot,$checkedin,$consumed_uniq);
+    my ($is_correct,$got_grade,$checkin,$checkinslot,$checkedin,$consumed_uniq);
     if ($type eq 'Task') {
 	my $version=$Apache::lonhomework::history{'resource.0.version'};
+        $checkin = "resource.$version.0.checkedin";
 	$got_grade = 
 	    ($Apache::lonhomework::history{"resource.$version.0.status"} 
 	     =~ /^(?:pass|fail)$/);
@@ -283,7 +287,8 @@
 	$checkedin =
 	    $Apache::lonhomework::history{"resource.$version.0.checkedin"};
     } elsif ($type eq 'problem') {
-	$checkedin  = $Apache::lonhomework::history{"resource.0.checkedin"};
+        $checkin = 'resource.0.checkedin';
+	$checkedin  = $Apache::lonhomework::history{$checkin};
     }
     if ($checkedin) {
         $checkinslot = $Apache::lonhomework::history{"$checkin.slot"};
@@ -356,7 +361,6 @@
                 if ($env{'request.course.id'}) {
                     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-                    my ($symb)=&Apache::lonnet::whichuser();
                     $slotstatus = 'NOTRESERVABLE';
                     my ($reservable_now_order,$reservable_now,$reservable_future_order,
                         $reservable_future) = 
@@ -452,7 +456,7 @@
 # JB, 9/24/2002: Any changes in this function may require a change
 # in lonnavmaps::resource::getDateStatus.
 sub check_access {
-    my ($id) = @_;
+    my ($id,$symb) = @_;
     my $date ='';
     my $status;
     my $datemsg = '';
@@ -482,11 +486,13 @@
     &Apache::lonxml::debug("checking for part :$id:");
     &Apache::lonxml::debug("time:".time);
 
-    my ($symb)=&Apache::lonnet::whichuser();
+    unless ($symb) {
+        ($symb)=&Apache::lonnet::whichuser();
+    }
     &Apache::lonxml::debug("symb:".$symb);
     #if ($env{'request.state'} ne "construct" && $symb ne '') {
     if ($env{'request.state'} ne "construct") {
-        my $idacc = &Apache::lonnet::EXT("resource.$id.acc");
+        my $idacc = &Apache::lonnet::EXT("resource.$id.acc",$symb);
 	my $allowed=&Apache::loncommon::check_ip_acc($idacc);
 	if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {
 	    $status='INVALID_ACCESS';
@@ -502,12 +508,12 @@
 	foreach my $temp ("opendate","duedate","answerdate") {
 	    $lastdate = $date;
 	    if ($temp eq 'duedate') {
-		$date = &due_date($id);
+		$date = &due_date($id,$symb);
 	    } else {
-		$date = &Apache::lonnet::EXT("resource.$id.$temp");
+		$date = &Apache::lonnet::EXT("resource.$id.$temp",$symb);
 	    }
 	    
-	    my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
+	    my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type",$symb);
 	    if ($thistype =~ /^(con_lost|no_such_host)/ ||
 		$date     =~ /^(con_lost|no_such_host)/) {
 		$status='UNAVAILABLE';
@@ -516,10 +522,10 @@
 	    }
 	    if ($thistype eq 'date_interval') {
 		if ($temp eq 'opendate') {
-		    $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date;
+		    $date=&Apache::lonnet::EXT("resource.$id.duedate",$symb)-$date;
 		}
 		if ($temp eq 'answerdate') {
-		    $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date;
+		    $date=&Apache::lonnet::EXT("resource.$id.duedate",$symb)+$date;
 		}
 	    }
 	    &Apache::lonxml::debug("found :$date: for :$temp:");
@@ -553,7 +559,7 @@
 	(($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED'))) {
 	#check #tries, and if correct.
 	my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
-	my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
+	my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries",$symb);
 	if ( $tries eq '' ) { $tries = '0'; }
 	if ( $maxtries eq '' && 
 	     $env{'request.state'} ne 'construct') { $maxtries = '2'; } 
@@ -562,7 +568,7 @@
 	if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/)
 	      && (&show_problem_status()) ) {
             if (($Apache::lonhomework::history{"resource.$id.awarded"} >= 1) ||
-                (&Apache::lonnet::EXT("resource.$id.retrypartial") !~/^1|on|yes$/i)) {
+                (&Apache::lonnet::EXT("resource.$id.retrypartial",$symb) !~/^1|on|yes$/i)) {
 	        $status = 'CANNOT_ANSWER';
             }
         } elsif ($Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
@@ -574,14 +580,14 @@
 	}
     }
     if ($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER') {
-	my @interval=&Apache::lonnet::EXT("resource.$id.interval");
+	my @interval=&Apache::lonnet::EXT("resource.$id.interval",$symb);
 	&Apache::lonxml::debug("looking for interval @interval");
 	if ($interval[0]) {
-	    my $first_access=&Apache::lonnet::get_first_access($interval[1]);
+	    my $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
 	    &Apache::lonxml::debug("looking for accesstime $first_access");
 	    if (!$first_access) {
 		$status='NOT_YET_VIEWED';
-		my $due_date = &due_date($id);
+		my $due_date = &due_date($id,$symb);
 		my $seconds_left = $due_date - time;
 		if ($seconds_left > $interval[0] || $due_date eq '') {
 		    $seconds_left = $interval[0];




More information about the LON-CAPA-cvs mailing list