--- loncom/homework/grades.pm 2008/03/17 20:39:50 1.515 +++ loncom/homework/grades.pm 2008/04/16 23:30:03 1.517 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.515 2008/03/17 20:39:50 raeburn Exp $ +# $Id: grades.pm,v 1.517 2008/04/16 23:30:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -73,7 +73,7 @@ my $ssi_error_message; # the number of times requested by the caller. # If we still have a proble, no text is appended to the # output and we set some global variables. -# to indicate to the caller an SSI error occured. +# to indicate to the caller an SSI error occurred. # All of this is supposed to deal with the issues described # in LonCAPA BZ 5631 see: # http://bugs.lon-capa.org/show_bug.cgi?id=5631 @@ -89,13 +89,13 @@ my $ssi_error_message; # On success, returns the rendered resource identified by the resource parameter. # Side Effects: # The following global variables can be set: -# ssi_error - If an unrecoverable error occured this becomes true. +# ssi_error - If an unrecoverable error occurred this becomes true. # It is up to the caller to initialize this to false # if desired. -# ssi_last_error_resource - If an unrecoverable error occured, this is the value +# ssi_error_resource - If an unrecoverable error occurred, this is the value # of the resource that could not be rendered by the ssi # call. -# ssi_last_error - The error string fetched from the ssi response +# ssi_error_message - The error string fetched from the ssi response # in the event of an error. # sub ssi_with_retries { @@ -116,11 +116,20 @@ sub ssi_with_retries { sub ssi_print_error { my ($r) = @_; - $r->print('

Unrecoverable network error

'); - $r->print('

Unable to perform a resource fetch from a server:
'); - $r->print("Resource: $ssi_error_resource
"); - $r->print("Error: $ssi_error_message
Try again later."); - $r->print('If errors persist, contact LonCAPA support for assistance

'); + my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk'); + $r->print(' +
+

'.&mt('An unrecoverable network error occurred:').'

+

+'.&mt('Unable to retrieve a resource from a server:').'
+'.&mt('Resource:').' '.$ssi_error_resource.'
+'.&mt('Error:').' '.$ssi_error_message.' +

+

'. +&mt('It is recommended that you try again later, as this error may mean the server was just temporarily unavailable, or is down for maintenance.').'
'. +&mt('If the error persists, please contact the [_1] for assistance.',$helpurl). +'

'); + return; } # @@ -276,12 +285,12 @@ sub reset_caches { my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); $url=&Apache::lonnet::clutter($url); my $subresult=&ssi_with_retries($url, $ssi_retries, - ('grade_target' => 'analyze'), - ('grade_domain' => $udom), - ('grade_symb' => $symb), - ('grade_courseid' => - $env{'request.course.id'}), - ('grade_username' => $uname)); + ('grade_target' => 'analyze', + 'grade_domain' => $udom, + 'grade_symb' => $symb, + 'grade_courseid' => + $env{'request.course.id'}, + 'grade_username' => $uname)); (undef,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); return $analyze_cache{$key} = \%analyze; @@ -2759,7 +2768,7 @@ sub check_and_remove_from_queue { sub handback_files { my ($request,$symb,$stuname,$domain,$newflg,$new_part,$newrecord) = @_; - my $portfolio_root = &propath($domain,$stuname).'/userfiles/portfolio'; + my $portfolio_root = '/userfiles/portfolio'; my ($partlist,$handgrade,$responseType) = &response_type($symb); my @part_response_id = &flatten_responseType($responseType); @@ -2777,7 +2786,8 @@ sub handback_files { my ($answer_name,$answer_ver,$answer_ext) = &file_name_version_ext($answer_file); my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/); - my @dir_list = &Apache::lonnet::dirlist($portfolio_path,$domain,$stuname,$portfolio_root); + my $getpropath = 1; + my @dir_list = &Apache::lonnet::dirlist($portfolio_root.$portfolio_path,$domain,$stuname,$getpropath); my $version = &get_next_version($answer_name, $answer_ext, \@dir_list); # fix file name my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/); @@ -2913,8 +2923,7 @@ sub version_portfiles { my $version_parts = join('|',@$v_flag); my @returned_keys; my $parts = join('|', @$parts_graded); - my $portfolio_root = &propath($domain,$stu_name). - '/userfiles/portfolio'; + my $portfolio_root = '/userfiles/portfolio'; foreach my $key (keys(%$record)) { my $new_portfiles; if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) { @@ -2925,7 +2934,8 @@ sub version_portfiles { my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/); my ($answer_name,$answer_ver,$answer_ext) = &file_name_version_ext($answer_file); - my @dir_list = &Apache::lonnet::dirlist($directory,$domain,$stu_name,$portfolio_root); + my $getpropath = 1; + my @dir_list = &Apache::lonnet::dirlist($portfolio_root.$directory,$domain,$stu_name,$getpropath); my $version = &get_next_version($answer_name, $answer_ext, \@dir_list); my $new_answer = &version_selected_portfile($domain, $stu_name, $directory, $answer_file, $version); if ($new_answer ne 'problem getting file') { @@ -4825,8 +4835,9 @@ sub get_response_bubbles { sub scantron_filenames { my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; + my $getpropath = 1; my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, - &propath($cdom,$cname)); + $getpropath); my @possiblenames; foreach my $filename (sort(@files)) { ($filename)=split(/&/,$filename); @@ -7247,11 +7258,11 @@ sub scantron_get_maxbubble { } } my $result=&ssi_with_retries($resource->src(), $ssi_retries, - ('symb' => $symb), - ('grade_target' => 'analyze'), - ('grade_courseid' => $cid), - ('grade_domain' => $udom), - ('grade_username' => $uname)); + ('symb' => $symb, + 'grade_target' => 'analyze', + 'grade_courseid' => $cid, + 'grade_domain' => $udom, + 'grade_username' => $uname)); my (undef, $an) = split(/_HASH_REF__/,$result, 2);