--- loncom/homework/bridgetask.pm 2006/02/14 16:05:31 1.108
+++ loncom/homework/bridgetask.pm 2006/11/06 17:50:17 1.184.2.4
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.108 2006/02/14 16:05:31 albertel Exp $
+# $Id: bridgetask.pm,v 1.184.2.4 2006/11/06 17:50:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,25 +38,28 @@ use Apache::lonlocal;
use Apache::lonxml;
use Apache::slotrequest();
use Time::HiRes qw( gettimeofday tv_interval );
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
BEGIN {
- &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Instance','InstanceText','Criteria','ClosingParagraph'));
+ &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','GraderNote','ClosingParagraph'));
}
+my %dimension;
sub initialize_bridgetask {
# id of current Dimension, 0 means that no dimension is current
# (inside only)
- $Apache::bridgetask::dimension='';
+ @Apache::bridgetask::dimension=();
# list of all Dimension ids seen
- @Apache::bridgetask::dimensionlist=();
- # mandatory attribute of all Dimensions seen
- %Apache::bridgetask::dimensionmandatory=();
+ %Apache::bridgetask::top_dimensionlist=();
# list of all current Instance ids
- @Apache::bridgetask::instance=();
+ %Apache::bridgetask::instance=();
# list of all Instance ids seen in this problem
@Apache::bridgetask::instancelist=();
# key of queud user data that we are currently grading
$Apache::bridgetask::queue_key='';
+ undef(%dimension);
}
sub proctor_check_auth {
@@ -66,7 +69,7 @@ sub proctor_check_auth {
my @allowed=split(",",$slot->{'proctor'});
foreach my $possible (@allowed) {
- my ($puser,$pdom)=(split('@',$possible));
+ my ($puser,$pdom)=(split(':',$possible));
if ($puser eq $user && $pdom eq $domain) {
my $authenticated=0;
if ( $slot->{'secret'} =~ /\S/ &&
@@ -79,39 +82,90 @@ sub proctor_check_auth {
$authenticated=1;
}
}
- if ($authenticated && $type eq 'Task') {
- # increment version
- my $version=
- $Apache::lonhomework::history{'resource.0.version'};
- $version++;
-
- #clean out all current results
- foreach my $key (keys(%Apache::lonhomework::history)) {
- if ($key=~/^resource\.0\./) {
- $Apache::lonhomework::results{$key}='';
- }
- }
-
- #setup new version and who did it
- $Apache::lonhomework::results{'resource.0.version'}=$version;
- $Apache::lonhomework::results{"resource.$version.0.checkedin"}=
- $user.'@'.$domain;
- $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}=
- $slot_name;
-
+ if ($authenticated) {
+ &check_in($type,$user,$domain,$slot_name);
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;
}
}
}
return 0;
}
+sub check_in {
+ my ($type,$user,$domain,$slot_name) = @_;
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots");
+ if ( $useslots eq 'map_map') {
+ &check_in_sequence($user,$domain,$slot_name);
+ } else {
+ &create_new_version($type,$user,$domain,$slot_name);
+ }
+ return 1;
+}
+
+sub check_in_sequence {
+ my ($user,$domain,$slot_name) = @_;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my ($symb) = &Apache::lonxml::whichuser();
+ my ($map) = &Apache::lonnet::decode_symb($symb);
+ my @resources =
+ $navmap->retrieveResources($map, sub { $_[0]->is_problem() },0,0);
+ my %old_history = %Apache::lonhomework::history;
+ my %old_results = %Apache::lonhomework::results;
+
+ foreach my $res (@resources) {
+ &Apache::lonxml::debug("doing ".$res->src);
+ &Apache::structuretags::initialize_storage($res->symb);
+ my $type = ($res->is_task()) ? 'Task' : 'problem';
+ &create_new_version($type,$user,$domain,$slot_name);
+ &Apache::structuretags::finalize_storage($res->symb);
+ }
+
+ %Apache::lonhomework::history = %old_history;
+ %Apache::lonhomework::results = %old_results;
+}
+
+sub create_new_version {
+ my ($type,$user,$domain,$slot_name) = @_;
+
+ my $id = '0';
+ if ($type eq 'Task') {
+ # increment version
+ my $version=
+ $Apache::lonhomework::history{'resource.0.version'};
+ $version++;
+ &Apache::lonxml::debug("Making version $version");
+ #clean out all current results
+ foreach my $key (keys(%Apache::lonhomework::history)) {
+ if ($key=~/^resource\.0\./) {
+ $Apache::lonhomework::results{$key}='';
+ }
+ }
+
+ #setup new version and who did it
+ $Apache::lonhomework::results{'resource.0.version'}=$version;
+ $id = "$version.0";
+ if (!defined($user) || !defined($domain)) {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ }
+
+ } elsif ($type eq 'problem') {
+ &Apache::lonxml::debug("authed $slot_name");
+ }
+ if (!defined($user) || !defined($domain)) {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ }
+
+ $Apache::lonhomework::results{"resource.$id.checkedin"}=
+ $user.':'.$domain;
+
+ if (defined($slot_name)) {
+ $Apache::lonhomework::results{"resource.$id.checkedin.slot"}=
+ $slot_name;
+ }
+}
+
sub get_version {
my ($version,$previous);
if ($env{'form.previousversion'} &&
@@ -120,7 +174,11 @@ sub get_version {
$version=$env{'form.previousversion'};
$previous=1;
} else {
- $version=$Apache::lonhomework::history{'resource.0.version'};
+ if (defined($Apache::lonhomework::results{'resource.0.version'})) {
+ $version=$Apache::lonhomework::results{'resource.0.version'};
+ } elsif (defined($Apache::lonhomework::history{'resource.0.version'})) {
+ $version=$Apache::lonhomework::history{'resource.0.version'};
+ }
$previous=0;
}
if (wantarray) {
@@ -155,7 +213,7 @@ sub add_previous_version_button {
join("\n\n";
$list.='';
- $result.='
';
+ }
return $result;
}
@@ -222,6 +281,12 @@ sub add_request_another_attempt_button {
if (!$text) { $text="Request another attempt"; }
my $result;
my $symb=&Apache::lonnet::symbread();
+ # not a slot access based resource
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
+ if ($useslots =~ /^\s*no\s*$/i) {
+ return '';
+ }
+
my ($slot_name,$slot)=&Apache::slotrequest::check_for_reservation($symb);
my $action='get_reservation';
if ($slot_name) {
@@ -235,8 +300,8 @@ STUFF
}
if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
- $symb=&Apache::lonnet::escape($symb);
- $result.='