--- loncom/homework/bridgetask.pm 2005/05/24 22:06:39 1.31
+++ loncom/homework/bridgetask.pm 2006/02/14 16:05:31 1.108
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.31 2005/05/24 22:06:39 albertel Exp $
+# $Id: bridgetask.pm,v 1.108 2006/02/14 16:05:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,7 @@ use Apache::File();
use Apache::lonmenu;
use Apache::lonlocal;
use Apache::lonxml;
+use Apache::slotrequest();
use Time::HiRes qw( gettimeofday tv_interval );
BEGIN {
@@ -59,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'};
@@ -67,21 +68,44 @@ 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') {
+ # increment version
my $version=
- $Apache::lonhomework::results{'resource.version'}=
- ++$Apache::lonhomework::history{'resource.version'};
- $Apache::lonhomework::results{"resource.$version.checkedin"}=
- $user.'@'.$domain;
- $Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
- $slot_name;
+ $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;
+
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;
}
}
}
@@ -91,11 +115,12 @@ sub proctor_check_auth {
sub get_version {
my ($version,$previous);
if ($env{'form.previousversion'} &&
- defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
+ $env{'form.previousversion'} ne 'current' &&
+ 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) {
@@ -107,10 +132,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 '';
}
@@ -121,14 +146,15 @@ 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);
}
}
my $list='\n\n";
+ $list.='';
$result.='
';
return $result;
}
@@ -166,13 +257,160 @@ sub preserve_grade_info {
return $result;
}
+sub style {
+ return (<
+STYLE
+
+}
+
+sub show_task {
+ my ($status,$previous)=@_;
+ if (!$previous && (
+ ( $status eq 'CLOSED' ) ||
+ ( $status eq 'BANNED') ||
+ ( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NEEDS_CHECKIN') ||
+ ( $status eq 'WAITING_FOR_GRADE') ||
+ ( $status eq 'INVALID_ACCESS') )) {
+ return 0;
+ }
+ if ($env{'form.donescreen'}) { return 0; }
+ return 1;
+}
+
+sub internal_location {
+ my ($id)=@_;
+ return '';
+}
+
+sub submission_time_stamp {
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my $submissiontime;
+ 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'};
+ }
+ }
+ my $result;
+ if ($submissiontime) {
+ 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)=('#FF6666','after');
+ if ($diff > 0) { ($color,$when)=('#336600','before'); }
+ my $info;
+ if ($diff%60) { $info=($diff%60).' seconds'; }
+ $diff=int($diff/60);
+ if ($diff%60) { $info=($diff%60).' minutes '.$info; }
+ $diff=int($diff/60);
+ if ($diff) { $info=$diff.' hours '.$info; }
+ $result='
'.
+ &mt('Student submitted [_1] [_2] the deadline.
+ (Submission was at [_3], end of period was [_4].)',
+ $info,$when,scalar(localtime($submissiontime)),
+ scalar(localtime($slot{'endtime'}))).
+ '
';
+ }
+ return $result;
+}
+
+sub webgrade_standard_info {
+ my ($version)=&get_version();
+ my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
+ my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
+ my $file_list="
\n";
+ foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
+ my $file=$file_url.$partial_file;
+ $file=~s|/+|/|g;
+ &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
+ $file_list.='
'.&mt('Your submission is in the grading queue.').'
';
+ } elsif ($env{'form.donescreen'}) {
+ my $title=&Apache::lonnet::gettitle();
+ my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'});
+ my $files='
+DONESCREEN
} elsif ($status ne 'NOT_YET_VIEWED') {
$msg.='
'.&mt('Not open to be viewed').'
';
}
@@ -237,72 +505,118 @@ sub start_Task {
}
} elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- if (&proctor_check_auth($slot_name,$slot)) {
- #FIXME immeadiatly add this to the grading queue
- # with slot->{'endtime'} for when grading can
- # begin on this resource
- # FIXME I think the above is done by default,
- # need to check that
- # failure doesn't do this.
- }
+ if(&proctor_check_auth($slot_name,$slot,'Task')
+ && defined($Apache::inputtags::slot_name)) {
+ my $result=&add_to_queue('gradingqueue',
+ [$Apache::inputtags::slot_name]);
+ &Apache::lonxml::debug("add_to_queue said $result");
+ }
}
}
} elsif ($target eq 'web') {
my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
$result.="$head_tag_start$name
- $body_tag_start \n $form_tag_start".
- '';
+ $body_tag_start \n".&style();
+
$result.=&preserve_grade_info();
- my ($version,$previous)=&get_version();
- if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
- $result.='
'.&mt('Did not pass').'
';
- if (!$previous) {
- $result.=&add_request_another_attempt_button();
- }
- }
- if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
- $result.='
'.&mt('Passed').'
';
- }
+ $result.=&internal_location();
+ $result.=$form_tag_start.
+ '';
+ &Apache::lonxml::startredirection();
}
} elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
$target eq 'webgrade') {
+ my $webgrade='yes';
if ($target eq 'webgrade') {
- $result.=$head_tag_start.$body_tag_start.$form_tag_start;
- $result.='';
- $result.=' Review'.&show_queue('reviewqueue');
- $result.=' Before'.&show_queue('gradingqueue');
- }
- my $todo;
- # don't get something new from the queue if they hit the stop button
- if (!($env{'form.stop'} && $target eq 'webgrade')) {
- $todo=&get_from_queue('gradingqueue');
- }
+ $result.=$head_tag_start.$body_tag_start;
+ #$result.=' Review'.&show_queue('reviewqueue');
+ #$result.=' Grade'.&show_queue('gradingqueue');
+ }
+ # FIXME Blast! still need to reorg this, need to reshow the
+ # queue being reviewed once done with the grade pass...
+ # Hrrm, vaildation pass should perhaps say 'not_locked'
+ # perhaps do a search if there is a key that is mine and if
+ # there isn't reshow the queue....
+ my ($todo,$status_code,$msg)=&get_key_todo($target);
+
if ($todo) {
&setup_env_for_other_user($todo,$safeeval);
my ($symb,$uname,$udom)=&decode_queue_key($todo);
$result.="\n".'
Found '.
&Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'
';
- $result.='';
$Apache::bridgetask::queue_key=$todo;
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
if ($target eq 'webgrade') {
- $result.=' After'.&show_queue('gradingqueue');
+ #$result.=' After -'.&show_queue($env{'form.queue'});
$result.="\n".'
'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'
').
"
";
+ }
+ if (!$previous && $status ne 'SHOW_ANSWER' &&
+ &show_task($status,$previous)) {
$result.=&Apache::inputtags::gradestatus('0');
+ $result.='';
+ $result.=<
+
+
+
+DONEBUTTON
+ }
+ if (&show_task($status,$previous) &&
+ $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_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 = "\n
\n";
+
+ if ($bt_status eq 'pass') {
+ $status.='
You passed the '.$title.' given on '.
+ $start_time.'
';
+ }
+ if ($bt_status eq 'fail') {
+ $status.='
You did not pass the '.$title.' given on '.
+ $start_time.'
';
+ if (!$previous) {
+ $status.=&add_request_another_attempt_button();
+ }
+ }
+ my $man_count=0;
+ my $opt_count=0;
+ my $opt_passed=0;
+ foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ if ($Apache::bridgetask::dimensionmandatory{$dim_id}
+ eq 'N') {
+ $opt_count++;
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') {
+ $opt_passed++;
+ }
+ } else {
+ $man_count++;
+ }
+ }
+ my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($opt_req !~ /\S/) { $opt_req='0'; }
+ $status.="\n
".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components, of which you passed [_4].',$man_count,$opt_req,$opt_count,$opt_passed)."