--- loncom/homework/bridgetask.pm 2006/03/06 19:48:42 1.110.2.1 +++ loncom/homework/bridgetask.pm 2006/06/01 19:22:29 1.160 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.110.2.1 2006/03/06 19:48:42 albertel Exp $ +# $Id: bridgetask.pm,v 1.160 2006/06/01 19:22:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,9 +38,12 @@ 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','Instance','InstanceText','Criteria','ClosingParagraph')); } sub initialize_bridgetask { @@ -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,56 @@ 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) { + &create_new_version($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 create_new_version { + my ($type,$user,$domain,$slot_name) = @_; + 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; + if (defined($user) && defined($domain)) { + $Apache::lonhomework::results{"resource.$version.0.checkedin"}= + $user.':'.$domain; + } else { + $Apache::lonhomework::results{"resource.$version.0.checkedin"}= + $env{'user.name'}.':'.$env{'user.domain'}; + } + if (defined($slot_name)) { + $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}= + $slot_name; + } + } elsif ($type eq 'problem') { + &Apache::lonxml::debug("authed $slot_name"); + if (defined($user) && defined($domain)) { + $Apache::lonhomework::results{"resource.0.checkedin"}= + $user.':'.$domain; + } + if (defined($slot_name)) { + $Apache::lonhomework::results{"resource.0.checkedin.slot"}= + $slot_name; + } + } +} + sub get_version { my ($version,$previous); if ($env{'form.previousversion'} && @@ -120,7 +140,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 +179,7 @@ sub add_previous_version_button { join("\n\n"; $list.=''; - $result.='
'. @@ -170,16 +194,16 @@ 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 %sections = &Apache::loncommon::get_sections($cdom,$cnum); + my $size=5; if (scalar(keys(%sections)) < 3) { $size=scalar(keys(%sections))+2; } - my $sec_select = ''."\n"; $sec_select .= "\n"; foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) { - $sec_select .= "\n"; + $sec_select .= "\n"; } $sec_select .= "\n"; @@ -213,7 +237,8 @@ sub add_grading_button { 'gradinguser', 'gradingdomain'); $result.=&Apache::loncommon::studentbrowser_javascript(); - } + $result.= '

'; + } return $result; } @@ -222,6 +247,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 +266,8 @@ STUFF } if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); } - $symb=&Apache::lonnet::escape($symb); - $result.=''. + $symb=&escape($symb); + $result.=''. ''. ''. ' -.fail, .pass, .neutral { - position: relative; - margin : 5px; - margin-bottom :10px; - padding : 4px; - padding-left : 75px; - border : thin solid; - font-weight : bolder; - font-size: smaller; - font-family: Arial; - background-color : rgb(255,240,225); -} - -.fail h4, .pass h4 { - position:absolute; - left: -4px; - top: -8px; - padding:2px; - margin:0; - background-color : rgb(255,240,225); - border : thin solid; -} - -.fail { - color: red; -} - -.pass { - color : green; -} - -.neutral { - color : blue; -} - -.question { - border : thin solid black; - padding : 4px; - margin-bottom : 1em; -} - -.grade { - font-size: x-large; - font-family: Arial; - position:absolute; - left: 5px; - top: -5px; - width: 70px; -} - -div#feedback h1 { - color : inherit; -} - + my ($target) = @_; + if ($target eq 'web' + || $target eq 'webgrade') { + return (< STYLE - + } + return; } sub show_task { @@ -327,7 +308,8 @@ sub show_task { ( $status eq 'NOT_IN_A_SLOT') || ( $status eq 'NEEDS_CHECKIN') || ( $status eq 'WAITING_FOR_GRADE') || - ( $status eq 'INVALID_ACCESS') )) { + ( $status eq 'INVALID_ACCESS') || + ( &get_version() eq ''))) { return 0; } if ($env{'form.donescreen'}) { return 0; } @@ -371,12 +353,15 @@ sub submission_time_stamp { return $result; } -sub webgrade_standard_info { - my ($version)=&get_version(); - my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser(); +sub file_list { + my ($files,$uname,$udom) = @_; + if (!defined($uname) || !defined($udom)) { + (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser(); + } my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/'; - my $file_list="