[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm inputtags.pm lonhomework.pm structuretags.pm /publisher packages.tab

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 21 Nov 2005 21:51:30 -0000


This is a MIME encoded message

--albertel1132609890
Content-Type: text/plain

albertel		Mon Nov 21 16:51:30 2005 EDT

  Modified files:              
    /loncom/publisher	packages.tab 
    /loncom/homework	bridgetask.pm inputtags.pm lonhomework.pm 
                    	structuretags.pm 
  Log:
  - de-appendix slots
     - new parm 'useslots' (problems defulat to no, Tasks default to resource)
     - make available and availablestudent exist for problems
     - problems uses check_slot_access
     - problems understand states of 'NOT_IN_A_SLOT' and 'NEEDS_CHECKIN'
  
  
  
--albertel1132609890
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20051121165130.txt"

Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.45 loncom/publisher/packages.tab:1.46
--- loncom/publisher/packages.tab:1.45	Sat Jun  4 13:35:19 2005
+++ loncom/publisher/packages.tab	Mon Nov 21 16:51:17 2005
@@ -29,6 +29,13 @@
 part&ordered&type:string_yesno
 part&ordered&default:no
 part&ordered&display:Show Parts One-at-a-Time
+part_0&useslots&display:Use slot based access controls
+part_0&useslots&type:string_useslots
+part_0&useslots&default:no
+part_0&available&display:Slots of availability
+part_0&available&type:string
+part_0&availablestudent&display:Slots of availability selected by student
+part_0&availablestudent&type:string
 part_0&hiddenparts&display:List of hidden parts
 part_0&hiddenparts&type:string_any
 part_0&hiddenresource&display:Resource hidden from students
@@ -143,6 +150,9 @@
 Task&acc&type:string_ip
 Task&display&display:Task Description
 Task&display&type:string
+Task_0&useslots&display:Use slot based access controls
+Task_0&useslots&type:string_useslots
+Task_0&useslots&default:resource
 Task_0&hiddenresource&display:Resource hidden from students
 Task_0&hiddenresource&type:string_yesno
 Task_0&encrypturl&type:string_yesno
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.80 loncom/homework/bridgetask.pm:1.81
--- loncom/homework/bridgetask.pm:1.80	Mon Nov 21 12:47:37 2005
+++ loncom/homework/bridgetask.pm	Mon Nov 21 16:51:29 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.80 2005/11/21 17:47:37 albertel Exp $
+# $Id: bridgetask.pm,v 1.81 2005/11/21 21:51:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,7 @@
 }
 
 sub proctor_check_auth {
-    my ($slot_name,$slot)=@_;
+    my ($slot_name,$slot,$type)=@_;
     my $user=$env{'form.proctorname'};
     my $domain=$env{'form.proctordomain'};
     
@@ -79,7 +79,7 @@
 		    $authenticated=1;
 		}
 	    }
-	    if ($authenticated) {
+	    if ($authenticated && $type eq 'Task') {
 		my $version=
 		    $Apache::lonhomework::results{'resource.version'}=
 		    ++$Apache::lonhomework::history{'resource.version'};
@@ -93,6 +93,12 @@
 		    }
 		}
 		return 1;
+	    } elsif ($authenticated && $type eq 'problem') {
+		&Apache::lonxml::debug("authed #slot_name");
+		$Apache::lonhomework::results{"resource.0.checkedin"}=
+		    $user.'@'.$domain;
+		$Apache::lonhomework::results{"resource.0.checkedin.slot"}=
+		    $slot_name;
 	    }
 	}
     }
