From: Mike G. v. a. <we...@ma...> - 2009-09-25 00:50:01
|
Log Message: ----------- Hide from students most of the errors created when the hardcopy version can't be TeX'd or created for some other reason. The professor still gets the errors. A value in global.conf download_hardcopy_view_errors =>"professor", adjusts who sees the hardcopy errors. global.conf.dist has been changed to include this entry. Tags: ---- rel-2-4-patches Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Hardcopy.pm webwork2/lib/WeBWorK/ContentGenerator/Instructor: PGProblemEditor.pm Revision Data ------------- Index: Hardcopy.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Hardcopy.pm,v retrieving revision 1.94.2.2.2.3 retrieving revision 1.94.2.2.2.4 diff -Llib/WeBWorK/ContentGenerator/Hardcopy.pm -Llib/WeBWorK/ContentGenerator/Hardcopy.pm -u -r1.94.2.2.2.3 -r1.94.2.2.2.4 --- lib/WeBWorK/ContentGenerator/Hardcopy.pm +++ lib/WeBWorK/ContentGenerator/Hardcopy.pm @@ -168,6 +168,7 @@ # is the user allowed to request multiple sets/users at a time? my $perm_multiset = $authz->hasPermissions($userID, "download_hardcopy_multiset"); my $perm_multiuser = $authz->hasPermissions($userID, "download_hardcopy_multiuser"); + my $perm_viewhidden = $authz->hasPermissions($userID, "view_hidden_work"); my $perm_viewfromip = $authz->hasPermissions($userID, "view_ip_restricted_sets"); @@ -258,42 +259,57 @@ sub body { my ($self) = @_; - + my $userID = $self->r->param("user"); + my $perm_view_errors = $self->r->authz->hasPermissions($userID, "download_hardcopy_view_errors"); + $perm_view_errors = (defined($perm_view_errors) ) ? $perm_view_errors : 0; if (my $num = $self->get_errors) { my $final_file_url = $self->{final_file_url}; my %temp_file_map = %{$self->{temp_file_map}}; - - my $errors_str = $num > 1 ? "errors" : "error"; - print CGI::p("$num $errors_str occured while generating hardcopy:"); - - print CGI::ul(CGI::li($self->get_errors_ref)); + if($perm_view_errors) { + my $errors_str = $num > 1 ? "errors" : "error"; + print CGI::p("$num $errors_str occured while generating hardcopy:"); + + print CGI::ul(CGI::li($self->get_errors_ref)); + } if ($final_file_url) { print CGI::p( - "A hardcopy file was generated, but it may not be complete or correct: ", - CGI::a({href=>$final_file_url}, "Download Hardcopy") + "A hardcopy file was generated, but it may not be complete or correct.", + "Please check that no problems are missing and that they are all legible." , + "If not, please inform your instructor.<br />", + CGI::a({href=>$final_file_url}, "Download Hardcopy"), ); - } + } else { + print CGI::p( + "WeBWorK was unable to generate a paper copy of this homework set. Please inform your instructor. " + ); - if (%temp_file_map) { - print CGI::start_p(); - print "You can also examine the following temporary files: "; - my $first = 1; - while (my ($temp_file_name, $temp_file_url) = each %temp_file_map) { - if ($first) { - $first = 0; - } else { - print ", "; + } + if($perm_view_errors) { + if (%temp_file_map) { + print CGI::start_p(); + print "You can also examine the following temporary files: "; + my $first = 1; + while (my ($temp_file_name, $temp_file_url) = each %temp_file_map) { + if ($first) { + $first = 0; + } else { + print ", "; + } + print CGI::a({href=>$temp_file_url}, " $temp_file_name"); } - print CGI::a({href=>$temp_file_url}, " $temp_file_name"); + print CGI::end_p(); } - print CGI::end_p(); } print CGI::hr(); } - - $self->display_form(); + + # don't display the retry form if there are errors and the user doesn't have permission to view the errors. + unless ($self->get_errors and not $perm_view_errors) { + $self->display_form(); + } + ''; # return a blank } sub display_form { Index: PGProblemEditor.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm,v retrieving revision 1.90.4.1.2.6 retrieving revision 1.90.4.1.2.7 diff -Llib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm -Llib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm -u -r1.90.4.1.2.6 -r1.90.4.1.2.7 --- lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm +++ lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm @@ -1628,16 +1628,18 @@ my $shortFilePath = $editFilePath; $shortFilePath =~ s|^$templatesDir/||; $shortFilePath =~ s|^.*/|| if $shortFilePath =~ m|^/|; # if it is still an absolute path don't suggest that you save to it. - -### --- old menu-based apparoach --- -# my $allowedActions = (defined($setID) && $setID =~/\S/ && $setID ne 'Undefined_Set') ? ['save_a_copy','rename' ] : ['save_a_copy']; - -# return CGI::popup_menu( -# -name=>'action.save_as.saveMode', -values=>$allowedActions, -# -default=>'rename',-labels=>{save_a_copy=>'Create a copy of file at ', rename=>'Rename file path to'}, -# -onmousedown=>$onChange -# ). " [TMPL]/". -### + if ( not (-w $editFilePath) ) { # if the file is not writable create a local file path so that the file can be saved." + $shortFilePath = $self->determineLocalFilePath($shortFilePath); + } + ####################################################################################### + # cases where the file might not be writable + # $self->{file_type} eq 'problem' # need problem structure to make local copy in most cases + # $self->{file_type} eq 'set_header' # special case to make copy of blankProblem + # $self->{file_type} eq 'set_header' # special case to make copy of screen header + # $self->{file_type} eq 'hardcopy_header' # special case to make copy of hardcopy header + # + ####################################################################################### + my $probNum = ($self->{file_type} eq 'problem')? "/problem $self->{problemID}" : ""; my $andRelink = ''; @@ -1667,6 +1669,7 @@ $self->{status_message} = ''; ## DPVC -- remove bogus old messages my $courseName = $self->{courseID}; my $setName = $self->{setID}; + my $fullSetName = $self->{fullSetID}; my $problemNumber = $self->{problemID}; my $displayMode = $self->{displayMode}; |