--- loncom/homework/bridgetask.pm 2005/10/14 16:23:39 1.70
+++ loncom/homework/bridgetask.pm 2005/12/20 18:09:49 1.89
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.70 2005/10/14 16:23:39 albertel Exp $
+# $Id: bridgetask.pm,v 1.89 2005/12/20 18:09:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ sub initialize_bridgetask {
}
sub proctor_check_auth {
- my ($slot_name,$slot)=@_;
+ my ($slot_name,$slot,$type)=@_;
my $user=$env{'form.proctorname'};
my $domain=$env{'form.proctordomain'};
@@ -68,14 +68,24 @@ sub proctor_check_auth {
foreach my $possible (@allowed) {
my ($puser,$pdom)=(split('@',$possible));
if ($puser eq $user && $pdom eq $domain) {
- my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
- if ($authhost ne 'no_host') {
+ my $authenticated=0;
+ if ( $slot->{'secret'} =~ /\S/ &&
+ $env{'form.proctorpassword'} eq $slot->{'secret'} ) {
+ $authenticated=1;
+ } else {
+
+ my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
+ if ($authhost ne 'no_host') {
+ $authenticated=1;
+ }
+ }
+ if ($authenticated && $type eq 'Task') {
my $version=
- $Apache::lonhomework::results{'resource.version'}=
- ++$Apache::lonhomework::history{'resource.version'};
- $Apache::lonhomework::results{"resource.$version.checkedin"}=
+ $Apache::lonhomework::results{'resource.0.version'}=
+ ++$Apache::lonhomework::history{'resource.0.version'};
+ $Apache::lonhomework::results{"resource.$version.0.checkedin"}=
$user.'@'.$domain;
- $Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
+ $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}=
$slot_name;
foreach my $key (keys(%Apache::lonhomework::history)) {
if ($key=~/^resource\.0\./) {
@@ -83,6 +93,12 @@ sub proctor_check_auth {
}
}
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;
}
}
}
@@ -93,11 +109,11 @@ sub get_version {
my ($version,$previous);
if ($env{'form.previousversion'} &&
$env{'form.previousversion'} ne 'current' &&
- defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
+ defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.0.status'})) {
$version=$env{'form.previousversion'};
$previous=1;
} else {
- $version=$Apache::lonhomework::history{'resource.version'};
+ $version=$Apache::lonhomework::history{'resource.0.version'};
$previous=0;
}
if (wantarray) {
@@ -109,10 +125,10 @@ sub get_version {
sub add_previous_version_button {
my ($status)=@_;
my $result;
- if ($Apache::lonhomework::history{'resource.version'} eq '') {
+ if ($Apache::lonhomework::history{'resource.0.version'} eq '') {
return '';
}
- if ($Apache::lonhomework::history{'resource.version'} < 2 &&
+ if ($Apache::lonhomework::history{'resource.0.version'} < 2 &&
$status ne 'NEEDS_CHECKIN') {
return '';
}
@@ -123,8 +139,8 @@ sub add_previous_version_button {
"\n";
}
my @to_show;
- foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) {
- if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) {
+ foreach my $test_version (1..$Apache::lonhomework::history{'resource.0.version'}) {
+ if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.0.status'})) {
push(@to_show,$test_version);
}
}
@@ -306,7 +322,7 @@ sub internal_location {
sub submission_time_stamp {
my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
my $submissiontime;
- my $version=$Apache::lonhomework::history{'resource.version'};
+ my $version=$Apache::lonhomework::history{'resource.0.version'};
for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) {
if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})) {
$submissiontime=$Apache::lonhomework::history{$v.':timestamp'};
@@ -314,11 +330,11 @@ sub submission_time_stamp {
}
my $result;
if ($submissiontime) {
- my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.checkedin.slot'};
+ my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.0.checkedin.slot'};
my %slot=&Apache::lonnet::get_slot($slot_name);
my $diff = $slot{'endtime'} - $submissiontime;
- my ($color,$when)=('red','after');
- if ($diff > 0) { ($color,$when)=('green','before'); }
+ my ($color,$when)=('#FF6666','after');
+ if ($diff > 0) { ($color,$when)=('#336600','before'); }
my $info;
if ($diff%60) { $info=($diff%60).' seconds'; }
$diff=int($diff/60);
@@ -344,7 +360,7 @@ sub webgrade_standard_info {
my $file=$file_url.$partial_file;
$file=~s|/+|/|g;
&Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
- $file_list.='
'.$file.
''."\n";
}
@@ -365,13 +381,16 @@ INFO
}
sub start_Task {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my ($status,$accessmsg,$slot);
if ($target ne 'webgrade') {
&Apache::structuretags::init_problem_globals('Task');
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
+ if ($env{'request.state'} eq 'construct') {
+ &Apache::structuretags::setup_rndseed($safeeval);
+ }
}
$Apache::lonhomework::parsing_a_task=1;
@@ -379,7 +398,7 @@ sub start_Task {
my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
&Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
- if ($target eq 'web') {
+ if ($target eq 'web' && $env{'request.state'} ne 'construct') {
if ($Apache::lonhomework::modifygrades) {
$body_tag_start.='';
$result.=<
DONEBUTTON
- }
+ }
if (&show_task($status,$previous) &&
- $Apache::lonhomework::history{"resource.$version.status"} =~ /^(pass|fail)$/) {
- my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
+ $Apache::lonhomework::history{"resource.$version.0.status"} =~ /^(pass|fail)$/) {
+ my $bt_status=$Apache::lonhomework::history{"resource.$version.0.status"};
my $title=&Apache::lonnet::gettitle();
- my %slot=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
+
+ my $slot_name=
+ $Apache::lonhomework::history{"resource.$version.0.checkedin.slot"};
+ my %slot=&Apache::lonnet::get_slot($slot_name);
my $start_time=
&Apache::lonlocal::locallocaltime($slot{'starttime'});
- my $status;
- $status.="\n\n";
+ my $status = "\n
\n";
if ($bt_status eq 'pass') {
$status.='
You passed the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
}
if ($bt_status eq 'fail') {
$status.='You did not pass the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
if (!$previous) {
$status.=&add_request_another_attempt_button();
}
@@ -702,7 +747,7 @@ DONEBUTTON
if ($Apache::bridgetask::dimensionmandatory{$dim_id}
eq 'N') {
$opt_count++;
- if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') {
$opt_passed++;
}
} else {
@@ -739,12 +784,16 @@ DONEBUTTON
$Apache::lonhomework::results{"resource.$version.0.submission"}='';
} else {
delete($Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"});
+ $award = '';
}
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
- if ($award eq 'SUBMITTED') {
- &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
+ if ($award eq 'SUBMITTED'
+ && defined($Apache::inputtags::slot_name)) {
+ &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
}
+ } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
+ &Apache::structuretags::finalize_storage();
}
if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
my $optional_required=
@@ -757,7 +806,7 @@ DONEBUTTON
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
my $status=
- $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
+ $Apache::lonhomework::results{"resource.$version.0.$dim_id.status"};
my $mandatory=
($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
if ($status eq 'pass') {
@@ -776,10 +825,10 @@ DONEBUTTON
$mandatory_failed++;
}
&Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
- $Apache::lonhomework::results{'resource.grader'}=
+ $Apache::lonhomework::results{'resource.0.regrader'}=
$env{'user.name'}.'@'.$env{'user.domain'};
if ($review) {
- $Apache::lonhomework::results{"resource.$version.status"}='review';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='review';
if ($env{'form.queue'} eq 'reviewqueue') {
&check_queue_unlock($env{'form.queue'});
&Apache::lonxml::debug(" still needs review not changing status.");
@@ -787,7 +836,7 @@ DONEBUTTON
&move_between_queues($env{'form.queue'},'reviewqueue');
}
} elsif ($ungraded) {
- $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='ungraded';
if ($env{'form.queue'} eq 'reviewqueue' ||
$env{'form.queue'} eq 'none' ) {
&Apache::lonxml::debug("moving back.");
@@ -796,7 +845,7 @@ DONEBUTTON
&check_queue_unlock($env{'form.queue'});
}
} elsif ($mandatory_failed) {
- $Apache::lonhomework::results{"resource.$version.status"}='fail';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='fail';
$Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
@@ -814,7 +863,7 @@ DONEBUTTON
["$version.0.bridgetask"]);
}
} else {
- $Apache::lonhomework::results{"resource.$version.status"}='pass';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='pass';
$Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
@@ -831,8 +880,8 @@ DONEBUTTON
["$version.0.bridgetask"]);
}
}
- $Apache::lonhomework::results{"resource.status"}=
- $Apache::lonhomework::results{"resource.$version.status"};
+ $Apache::lonhomework::results{"resource.0.status"}=
+ $Apache::lonhomework::results{"resource.$version.0.status"};
if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
$Apache::lonhomework::results{"resource.0.award"}=
$Apache::lonhomework::results{"resource.$version.0.award"};
@@ -856,13 +905,14 @@ DONEBUTTON
$result.=''.&Apache::loncommon::endbodytag().'