--- loncom/homework/bridgetask.pm 2006/05/09 19:01:19 1.146
+++ loncom/homework/bridgetask.pm 2009/03/20 10:05:00 1.245
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.146 2006/05/09 19:01:19 albertel Exp $
+# $Id: bridgetask.pm,v 1.245 2009/03/20 10:05:00 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,25 +38,27 @@ use Apache::lonlocal;
use Apache::lonxml;
use Apache::slotrequest();
use Time::HiRes qw( gettimeofday tv_interval );
+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','Setup','Instance','InstanceText','Criteria','CriteriaText','GraderNote','ClosingParagraph'));
}
+my %dimension;
+my $top = 'top';
+
sub initialize_bridgetask {
# id of current Dimension, 0 means that no dimension is current
# (inside '."\n";
- $result.='';
+ $entries,$ready,$locks).''."\n\t\t".''."\n";
+ $result.="\n\t\t".' '.
+ "\n\t\t".'';
+ $result.= "\n\t\t".'';
$result.=&Apache::loncommon::select_dom_form($env{'user.domain'},
'gradingdomain');
$result.=' '.
@@ -213,36 +287,44 @@ sub add_grading_button {
'gradinguser',
'gradingdomain');
$result.=&Apache::loncommon::studentbrowser_javascript();
- $result.= '
'."\n";
- $result.='';
- $result.=' Specify a section: '.$sec_select.' ';
- $result.=''.' '."\n\t\t".' ';
+ if ($see_all || (!§ion_restricted())) {
+ $result.="\n\t\t\t".' '."\n";
+ $result.= "\n\t\t\t\t".&mt("[_1] entries, [_2] ready, [_3] being graded",$entries,$ready,$locks).''."\n\t\t".''."\n";
($entries,$ready,$locks)=&get_queue_counts('reviewqueue');
- $result.=''.&mt('Specify a section:').' '.
+ "\n\t\t\t".''.$sec_select."\n\t\t\t".' ';
+ } else {
+ $result.="\n\t\t\t".''.&mt('Grading section:').' '.
+ "\n\t\t\t".''.$env{'request.course.sec'}."\n\t\t\t".' ';
+ }
+ $result.="\n\t\t\t".''.' ';
- $result.= &mt("[_1] entries, [_2] ready, [_3] being graded",$entries,$ready,$locks).' '."\n";
- $result.=''.
- ' '.
+ "\n\t\t\t".' '.
+ "\n\t\t\t\t".' ';
$result.=&mt("[_1] entries, [_2] ready, [_3] being graded",
- $entries,$ready,$locks).' '.
+ "\n\t\t\t".' '
+ ."\n\t".''."\n";
+ $result.="\n\t".''.
+ "\n\t\t\t\t".' '
+ ."\n\t\t".'
' + .&mt('Will be next available:') + .' '.$description + .'
'; } if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); } - $symb=&Apache::lonnet::escape($symb); - $result.=''; + $text.'" />'."\n\t". + ''."\n"; return $result; } @@ -262,9 +344,22 @@ sub style { my ($target) = @_; if ($target eq 'web' || $target eq 'webgrade') { - return (< STYLE + if ($env{'browser.type'} eq 'explorer' + && $env{'browser.os'} eq 'win' ) { + if ($env{'browser.version'} < 7) { + $style .= (< +STYLE + } else { + $style .= (< +STYLE + } + } + return $style; } return; } @@ -278,25 +373,67 @@ 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; } return 1; } +my @delay; +sub nest { + if (@delay) { + return $delay[-1]; + } else { + return; + } +} + +sub start_delay { + push(@delay,1); +} +sub end_delay { + pop(@delay); +} + +sub nested_parse { + my ($str,$env,$args) = @_; + my @old_env = @Apache::scripttag::parser_env; + @Apache::scripttag::parser_env = @$env; + if (exists($args->{'set_dim_id'})) { + &enable_dimension_parsing($args->{'set_dim_id'}); + } + push(@delay,(($args->{'delayed_dim_results'})? 1 : 0)); + my $result = &Apache::scripttag::xmlparse($$str); + pop(@delay); + if (exists($args->{'set_dim_id'})) { + &disable_dimension_parsing(); + } + @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; +} + sub internal_location { my ($id)=@_; return ''; } 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; @@ -307,16 +444,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; @@ -325,7 +464,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/'; @@ -334,42 +473,122 @@ sub file_list { my $file=$file_url.$partial_file; $file=~s|/+|/|g; &Apache::lonnet::allowuploaded('/adm/bridgetask',$file); - $file_list.='".&mt('Submitted non-existent file [_1]',$file)."
\n"; + } else { + $file = ''.$file.''; + $msg .= "".&mt('Submitted file [_1]',$file)."
\n"; + } + $files .= ''.&mt('Message sent to user: [_1]', + $message_status).'
'; + } + if ($setting eq 'student_and_user_notes_screen') { + $comment_status = + &Apache::lonmsg::store_instructor_comment($subject.''.&mt('Message sent to instructor: [_1]', + $comment_status).'
'; + } + return "'.&mt('Files submitted: [_1]',$files).'
' + .''.&mt('You are now done with this Bridge Task').'
' + .''.&mt('Change to a different course').'
' +.$message_status +.$comment_status; + } sub start_Task { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my ($status,$accessmsg,$slot); + &Apache::structuretags::init_problem_globals('Task'); 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') { @@ -391,17 +610,18 @@ sub start_Task { &Apache::structuretags::page_start($target,$token,$tagstack, $parstack,$parser,$safeeval, $name,&style($target)); - $result .= 'Files submitted: $files
-You are now done with this Bridge Task
-Found '. - &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.' |
'. + &mt('Grading [_1] for [_2] at [_3]', + &Apache::lonnet::gettitle($symb),$uname,$udom).'
'; $form_tag_start.= ''; + &escape($todo).'" />'; $Apache::bridgetask::queue_key=$todo; &Apache::structuretags::initialize_storage(); &Apache::lonhomework::showhash(%Apache::lonhomework::history); @@ -548,6 +769,17 @@ DONESCREEN &mt('Return to resource').''; if ($status_code eq 'stop') { $result.=''.&mt("Stopped grading.").''.$back; + } elsif ($status_code eq 'cancel') { + $result.=''.&mt("Cancelled grading.").''.$back; + } elsif ($status_code eq 'never_versioned') { + $result.=''. + &mt("Requested user has never accessed the task."). + ''.$back; + } elsif ($status_code =~ /still_open:(.*)/) { + my $date = &Apache::lonlocal::locallocaltime($1); + $result.=''. + &mt("Task is still open, will close at [_1].",$date). + ''.$back; } elsif ($status_code eq 'lock_failed') { $result.=''.&mt("Failed to lock the requested record.") .''.$back; @@ -568,6 +800,8 @@ DONESCREEN } } $webgrade='no'; + } + if (!$todo || $env{'form.cancel'}) { my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style); } if ($target eq 'webgrade' && defined($env{'form.queue'})) { @@ -583,26 +817,42 @@ DONESCREEN $result.=''; } - if ($env{'form.chosensections'}) { - my @chosen_sections= - &Apache::loncommon::get_env_multiple('form.chosensections'); + if ($env{'form.chosensections'} || §ion_restricted()) { + my @chosen_sections = &get_allowed_sections(); foreach my $sec (@chosen_sections) { $result.=''; } } if ($webgrade eq 'yes') { $result.=&webgrade_standard_info(); } + } elsif ($target eq 'webgrade' + && $env{'request.state'} eq 'construct') { + $result.=$form_tag_start; + $result.=''; + $result.=&webgrade_standard_info(); } if ($target eq 'webgrade') { $result.="\n".'". + &question_status_message(\%counts,-1). + "
\n"; + if ($bt_status eq 'pass') { - $status.='".&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)."
Showing only sections '.join(', ',@chosen_sections). - '.
'."\n"; + $result.='' + .&mt('Showing only sections [_1].' + ,''.join(', ',@chosen_sections).'') + ."
\n"; + } + + my ($view,$view_section); + my $scope = $env{'request.course.id'}; + if (!($view=&Apache::lonnet::allowed('vgr',$scope))) { + $scope .= '/'.$env{'request.course.sec'}; + if ( $view = &Apache::lonnet::allowed('vgr',$scope)) { + $view_section=$env{'request.course.sec'}; + } else { + undef($view); + } } + $result .= + ''. + &mt('Return to resource').'
Empty |
Status | "; } - $result.=" | user | data | '.&mt('Status').' | '; } + $result.=' | '.&mt('User').' | '.&mt('Data').' | '. + &Apache::loncommon::end_data_table_header_row(); foreach my $key (sort(keys(%queue))) { my ($symb,$uname,$udom) = &decode_queue_key($key); - if (!defined($classlist->{$uname.':'.$udom})) { next; } + next if (!defined($classlist->{$uname.':'.$udom})); + next if (!&allow_grade_user($classlist->{$uname.':'.$udom})); + + my $section = $classlist->{$uname.':'.$udom}[&Apache::loncoursedata::CL_SECTION()]; + + my $can_view=1; + if (!$view + || ($view_section && !$section) + || ($view_section && $section && ($view_section ne $section))) { + $can_view=0; + } + if ($key=~/locked$/ && !$with_selects) { - $result.="
---|---|---|---|
$uname | "; + $result.= &Apache::loncommon::start_data_table_row(). + "$uname | "; $result.=''.$queue{$key}.' | |
"; + $result.=&Apache::loncommon::start_data_table_row()." | "; $result.=' | '. &Apache::lonlocal::locallocaltime($queue{$key})." | |
'.$slot_text.' ' + .&mt('End time: [_1]' + ,&Apache::lonlocal::locallocaltime($end_time)) + .' | ' + .&Apache::loncommon::end_data_table_row(); } } - $result.="
Showing only sections '.join(', ',@chosen_sections). - '.
'."\n"; + $result.='' + .&mt('Showing only sections [_1].' + ,''.join(', ',@chosen_sections).'') + .'
'."\n"; } - $result.=''.$fullname->{$student}. + $result.=&Apache::loncommon::start_data_table_row(). + ' | '.$classlist->{$student}[&Apache::loncoursedata::CL_FULLNAME()]. ' | ';
} else {
my $seclist;
@@ -1512,20 +2081,19 @@ sub select_user {
$seclist.='';
}
- my $studentdis = $student;
- $studentdis =~ tr/:/@/;
+ my $buttontext=&mt('Regrade');
+ $result.=&Apache::loncommon::start_data_table_row();
$result.=<
- | $fullname->{$student} ($studentdis) |
+ $classlist->{$student}[&Apache::loncoursedata::CL_FULLNAME()] ($student) Sec: $classlist->{$student}[&Apache::loncoursedata::CL_SECTION()] |
RESULT
}
@@ -1564,9 +2132,9 @@ RESULT
} else {
$result.=" ";
}
- $result.= ' | |
".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."
\n" + .&question_status_message(\%counts, + $dimension{$dim}{'depth'}) + ."
\n'; - @Apache::scripttag::parser_env = @_; - $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id}); - $result.='
'.$status_display.'
'; - if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}) { - $result.=''.&mt('Comment: [_1]',$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}).'
'; - } - $result.='' + ."\n"; + $criteria =~ s/^\s*//s; + $criteria =~ s/\s*$//s; + $criteria_info.= $criteria; + $criteria_info.="\n\t".'
'. + "\n\t".''.$status_display.'
'; + if ($comment =~ /\w/) { + $criteria_info.= + "\n\t". + ''.&mt('Comment: [_1]',$comment).'
'; + } + $criteria_info.="\n".''.&mt("Failed to authenticate the proctor.") - .'
'; + $msg.='' + .&mt("Failed to authenticate the proctor.") + .'
'; + } + + my $valid; + my @possible_proctors=split(",",$slot->{'proctor'}); + foreach my $proctor (@possible_proctors) { + if ($proctor =~ /$LONCAPA::username_re:$LONCAPA::domain_re/) { + $valid = 1; + last; + } + } + if (!$valid) { + $msg.='' + .&mt("No valid proctors are defined.") + .'
'; } + if (!$env{'form.proctordomain'}) { $env{'form.proctordomain'}=$domain; } + my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); + $uri = &HTML::Entities::encode($uri,'<>&"'); + my %lt = &Apache::lonlocal::texthash( + 'prva' => "Proctor Validation", + 'yoro' => "Your room's proctor needs to validate your access to this resource.", + 'prus' => "Proctor's Username:", + 'pasw' => "Password:", + 'prdo' => "Proctor's Domain:", + 'vali' => 'Validate', + 'stui' => "Student who should be logged in is:", + 'name' => "Name:", + 'sid' => "Student/Employee ID:", + 'unam' => "Username:", + ); my $result= (<Your room's proctor needs to validate your access to this resource.
+$lt{'yoro'}
$msg - ENDCHECKOUT + return $result; }