--- loncom/homework/bridgetask.pm 2005/09/30 20:34:53 1.57
+++ loncom/homework/bridgetask.pm 2006/01/30 21:01:46 1.99
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.57 2005/09/30 20:34:53 albertel Exp $
+# $Id: bridgetask.pm,v 1.99 2006/01/30 21:01:46 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,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;
}
}
}
@@ -93,11 +116,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 +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 '';
}
@@ -123,8 +146,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);
}
}
@@ -144,11 +167,28 @@ sub add_previous_version_button {
}
sub add_grading_button {
+ my (undef,$cid)=&Apache::lonxml::whichuser();
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
+ my %sections;
+ my $numsections=&Apache::loncommon::get_sections($cdom,$cnum,\%sections);
+ my $size=5;
+ if (scalar(keys(%sections)) < 3) {
+ $size=scalar(keys(%sections))+2;
+ }
+ my $sec_select = '\n";
+
my $result=' ';
$result.='';
if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
+ $result.='
Specify a section: '.$sec_select.'
';
$result.='
'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
$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.='
\n";
+
+ my %lt=&Apache::lonlocal::texthash('done' => 'Done',
+ 'stop' => 'Stop',
+ );
+
+ my $result=<
+
+
+ $file_list
+
+INFO
+ return $result;
+}
+
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;
@@ -299,7 +405,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();
}
@@ -593,7 +767,7 @@ sub end_Task {
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 {
@@ -603,7 +777,7 @@ sub end_Task {
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 on the bridge task.',$man_count,$opt_req,$opt_count)."
\n";
+ $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)."
\n";
my $internal_location=&internal_location();
$result=~s/\Q$internal_location\E/$status/;
@@ -628,12 +802,18 @@ sub end_Task {
$award;
$Apache::lonhomework::results{"resource.0.submission"}=
$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=
@@ -646,7 +826,7 @@ sub end_Task {
&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') {
@@ -665,10 +845,10 @@ sub end_Task {
$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.");
@@ -676,7 +856,7 @@ sub end_Task {
&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.");
@@ -685,7 +865,7 @@ sub end_Task {
&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';
@@ -703,7 +883,7 @@ sub end_Task {
["$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';
@@ -720,8 +900,8 @@ sub end_Task {
["$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"};
@@ -730,6 +910,7 @@ sub end_Task {
$Apache::lonhomework::results{"resource.0.solved"}=
$Apache::lonhomework::results{"resource.$version.0.solved"};
}
+ &minimize_storage();
&Apache::structuretags::finalize_storage();
}
} elsif ($target eq 'webgrade') {
@@ -744,9 +925,15 @@ sub end_Task {
# &mt('Save Partial Grade and Continue Grading').'" /> ';
$result.=''.&Apache::loncommon::endbodytag().'