@@ -416,7 +422,7 @@
 	$target eq 'tex') {
 	my ($version,$previous)=&get_version();
 	($status,$accessmsg,my $slot_name,$slot) = 
-	    &Apache::lonhomework::check_task_access('0');
+	    &Apache::lonhomework::check_slot_access('0','Task');
 	push(@Apache::inputtags::status,$status);
 	$Apache::inputtags::slot_name=$slot_name;
 	my $expression='$external::datestatus="'.$status.'";';
@@ -470,7 +476,7 @@
 		}
 	    } elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
 		if ($status eq 'NEEDS_CHECKIN') {
-		    if(&proctor_check_auth($slot_name,$slot)) {
+		    if(&proctor_check_auth($slot_name,$slot,'Task')) {
 			my $result=&add_to_queue('gradingqueue',
 						 $Apache::inputtags::slot_name);
 			&Apache::lonxml::debug("add_to_queue said $result");
@@ -525,19 +531,23 @@
 	} else {
 	    if ($target eq 'webgrade') {
 		$result.="\n";
+		my $back='<p><a href="/adm/flip?postdata=return:">'.
+		    &mt('Return to resource').'</a></p>';
 		if      ($status_code eq 'stop') {
-		    $result.='<b>'.&mt("Stopped grading.").'</b>';
+		    $result.='<b>'.&mt("Stopped grading.").'</b>'.$back;
 		} elsif ($status_code eq 'lock_failed') {
-		    $result.='<b>'.&mt("Failed to lock the request record.").'</b>';
+		    $result.='<b>'.&mt("Failed to lock the request record.")
+			.'</b>'.$back;
 		} elsif ($status_code eq 'unlock') {
-		    $result.='<b>'.&mt("Unlocked the requested record.").'</b>';
+		    $result.='<b>'.&mt("Unlocked the requested record.")
+			.'</b>'.$back;
 		    $result.=&show_queue($env{'form.queue'},1);
 		} elsif ($status_code eq 'show_list') {
 		    $result.=&show_queue($env{'form.queue'},1);
 		} elsif ($status_code eq 'select_user') {
 		    $result.=&select_user();
 		} else {
-		    $result.='<b>'.&mt("No user to be graded.").'</b>';
+		    $result.='<b>'.&mt("No user to be graded.").'</b>'.$back;
 		}
 	    }
 	    $webgrade='no';
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.182 loncom/homework/inputtags.pm:1.183
--- loncom/homework/inputtags.pm:1.182	Wed Nov 16 18:17:39 2005
+++ loncom/homework/inputtags.pm	Mon Nov 21 16:51:29 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.182 2005/11/16 23:17:39 albertel Exp $
+# $Id: inputtags.pm,v 1.183 2005/11/21 21:51:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -846,8 +846,11 @@
 
     my $status = $Apache::inputtags::status['-1'];
     &Apache::lonxml::debug("gradestatus has :$status:");
-    if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE' &&
-	 $status ne 'INVALID_ACCESS') {  
+    if ( $status ne 'CLOSED' 
+	 && $status ne 'UNAVAILABLE' 
+	 && $status ne 'INVALID_ACCESS' 
+	 && $status ne 'NEEDS_CHECKIN' 
+	 && $status ne 'NOT_IN_A_SLOT') {  
 	my $award = $Apache::lonhomework::history{"resource.$id.award"};
 	my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"};
 	my $solved = $Apache::lonhomework::history{"resource.$id.solved"};
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.225 loncom/homework/lonhomework.pm:1.226
--- loncom/homework/lonhomework.pm:1.225	Tue Nov 15 16:39:33 2005
+++ loncom/homework/lonhomework.pm	Mon Nov 21 16:51:29 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.225 2005/11/15 21:39:33 albertel Exp $
+# $Id: lonhomework.pm,v 1.226 2005/11/21 21:51:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -166,17 +166,24 @@
 }
 
 sub proctor_checked_in {
-    my ($slot_name,$slot)=@_;
-    my @allowed=split(",",$slot->{'proctor'});
-    my $version=$Apache::lonhomework::history{'resource.version'};
-    foreach my $possible (@allowed) { 
-	if ($Apache::lonhomework::history{"resource.$version.checkedin"} eq
-	    $possible &&
-	    $Apache::lonhomework::history{"resource.$version.checkedin.slot"}
-	       eq $slot_name) {
+    my ($slot_name,$slot,$type)=@_;
+    my @possible_proctors=split(",",$slot->{'proctor'});
+    
+    my $key;
+    if ($type eq 'Task') {
+	my $version=$Apache::lonhomework::history{'resource.version'};
+	$key ="resource.$version.checkedin";
+    } elsif ($type eq 'problem') {
+	$key ='resource.0.checkedin';
+    }
+    
+    foreach my $possible (@possible_proctors) { 
+	if ($Apache::lonhomework::history{$key} eq $possible
+	    && $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) {
 	    return 1;
 	}
     }
+    
     return 0;
 }
 
@@ -230,10 +237,17 @@
     return $allowed;
 }
 
-sub check_task_access {
+sub check_slot_access {
+    my ($id,$type)=@_;
+
     # does it pass normal muster
-    # yes we really do want the default args passing
-    my ($status,$datemsg)=&check_access;
+    my ($status,$datemsg)=&check_access($id);
+    
+    my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");
+    if ($useslots ne 'resource') {
+	return ($status,$datemsg);
+    }
+
     if ($status eq 'SHOW_ANSWER' ||
 	$status eq 'CLOSED' ||
 	$status eq 'INVALID_ACCESS' ||
@@ -243,12 +257,15 @@
     if ($env{'request.state'} eq "construct") {
 	return ($status,$datemsg);
     }
-    my $version=$Apache::lonhomework::history{'resource.version'};
-    if ($Apache::lonhomework::history{"resource.$version.checkedin"} &&
-	$Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
-	return ('SHOW_ANSWER');
+    
+    if ($type eq 'Task') {
+	my $version=$Apache::lonhomework::history{'resource.version'};
+	if ($Apache::lonhomework::history{"resource.$version.checkedin"} &&
+	    $Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
+	    return ('SHOW_ANSWER');
+	}
     }
-    my ($id)=@_;
+
     my @slots=
 	(split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")),
 	 split(':',&Apache::lonnet::EXT("resource.$id.available")));
@@ -273,17 +290,32 @@
 	}
     }
     if ($slotstatus eq 'NEEDS_CHECKIN' &&
-	&proctor_checked_in($slot_name,$returned_slot)) {
+	&proctor_checked_in($slot_name,$returned_slot,$type)) {
 	&Apache::lonxml::debug("protoctor checked in");
 	$slotstatus='CAN_ANSWER';
     }
-    if ( $slotstatus eq 'NOT_IN_A_SLOT' && 
-	$Apache::lonhomework::history{"resource.$version.checkedin"}) {
-	if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
+
+    my ($pass_status,$checkedin);
+    if ($type eq 'Task') {
+	my $version=$Apache::lonhomework::history{'resource.version'};
+	$pass_status = 
+	    $Apache::lonhomework::history{"resource.$version.status"} eq 'fail';
+	$checkedin =
+	    $Apache::lonhomework::history{"resource.$version.checkedin"};
+    } elsif ($type eq 'problem') {
+	$pass_status = 1;
+	$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"};
+    }
+    
+    if ($slotstatus eq 'NOT_IN_A_SLOT' 
+	&& $checkedin ) {
+
+	if ($pass_status) {
 	    return ('SHOW_ANSWER');
 	} else {
 	    return ('WAITING_FOR_GRADE');
 	}
+
     }
     if ( $status eq 'CANNOT_ANSWER' && 
 	 ($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) {
@@ -301,7 +333,6 @@
     my $status;
     my $datemsg = '';
     my $lastdate = '';
-    my $temp;
     my $type;
     my $passed;
 
@@ -338,7 +369,7 @@
 	    return($status,$date);
 	}
 	
-	foreach $temp ("opendate","duedate","answerdate") {
+	foreach my $temp ("opendate","duedate","answerdate") {
 	    $lastdate = $date;
 	    $date = &Apache::lonnet::EXT("resource.$id.$temp");
 	    my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.323 loncom/homework/structuretags.pm:1.324
--- loncom/homework/structuretags.pm:1.323	Fri Nov 18 15:29:13 2005
+++ loncom/homework/structuretags.pm	Mon Nov 21 16:51:29 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.323 2005/11/18 20:29:13 albertel Exp $
+# $Id: structuretags.pm,v 1.324 2005/11/21 21:51:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -613,17 +613,22 @@
 	    }
 	    $form_tag_start.='<hr />';
 	}
-	($status,$accessmsg) = &Apache::lonhomework::check_access('0');
+
+	($status,$accessmsg,my $slot_name,my $slot) = 
+	    &Apache::lonhomework::check_slot_access('0','problem');
 	push (@Apache::inputtags::status,$status);
+
 	my $expression='$external::datestatus="'.$status.'";';
 	$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
 	&Apache::run::run($expression,$safeeval);
 	&Apache::lonxml::debug("Got $status");
+
 	if (( $status eq 'CLOSED' ) ||
 	    ( $status eq 'UNCHECKEDOUT') ||
 	    ( $status eq 'NOT_YET_VIEWED') ||
 	    ( $status eq 'BANNED') ||
 	    ( $status eq 'UNAVAILABLE') ||
+	    ( $status eq 'NOT_IN_A_SLOT') ||
 	    ( $status eq 'INVALID_ACCESS')) {
 	    my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
 	    if ( $target eq "web" ) {
@@ -650,6 +655,16 @@
 		    $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
 		}
 	    }
+	} elsif ($status eq 'NEEDS_CHECKIN') {
+	    my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
+	    if ($target eq 'web') {
+		$result .= $head_tag_start.'</head>';
+		$result .= $body_tag_start;
+		$result .= &Apache::bridgetask::proctor_validation_screen();
+	    } elsif ($target eq 'grade') {
+		&Apache::bridgetask::proctor_check_auth($slot_name,$slot,
+							'problem');
+	    }
 	} elsif ($target eq 'web') {
 	    my $name= &get_resource_name($parstack,$safeeval);
 	    $result.="$head_tag_start<title>$name</title></head>
@@ -792,6 +807,8 @@
 	    # if part is zero, no <part>s existed, so we need to the grading
 	    if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {
 		&Apache::inputtags::grade;
+	    } elsif ($status eq 'NEEDS_CHECKIN') {
+		# no need to grade, and don't want to hide data
 	    } else {
 		# move any submission data to .hidden
 		&Apache::inputtags::hidealldata($Apache::inputtags::part);

--albertel1132609890--