version 1.514, 2008/03/12 02:46:52
|
version 1.517, 2008/04/16 23:30:03
|
Line 73 my $ssi_error_message;
|
Line 73 my $ssi_error_message;
|
# the number of times requested by the caller. |
# the number of times requested by the caller. |
# If we still have a proble, no text is appended to the |
# If we still have a proble, no text is appended to the |
# output and we set some global variables. |
# 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 |
# All of this is supposed to deal with the issues described |
# in LonCAPA BZ 5631 see: |
# in LonCAPA BZ 5631 see: |
# http://bugs.lon-capa.org/show_bug.cgi?id=5631 |
# http://bugs.lon-capa.org/show_bug.cgi?id=5631 |
Line 89 my $ssi_error_message;
|
Line 89 my $ssi_error_message;
|
# On success, returns the rendered resource identified by the resource parameter. |
# On success, returns the rendered resource identified by the resource parameter. |
# Side Effects: |
# Side Effects: |
# The following global variables can be set: |
# 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 |
# It is up to the caller to initialize this to false |
# if desired. |
# 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 |
# of the resource that could not be rendered by the ssi |
# call. |
# 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. |
# in the event of an error. |
# |
# |
sub ssi_with_retries { |
sub ssi_with_retries { |
Line 116 sub ssi_with_retries {
|
Line 116 sub ssi_with_retries {
|
|
|
sub ssi_print_error { |
sub ssi_print_error { |
my ($r) = @_; |
my ($r) = @_; |
$r->print('<h2>Unrecoverable network error</h2>'); |
my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk'); |
$r->print('<p>Unable to perform a resource fetch from a server: <br />'); |
$r->print(' |
$r->print("Resource: $ssi_error_resource <br />"); |
<br /> |
$r->print("Error: $ssi_error_message <br /> Try again later."); |
<h2>'.&mt('An unrecoverable network error occurred:').'</h2> |
$r->print('If errors persist, contact LonCAPA support for assistance</p>'); |
<p> |
|
'.&mt('Unable to retrieve a resource from a server:').'<br /> |
|
'.&mt('Resource:').' '.$ssi_error_resource.'<br /> |
|
'.&mt('Error:').' '.$ssi_error_message.' |
|
</p> |
|
<p>'. |
|
&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.').'<br />'. |
|
&mt('If the error persists, please contact the [_1] for assistance.',$helpurl). |
|
'</p>'); |
|
return; |
} |
} |
|
|
# |
# |
Line 276 sub reset_caches {
|
Line 285 sub reset_caches {
|
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
$url=&Apache::lonnet::clutter($url); |
$url=&Apache::lonnet::clutter($url); |
my $subresult=&ssi_with_retries($url, $ssi_retries, |
my $subresult=&ssi_with_retries($url, $ssi_retries, |
('grade_target' => 'analyze'), |
('grade_target' => 'analyze', |
('grade_domain' => $udom), |
'grade_domain' => $udom, |
('grade_symb' => $symb), |
'grade_symb' => $symb, |
('grade_courseid' => |
'grade_courseid' => |
$env{'request.course.id'}), |
$env{'request.course.id'}, |
('grade_username' => $uname)); |
'grade_username' => $uname)); |
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
return $analyze_cache{$key} = \%analyze; |
return $analyze_cache{$key} = \%analyze; |
Line 2759 sub check_and_remove_from_queue {
|
Line 2768 sub check_and_remove_from_queue {
|
|
|
sub handback_files { |
sub handback_files { |
my ($request,$symb,$stuname,$domain,$newflg,$new_part,$newrecord) = @_; |
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 ($partlist,$handgrade,$responseType) = &response_type($symb); |
|
|
my @part_response_id = &flatten_responseType($responseType); |
my @part_response_id = &flatten_responseType($responseType); |
Line 2777 sub handback_files {
|
Line 2786 sub handback_files {
|
my ($answer_name,$answer_ver,$answer_ext) = |
my ($answer_name,$answer_ver,$answer_ext) = |
&file_name_version_ext($answer_file); |
&file_name_version_ext($answer_file); |
my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/); |
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); |
my $version = &get_next_version($answer_name, $answer_ext, \@dir_list); |
# fix file name |
# fix file name |
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/); |
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/); |
Line 2913 sub version_portfiles {
|
Line 2923 sub version_portfiles {
|
my $version_parts = join('|',@$v_flag); |
my $version_parts = join('|',@$v_flag); |
my @returned_keys; |
my @returned_keys; |
my $parts = join('|', @$parts_graded); |
my $parts = join('|', @$parts_graded); |
my $portfolio_root = &propath($domain,$stu_name). |
my $portfolio_root = '/userfiles/portfolio'; |
'/userfiles/portfolio'; |
|
foreach my $key (keys(%$record)) { |
foreach my $key (keys(%$record)) { |
my $new_portfiles; |
my $new_portfiles; |
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) { |
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) { |
Line 2925 sub version_portfiles {
|
Line 2934 sub version_portfiles {
|
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/); |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/); |
my ($answer_name,$answer_ver,$answer_ext) = |
my ($answer_name,$answer_ver,$answer_ext) = |
&file_name_version_ext($answer_file); |
&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 $version = &get_next_version($answer_name, $answer_ext, \@dir_list); |
my $new_answer = &version_selected_portfile($domain, $stu_name, $directory, $answer_file, $version); |
my $new_answer = &version_selected_portfile($domain, $stu_name, $directory, $answer_file, $version); |
if ($new_answer ne 'problem getting file') { |
if ($new_answer ne 'problem getting file') { |
Line 4825 sub get_response_bubbles {
|
Line 4835 sub get_response_bubbles {
|
sub scantron_filenames { |
sub scantron_filenames { |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $getpropath = 1; |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
&propath($cdom,$cname)); |
$getpropath); |
my @possiblenames; |
my @possiblenames; |
foreach my $filename (sort(@files)) { |
foreach my $filename (sort(@files)) { |
($filename)=split(/&/,$filename); |
($filename)=split(/&/,$filename); |
Line 7231 sub scantron_get_maxbubble {
|
Line 7242 sub scantron_get_maxbubble {
|
my $response_number = 0; |
my $response_number = 0; |
my $bubble_line = 0; |
my $bubble_line = 0; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
my $symb = $resource->symb(); |
# Need to retrieve part IDs and response IDs because essayresponse, |
# Need to retrieve part IDs and response IDs because essayresponse, |
# reactionresponse and organicresponse items are not included in |
# reactionresponse and organicresponse items are not included in |
# $analysis{'parts'} from lonnet::ssi. |
# $analysis{'parts'} from lonnet::ssi. |
my %possible_part_ids; |
my %possible_part_ids; |
if (ref($resource->parts()) eq 'ARRAY') { |
if (ref($resource->parts()) eq 'ARRAY') { |
foreach my $part (@{$resource->parts()}) { |
foreach my $part (@{$resource->parts()}) { |
my @resp_ids = $resource->responseIds($part); |
if (!&Apache::loncommon::check_if_partid_hidden($part,$symb,$udom,$uname)) { |
foreach my $id (@resp_ids) { |
my @resp_ids = $resource->responseIds($part); |
$possible_part_ids{$part.'.'.$id} = 1; |
foreach my $id (@resp_ids) { |
|
$possible_part_ids{$part.'.'.$id} = 1; |
|
} |
} |
} |
} |
} |
} |
} |
my $result=&ssi_with_retries($resource->src(), $ssi_retries, |
my $result=&ssi_with_retries($resource->src(), $ssi_retries, |
('symb' => $resource->symb()), |
('symb' => $symb, |
('grade_target' => 'analyze'), |
'grade_target' => 'analyze', |
('grade_courseid' => $cid), |
'grade_courseid' => $cid, |
('grade_domain' => $udom), |
'grade_domain' => $udom, |
('grade_username' => $uname)); |
'grade_username' => $uname)); |
my (undef, $an) = |
my (undef, $an) = |
split(/_HASH_REF__/,$result, 2); |
split(/_HASH_REF__/,$result, 2); |
|
|
Line 7257 sub scantron_get_maxbubble {
|
Line 7271 sub scantron_get_maxbubble {
|
my %analysis = &Apache::lonnet::str2hash($an); |
my %analysis = &Apache::lonnet::str2hash($an); |
|
|
if (ref($analysis{'parts'}) eq 'ARRAY') { |
if (ref($analysis{'parts'}) eq 'ARRAY') { |
@parts = @{$analysis{'parts'}}; |
foreach my $part (@{$analysis{'parts'}}) { |
|
my ($id,$respid) = split(/\./,$part); |
|
if (!&Apache::loncommon::check_if_partid_hidden($id,$symb,$udom,$uname)) { |
|
push(@parts,$part); |
|
} |
|
} |
} |
} |
# Add part_ids for any essayresponse items. |
# Add part_ids for any essayresponse items. |
foreach my $part_id (keys(%possible_part_ids)) { |
foreach my $part_id (keys(%possible_part_ids)) { |