[LON-CAPA-cvs] cvs: loncom /homework grades.pm
www
www@source.lon-capa.org
Sun, 11 Apr 2010 22:53:23 -0000
This is a MIME encoded message
--www1271026403
Content-Type: text/plain
www Sun Apr 11 22:53:23 2010 EDT
Modified files:
/loncom/homework grades.pm
Log:
Unifying the way symbs are passed around
--www1271026403
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20100411225323.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.607 loncom/homework/grades.pm:1.608
--- loncom/homework/grades.pm:1.607 Wed Apr 7 21:08:35 2010
+++ loncom/homework/grades.pm Sun Apr 11 22:53:23 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.607 2010/04/07 21:08:35 droeschl Exp $
+# $Id: grades.pm,v 1.608 2010/04/11 22:53:23 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,25 +123,6 @@
return @stores;
}
-# --- Get the symbolic name of a problem and the url
-# Generate an error message if symb could not be found unless silent flag is set
-# Takes $env{'form.symb'} by default; if not present, takes $env{'form.url'} and tries to get symb from that
-#
-
-sub get_symb {
- my ($request,$silent) = @_;
- (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
- my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
- if ($symb eq '') {
- if (!$silent) {
- $request->print(&mt("Unable to handle ambiguous references: [_1].",$url));
- return ();
- }
- }
- &Apache::lonenc::check_decrypt(\$symb);
- return ($symb);
-}
-
#--- Format fullname, username:domain if different for display
#--- Use anywhere where the student names are listed
sub nameUserString {
@@ -728,9 +709,8 @@
#
sub initialverifyreceipt {
- my $request = shift;
+ my ($request,$symb) = @_;
&commonJSfunctions($request);
- my ($symb) = &get_symb($request);
return '<form name="gradingMenu"><input type="submit" value="'.&mt('Verify Receipt Number.').'" />'.
&Apache::lonnet::recprefix($env{'request.course.id'}).
'-<input type="text" name="receipt" size="4" />'.
@@ -741,13 +721,12 @@
#--- Check whether a receipt number is valid.---
sub verifyreceipt {
- my $request = shift;
+ my ($request,$symb) = @_;
my $courseid = $env{'request.course.id'};
my $receipt = &Apache::lonnet::recprefix($courseid).'-'.
$env{'form.receipt'};
$receipt =~ s/[^\-\d]//g;
- my ($symb) = &get_symb($request);
my $title.=
'<h3><span class="LC_info">'.
@@ -830,9 +809,8 @@
#--- Also called directly when one clicks on the subm button
# on the problem page.
sub listStudents {
- my ($request) = shift;
+ my ($request,$symb) = @_;
- my ($symb) = &get_symb($request);
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
@@ -1907,12 +1885,12 @@
# --------------------------- show submissions of a student, option to grade
sub submission {
- my ($request,$counter,$total) = @_;
+ my ($request,$counter,$total,$symb) = @_;
my ($uname,$udom) = ($env{'form.student'},$env{'form.userdom'});
$udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student?
my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
$env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';
- my $symb = &get_symb($request);
+
my $probtitle=&Apache::lonnet::gettitle($symb);
if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }
@@ -2487,8 +2465,7 @@
#--- Called from submission routine
sub processHandGrade {
- my ($request) = shift;
- my $symb = &get_symb($request);
+ my ($request,$symb) = @_;
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
my $button = $env{'form.gradeOpt'};
my $ngrade = $env{'form.NCT'};
@@ -3291,10 +3268,9 @@
#--- show scores for a section or whole class w/ option to change/update a score
sub viewgrades {
- my ($request) = shift;
+ my ($request,$symb) = @_;
&viewgrades_js($request);
- my ($symb) = &get_symb($request);
#need to make sure we have the correct data for later EXT calls,
#thus invalidate the cache
&Apache::lonnet::devalidatecourseresdata(
@@ -3532,9 +3508,8 @@
#--- change scores for all the students in a section/class
# record does not get update if unchanged
sub editgrades {
- my ($request) = @_;
+ my ($request,$symb) = @_;
- my $symb=&get_symb($request);
my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
my $title='<h2>'.&mt('Current Grade Status').'</h2>';
$title.='<h4>'.&mt('<b>Section: </b>[_1]',$section_display).'</h4>'."\n";
@@ -3943,8 +3918,7 @@
}
sub upcsvScores_form {
- my ($request) = shift;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
my $result=&checkforfile_js();
$result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n";
@@ -3976,8 +3950,7 @@
sub csvuploadmap {
- my ($request)= @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb)= @_;
if (!$symb) {return '';}
my $datatoken;
@@ -4024,8 +3997,7 @@
}
sub csvuploadoptions {
- my ($request)= @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb)= @_;
my $checked=(($env{'form.noFirstLine'})?'1':'0');
my $ignore=&mt('Ignore First Line');
$request->print(<<ENDPICK);
@@ -4085,8 +4057,7 @@
}
sub csvuploadassign {
- my ($request)= @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb)= @_;
if (!$symb) {return '';}
my $error_msg = '';
&Apache::loncommon::load_tmp_file($request);
@@ -4204,7 +4175,7 @@
#
#--- Select a page/sequence and a student to grade
sub pickStudentPage {
- my ($request) = shift;
+ my ($request,$symb) = @_;
my $alertmsg = &mt('Please select the student you wish to grade.');
$request->print(&Apache::lonhtmlcommon::scripttag(<<LISTJAVASCRIPT));
@@ -4222,7 +4193,7 @@
LISTJAVASCRIPT
&commonJSfunctions($request);
- my ($symb) = &get_symb($request);
+
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
@@ -4361,9 +4332,7 @@
#
#--- Displays a page/sequence w/wo problems, w/wo submissions
sub displayPage {
- my ($request) = shift;
-
- my ($symb) = &get_symb($request);
+ my ($request,$symb) = @_;
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
@@ -4649,7 +4618,7 @@
}
sub updateGradeByPage {
- my ($request) = shift;
+ my ($request,$symb) = @_;
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
@@ -4679,7 +4648,6 @@
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
if (!$map) {
$request->print('<span class="LC_warning">'.&mt('Unable to grade requested sequence ([_1]).',$resUrl).'</span>');
- my ($symb)=&get_symb($request);
$request->print(&show_grading_menu_form($symb));
return;
}
@@ -5171,8 +5139,7 @@
=cut
sub scantron_selectphase {
- my ($r,$file2grade) = @_;
- my ($symb)=&get_symb($r);
+ my ($r,$file2grade,$symb) = @_;
if (!$symb) {return '';}
my $map_error;
my $sequence_selector=&getSequenceDropDown($symb,\$map_error);
@@ -5206,7 +5173,7 @@
'.&Apache::loncommon::start_data_table_row().'
<td>
');
- my $default_form_data=&defaultFormData(&get_symb($r,1));
+ my $default_form_data=&defaultFormData($symb);
my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};
$r->print(&Apache::lonhtmlcommon::scripttag('
@@ -6243,8 +6210,7 @@
=cut
sub scantron_do_warning {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
my $default_form_data=&defaultFormData($symb);
$r->print(&scantron_form_start().$default_form_data);
@@ -6325,8 +6291,7 @@
=cut
sub scantron_validate_file {
- my ($r) = @_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb) = @_;
if (!$symb) {return '';}
my $default_form_data=&defaultFormData($symb);
@@ -7598,10 +7563,9 @@
sub scantron_process_students {
- my ($r) = @_;
+ my ($r,$symb) = @_;
my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($env{'form.selectpage'});
- my ($symb)=&get_symb($r);
if (!$symb) {
return '';
}
@@ -7901,7 +7865,7 @@
}
sub scantron_upload_scantron_data {
- my ($r)=@_;
+ my ($r,$symb)=@_;
my $dom = $env{'request.role.domain'};
my $domdesc = &Apache::lonnet::domain($dom,'description');
$r->print(&Apache::loncommon::coursebrowser_javascript($dom));
@@ -7910,7 +7874,7 @@
'coursename',$dom);
my $syllabuslink = '<a href="javascript:ToSyllabus();">'.&mt('Syllabus').'</a>'.
(' 'x2).&mt('(shows course personnel)');
- my $default_form_data=&defaultFormData(&get_symb($r,1));
+ my $default_form_data=&defaultFormData($symb);
my $nofile_alert = &mt('Please use the browse button to select a file from your local directory.');
my $nocourseid_alert = &mt("Please use the 'Select Course' link to open a separate window where you can search for a course to which a file can be uploaded.");
$r->print(&Apache::lonhtmlcommon::scripttag('
@@ -7970,8 +7934,7 @@
sub scantron_upload_scantron_data_save {
- my($r)=@_;
- my ($symb)=&get_symb($r,1);
+ my($r,$symb)=@_;
my $doanotherupload=
'<br /><form action="/adm/grades" method="post">'."\n".
'<input type="hidden" name="command" value="scantronupload" />'."\n".
@@ -8113,8 +8076,8 @@
}
sub scantron_download_scantron_data {
- my ($r)=@_;
- my $default_form_data=&defaultFormData(&get_symb($r,1));
+ my ($r,$symb)=@_;
+ my $default_form_data=&defaultFormData($symb);
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my $file=$env{'form.scantron_selectfile'};
@@ -8124,7 +8087,7 @@
'.&mt('The requested file name was invalid.').'
</p>
');
- $r->print(&show_grading_menu_form(&get_symb($r,1)));
+ $r->print(&show_grading_menu_form($symb));
return;
}
my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file;
@@ -8147,13 +8110,12 @@
'<a href="'.$skipped.'">','</a>').'
</p>
');
- $r->print(&show_grading_menu_form(&get_symb($r,1)));
+ $r->print(&show_grading_menu_form($symb));
return '';
}
sub checkscantron_results {
- my ($r) = @_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb) = @_;
if (!$symb) {return '';}
my $grading_menu_button=&show_grading_menu_form($symb);
my $cid = $env{'request.course.id'};
@@ -8463,8 +8425,7 @@
}
sub grading_menu {
- my ($request) = @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb),
@@ -8572,8 +8533,7 @@
}
sub submit_options_sequence {
- my ($request) = @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
&commonJSfunctions($request);
my $result;
@@ -8599,8 +8559,7 @@
}
sub submit_options_table {
- my ($request) = @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
&commonJSfunctions($request);
my $result;
@@ -8629,8 +8588,7 @@
#--- Displays the submissions first page -------
sub submit_options {
- my ($request) = @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
&commonJSfunctions($request);
@@ -8784,8 +8742,7 @@
}
sub process_clicker {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
my $result=&checkforfile_js();
$result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n";
@@ -8888,8 +8845,7 @@
}
sub process_clicker_file {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
my %Saveable_Parameters=&clicker_grading_parameters();
@@ -9121,8 +9077,7 @@
}
sub assign_clicker_grades {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
# See which part we are saving to
my $res_error;
@@ -9240,11 +9195,27 @@
'</div>';
}
sub startpage{
- my ($r,$crumbs) = @_;
+ my ($r,$crumbs,$symb,$onlyfolderflag) = @_;
- unshift(@$crumbs, {href=>"/adm/grades",text=>"Grading"});
+ unshift(@$crumbs, {href=>"/adm/grades?command=gradingmenu&symb=".&HTML::Entities::encode($symb,'<>&"'),text=>"Grading"});
$r->print(&Apache::loncommon::start_page('Grading',undef,
{'bread_crumbs' => $crumbs}));
+ if ($env{'form.symb'}) {
+ my $symb=$env{'form.symb'};
+ my $title=&Apache::lonnet::gettitle($symb);
+ $r->print(&Apache::loncommon::start_data_table());
+ unless ($onlyfolderflag) {
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<th>'.&mt('Resource:').'</th><td>'.$title.'</td>'.
+ &Apache::loncommon::end_data_table_row());
+ }
+ my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symb);
+ my $folder=&Apache::lonnet::gettitle($map);
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<th>'.&mt('Folder:').'</th><td>'.$folder.'</td>'.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table());
+ }
}
sub handler {
@@ -9258,14 +9229,25 @@
$request->send_http_header;
return '' if $request->header_only;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
- my $symb=&get_symb($request,1);
+
+# see what command we need to execute
+
my @commands=&Apache::loncommon::get_env_multiple('form.command');
my $command=$commands[0];
if ($#commands > 0) {
&Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands));
}
-
+
+# see what the symb is
+
+ my $symb=$env{'form.symb'};
+ unless ($symb) {
+ (my $url=$env{'form.url'}) =~ s-^https*://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+ $symb=&Apache::lonnet::symbread($url);
+ }
+ &Apache::lonenc::check_decrypt(\$symb);
+
$ssi_error = 0;
if ($symb eq '' && $command eq '') {
#
@@ -9275,83 +9257,83 @@
} else {
&init_perm();
if ($command eq 'submission' && $perm{'vgr'}) {
- &startpage($request, [{href=>"", text=>"Student Submissions"}]);
+ &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}]);
($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
- &pickStudentPage($request);
+ &pickStudentPage($request,$symb);
} elsif ($command eq 'displayPage' && $perm{'vgr'}) {
- &displayPage($request);
+ &displayPage($request,$symb);
} elsif ($command eq 'gradeByPage' && $perm{'mgr'}) {
- &updateGradeByPage($request);
+ &updateGradeByPage($request,$symb);
} elsif ($command eq 'processGroup' && $perm{'vgr'}) {
- &processGroup($request);
+ &processGroup($request,$symb);
} elsif ($command eq 'gradingmenu' && $perm{'vgr'}) {
- &startpage($request);
- $request->print(&grading_menu($request));
+ &startpage($request,$symb);
+ $request->print(&grading_menu($request,$symb));
} elsif ($command eq 'individual' && $perm{'vgr'}) {
- $request->print(&submit_options($request));
+ $request->print(&submit_options($request,$symb));
} elsif ($command eq 'ungraded' && $perm{'vgr'}) {
- $request->print(&submit_options($request));
+ $request->print(&submit_options($request,$symb));
} elsif ($command eq 'table' && $perm{'vgr'}) {
- $request->print(&submit_options_table($request));
+ $request->print(&submit_options_table($request),$symb);
} elsif ($command eq 'all_for_one' && $perm{'vgr'}) {
- $request->print(&submit_options_sequence($request));
+ $request->print(&submit_options_sequence($request,$symb));
} elsif ($command eq 'viewgrades' && $perm{'vgr'}) {
- $request->print(&viewgrades($request));
+ $request->print(&viewgrades($request,$symb));
} elsif ($command eq 'handgrade' && $perm{'mgr'}) {
- $request->print(&processHandGrade($request));
+ $request->print(&processHandGrade($request,$symb));
} elsif ($command eq 'editgrades' && $perm{'mgr'}) {
- $request->print(&editgrades($request));
+ $request->print(&editgrades($request,$symb));
} elsif ($command eq 'initialverifyreceipt' && $perm{'vgr'}) {
- $request->print(&initialverifyreceipt($request));
+ $request->print(&initialverifyreceipt($request),$symb);
} elsif ($command eq 'verify' && $perm{'vgr'}) {
- $request->print(&verifyreceipt($request));
+ $request->print(&verifyreceipt($request,$symb));
} elsif ($command eq 'processclicker' && $perm{'mgr'}) {
- $request->print(&process_clicker($request));
+ $request->print(&process_clicker($request,$symb));
} elsif ($command eq 'processclickerfile' && $perm{'mgr'}) {
- $request->print(&process_clicker_file($request));
+ $request->print(&process_clicker_file($request,$symb));
} elsif ($command eq 'assignclickergrades' && $perm{'mgr'}) {
- $request->print(&assign_clicker_grades($request));
+ $request->print(&assign_clicker_grades($request,$symb));
} elsif ($command eq 'csvform' && $perm{'mgr'}) {
- $request->print(&upcsvScores_form($request));
+ $request->print(&upcsvScores_form($request,$symb));
} elsif ($command eq 'csvupload' && $perm{'mgr'}) {
- $request->print(&csvupload($request));
+ $request->print(&csvupload($request,$symb));
} elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) {
- $request->print(&csvuploadmap($request));
+ $request->print(&csvuploadmap($request,$symb));
} elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) {
if ($env{'form.associate'} ne 'Reverse Association') {
- $request->print(&csvuploadoptions($request));
+ $request->print(&csvuploadoptions($request,$symb));
} else {
if ( $env{'form.upfile_associate'} ne 'reverse' ) {
$env{'form.upfile_associate'} = 'reverse';
} else {
$env{'form.upfile_associate'} = 'forward';
}
- $request->print(&csvuploadmap($request));
+ $request->print(&csvuploadmap($request,$symb));
}
} elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) {
- $request->print(&csvuploadassign($request));
+ $request->print(&csvuploadassign($request,$symb));
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
- $request->print(&scantron_selectphase($request));
+ $request->print(&scantron_selectphase($request,$symb));
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) {
- $request->print(&scantron_do_warning($request));
+ $request->print(&scantron_do_warning($request,$symb));
} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) {
- $request->print(&scantron_validate_file($request));
+ $request->print(&scantron_validate_file($request,$symb));
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
- $request->print(&scantron_process_students($request));
+ $request->print(&scantron_process_students($request,$symb));
} elsif ($command eq 'scantronupload' &&
(&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
- $request->print(&scantron_upload_scantron_data($request));
+ $request->print(&scantron_upload_scantron_data($request,$symb));
} elsif ($command eq 'scantronupload_save' &&
(&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
- $request->print(&scantron_upload_scantron_data_save($request));
+ $request->print(&scantron_upload_scantron_data_save($request,$symb));
} elsif ($command eq 'scantron_download' &&
&Apache::lonnet::allowed('usc',$env{'request.course.id'})) {
- $request->print(&scantron_download_scantron_data($request));
+ $request->print(&scantron_download_scantron_data($request,$symb));
} elsif ($command eq 'checksubmissions' && $perm{'vgr'}) {
- $request->print(&checkscantron_results($request));
+ $request->print(&checkscantron_results($request,$symb));
} elsif ($command) {
$request->print('<p class="LC_error">'.&mt('Access Denied ([_1])',$command).'</p>');
}
--www1271026403--