--- loncom/homework/bridgetask.pm 2006/06/20 03:33:55 1.174 +++ loncom/homework/bridgetask.pm 2006/10/31 21:29:38 1.188 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.174 2006/06/20 03:33:55 albertel Exp $ +# $Id: bridgetask.pm,v 1.188 2006/10/31 21:29:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,14 +43,14 @@ use LONCAPA; BEGIN { - &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','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::top_dimensionlist=(); # list of all current Instance ids @@ -83,12 +83,7 @@ sub proctor_check_auth { } } if ($authenticated) { - my $useslots = &Apache::lonnet::EXT("resource.0.useslots"); - if ( $useslots eq 'map_map') { - &checkin_resource($user,$domain,$slot_name); - } else { - &create_new_version($type,$user,$domain,$slot_name); - } + &check_in($type,$user,$domain,$slot_name); return 1; } } @@ -110,9 +105,10 @@ sub check_in { sub check_in_sequence { my ($user,$domain,$slot_name) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); - my ($symb) = &Apache::lonxml::whichuser(); + my ($symb) = &Apache::lonnet::whichuser(); my ($map) = &Apache::lonnet::decode_symb($symb); - my @resources = $navmap->retrieveResources($map,undef,1,0); + my @resources = + $navmap->retrieveResources($map, sub { $_[0]->is_problem() },0,0); my %old_history = %Apache::lonhomework::history; my %old_results = %Apache::lonhomework::results; @@ -148,7 +144,7 @@ sub create_new_version { #setup new version and who did it $Apache::lonhomework::results{'resource.0.version'}=$version; $id = "$version.0"; - if (!defined($user) || defined($domain)) { + if (!defined($user) || !defined($domain)) { $user = $env{'user.name'}; $domain = $env{'user.domain'}; } @@ -156,11 +152,14 @@ sub create_new_version { } elsif ($type eq 'problem') { &Apache::lonxml::debug("authed $slot_name"); } - - if (defined($user) && defined($domain)) { - $Apache::lonhomework::results{"resource.$id.checkedin"}= - $user.':'.$domain; + 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; @@ -226,7 +225,7 @@ sub add_previous_version_button { } sub add_grading_button { - my (undef,$cid)=&Apache::lonxml::whichuser(); + my (undef,$cid)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; my %sections = &Apache::loncommon::get_sections($cdom,$cnum); @@ -376,6 +375,8 @@ sub nested_parse { @Apache::scripttag::parser_env = @old_env; if ($args->{'delayed_dim_results'}) { my $dim = &get_dim_id(); + &Apache::lonxml::debug(" tossing out $result "); + &Apache::lonxml::debug(" usining out $dim 's ". $dimension{$dim}{'result'}); return $dimension{$dim}{'result'}; } return $result; @@ -387,12 +388,14 @@ sub internal_location { } sub submission_time_stamp { - my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::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'})) { + if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'}) + && defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.tries'})) { $submissiontime=$Apache::lonhomework::history{$v.':timestamp'}; + last; } } my $result; @@ -403,16 +406,18 @@ sub submission_time_stamp { my ($color,$when)=('#FF6666','after'); if ($diff > 0) { ($color,$when)=('#336600','before'); } my $info; + $diff = abs($diff); 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'}))). + &mt('Student submitted [_1] [_2] the deadline. '. + '(Submission was at [_3], end of period was [_4].)', + $info,$when, + &Apache::lonlocal::locallocaltime($submissiontime), + &Apache::lonlocal::locallocaltime($slot{'endtime'})). '

'; } return $result; @@ -421,7 +426,7 @@ sub submission_time_stamp { sub file_list { my ($files,$uname,$udom) = @_; if (!defined($uname) || !defined($udom)) { - (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser(); + (undef,undef,$udom,$uname) = &Apache::lonnet::whichuser(); } my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/'; @@ -482,7 +487,7 @@ sub done_screen { my ($version) = @_; my $title=&Apache::lonnet::gettitle(); my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'}); - my (undef,undef,$domain,$user)= &Apache::lonxml::whichuser(); + my (undef,undef,$domain,$user)= &Apache::lonnet::whichuser(); my $files = '