--- loncom/homework/grades.pm 2017/05/19 16:48:56 1.596.2.12.2.39
+++ loncom/homework/grades.pm 2019/02/05 16:13:05 1.596.2.12.2.41.2.4
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.39 2017/05/19 16:48:56 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.41.2.4 2019/02/05 16:13:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -354,7 +354,7 @@ sub reset_caches {
}
sub scantron_partids_tograde {
- my ($resource,$cid,$uname,$udom,$check_for_randomlist,$bubbles_per_row) = @_;
+ my ($resource,$cid,$uname,$udom,$check_for_randomlist,$bubbles_per_row,$scancode) = @_;
my (%analysis,@parts);
if (ref($resource)) {
my $symb = $resource->symb();
@@ -362,6 +362,13 @@ sub reset_caches {
if ($check_for_randomlist) {
$add_to_form = { 'check_parts_withrandomlist' => 1,};
}
+ if ($scancode) {
+ if (ref($add_to_form) eq 'HASH') {
+ $add_to_form->{'code_for_randomlist'} = $scancode;
+ } else {
+ $add_to_form = { 'code_for_randomlist' => $scancode,};
+ }
+ }
my $analyze =
&get_analyze($symb,$uname,$udom,undef,$add_to_form,
undef,undef,undef,$bubbles_per_row);
@@ -4170,6 +4177,7 @@ sub editgrades {
$ctr++;
}
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
+ my $totcolspan = 0;
foreach my $partid (@partid) {
$header .= '
'.&mt('Old Score').'
'.
'
'.&mt('New Score').'
';
@@ -4186,6 +4194,7 @@ sub editgrades {
'
'.&mt('New').' '.$display.'
';
$columns{$partid}+=2;
}
+ $totcolspan += $columns{$partid};
}
foreach my $partid (@partid) {
my $display_part=&get_display_part($partid,$symb);
@@ -4201,20 +4210,20 @@ sub editgrades {
my @noupdate;
my ($updateCtr,$noupdateCtr) = (1,1);
for ($i=0; $i<$env{'form.total'}; $i++) {
- my $line;
my $user = $env{'form.ctr'.$i};
my ($uname,$udom)=split(/:/,$user);
my %newrecord;
my $updateflag = 0;
- $line .= '
';
+ if (!$canmodify) {
+ push(@noupdate,
+ $line."
".
+ &mt('Not allowed to modify student')."
");
+ next;
+ }
my %aggregate = ();
my $aggregateflag = 0;
$user=~s/:/_/; # colon doen't work in javascript for names
@@ -4329,8 +4338,7 @@ sub editgrades {
}
}
if (@noupdate) {
-# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
- my $numcols=scalar(@partid)*4+2;
+ my $numcols=$totcolspan+2;
$result .= &Apache::loncommon::start_data_table_row('LC_empty_row').
'
'.
&mt('No Changes Occurred For the Students Below').
@@ -4598,8 +4606,10 @@ sub csvuploadmap {
if (!$env{'form.datatoken'}) {
$datatoken=&Apache::loncommon::upfile_store($request);
} else {
- $datatoken=$env{'form.datatoken'};
- &Apache::loncommon::load_tmp_file($request);
+ $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
+ if ($datatoken ne '') {
+ &Apache::loncommon::load_tmp_file($request,$datatoken);
+ }
}
my @records=&Apache::loncommon::upfile_record_sep();
if ($env{'form.noFirstLine'}) { shift(@records); }
@@ -4703,7 +4713,10 @@ sub csvuploadassign {
my ($symb)=&get_symb($request);
if (!$symb) {return '';}
my $error_msg = '';
- &Apache::loncommon::load_tmp_file($request);
+ my $datatoken = &Apache::loncommon::valid_datatoken($env{'form.datatoken'});
+ if ($datatoken ne '') {
+ &Apache::loncommon::load_tmp_file($request,$datatoken);
+ }
my @gradedata = &Apache::loncommon::upfile_record_sep();
if ($env{'form.noFirstLine'}) { shift(@gradedata); }
my %fields=&get_fields();
@@ -5703,7 +5716,7 @@ sub scantron_uploads {
sub scantron_scantab {
my $result='
- '.&Apache::loncommon::end_data_table_row().'
- '.&Apache::loncommon::end_data_table().'
-');
}
# Chunk of form to prompt for a file to grade and how:
@@ -6010,98 +5975,6 @@ sub scantron_selectphase {
return;
}
-=pod
-
-=item get_scantron_config
-
- Parse and return the scantron configuration line selected as a
- hash of configuration file fields.
-
- Arguments:
- which - the name of the configuration to parse from the file.
-
-
- Returns:
- If the named configuration is not in the file, an empty
- hash is returned.
- a hash with the fields
- name - internal name for the this configuration setup
- description - text to display to operator that describes this config
- CODElocation - if 0 or the string 'none'
- - no CODE exists for this config
- if -1 || the string 'letter'
- - a CODE exists for this config and is
- a string of letters
- Unsupported value (but planned for future support)
- if a positive integer
- - The CODE exists as the first n items from
- the question section of the form
- if the string 'number'
- - The CODE exists for this config and is
- a string of numbers
- CODEstart - (only matter if a CODE exists) column in the line where
- the CODE starts
- CODElength - length of the CODE
- IDstart - column where the student/employee ID starts
- IDlength - length of the student/employee ID info
- Qstart - column where the information from the bubbled
- 'questions' start
- Qlength - number of columns comprising a single bubble line from
- the sheet. (usually either 1 or 10)
- Qon - either a single character representing the character used
- to signal a bubble was chosen in the positional setup, or
- the string 'letter' if the letter of the chosen bubble is
- in the final, or 'number' if a number representing the
- chosen bubble is in the file (1->A 0->J)
- Qoff - the character used to represent that a bubble was
- left blank
- PaperID - if the scanning process generates a unique number for each
- sheet scanned the column that this ID number starts in
- PaperIDlength - number of columns that comprise the unique ID number
- for the sheet of paper
- FirstName - column that the first name starts in
- FirstNameLength - number of columns that the first name spans
-
- LastName - column that the last name starts in
- LastNameLength - number of columns that the last name spans
- BubblesPerRow - number of bubbles available in each row used to
- bubble an answer. (If not specified, 10 assumed).
-
-=cut
-
-sub get_scantron_config {
- my ($which) = @_;
- my @lines = &get_scantronformat_file();
- my %config;
- #FIXME probably should move to XML it has already gotten a bit much now
- foreach my $line (@lines) {
- my ($name,$descrip)=split(/:/,$line);
- if ($name ne $which ) { next; }
- chomp($line);
- my @config=split(/:/,$line);
- $config{'name'}=$config[0];
- $config{'description'}=$config[1];
- $config{'CODElocation'}=$config[2];
- $config{'CODEstart'}=$config[3];
- $config{'CODElength'}=$config[4];
- $config{'IDstart'}=$config[5];
- $config{'IDlength'}=$config[6];
- $config{'Qstart'}=$config[7];
- $config{'Qlength'}=$config[8];
- $config{'Qoff'}=$config[9];
- $config{'Qon'}=$config[10];
- $config{'PaperID'}=$config[11];
- $config{'PaperIDlength'}=$config[12];
- $config{'FirstName'}=$config[13];
- $config{'FirstNamelength'}=$config[14];
- $config{'LastName'}=$config[15];
- $config{'LastNamelength'}=$config[16];
- $config{'BubblesPerRow'}=$config[17];
- last;
- }
- return %config;
-}
-
=pod
=item username_to_idmap
@@ -6147,7 +6020,7 @@ sub username_to_idmap {
Process a requested correction to a scanline.
Arguments:
- $scantron_config - hash from &get_scantron_config()
+ $scantron_config - hash from &Apache::lonnet::get_scantron_config()
$scan_data - hash of correction information
(see &scantron_getfile())
$line - existing scanline
@@ -6830,7 +6703,7 @@ sub scantron_filter {
sub scantron_process_corrections {
my ($r) = @_;
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my ($scanlines,$scan_data)=&scantron_getfile();
my $classlist=&Apache::loncoursedata::get_classlist();
my $which=$env{'form.scantron_line'};
@@ -6999,7 +6872,7 @@ sub check_for_error {
sub scantron_warning_screen {
my ($button_text)=@_;
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'});
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my $CODElist;
if ($scantron_config{'CODElocation'} &&
$scantron_config{'CODEstart'} &&
@@ -7158,7 +7031,7 @@ sub scantron_validate_file {
#get the student pick code ready
$r->print(&Apache::loncommon::studentbrowser_javascript());
my $nav_error;
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my $max_bubble=&scantron_get_maxbubble(\$nav_error,\%scantron_config);
if ($nav_error) {
$r->print(&navmap_errormsg());
@@ -7617,7 +7490,7 @@ sub scantron_validate_ID {
my %idmap=&username_to_idmap($classlist);
#get scantron line setup
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my ($scanlines,$scan_data)=&scantron_getfile();
my $nav_error;
@@ -8081,7 +7954,7 @@ sub prompt_for_corrections {
Arguments:
$r - Apache request object
- $scan_config - hash from &get_scantron_config()
+ $scan_config - hash from &Apache::lonnet::get_scantron_config()
$line - Number of the line being displayed.
$questionnum - Question number (may include subquestion)
$error - Type of error.
@@ -8245,7 +8118,7 @@ sub get_codes {
sub scantron_validate_CODE {
my ($r,$currentphase) = @_;
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
if ($scantron_config{'CODElocation'} &&
$scantron_config{'CODEstart'} &&
$scantron_config{'CODElength'}) {
@@ -8319,7 +8192,7 @@ sub scantron_validate_doublebubble {
&Apache::lonnet::decode_symb($env{'form.selectpage'});
#get scantron line setup
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my ($scanlines,$scan_data)=&scantron_getfile();
my $navmap = Apache::lonnavmaps::navmap->new();
@@ -8501,7 +8374,7 @@ sub scantron_validate_missingbubbles {
&Apache::lonnet::decode_symb($env{'form.selectpage'});
#get scantron line setup
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my ($scanlines,$scan_data)=&scantron_getfile();
my $navmap = Apache::lonnavmaps::navmap->new();
@@ -8630,7 +8503,7 @@ sub hand_bubble_option {
}
}
if ($needs_hand_bubbles) {
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my $bubbles_per_row = &bubblesheet_bubbles_per_row(\%scantron_config);
return &mt('The sequence to be graded contains response types which are handgraded.').'
'.
&mt('If you have already graded these by bubbling sheets to indicate points awarded, [_1]what point value is assigned to a filled last bubble in each row?',' ').
@@ -8650,7 +8523,7 @@ sub scantron_process_students {
}
my $default_form_data=&defaultFormData($symb);
- my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my %scantron_config=&Apache::lonnet::get_scantron_config($env{'form.scantron_format'});
my $bubbles_per_row = &bubblesheet_bubbles_per_row(\%scantron_config);
my ($scanlines,$scan_data)=&scantron_getfile();
my $classlist=&Apache::loncoursedata::get_classlist();
@@ -8720,7 +8593,7 @@ SCANTRONFORM
return ''; # Dunno why the other returns return '' rather than just returning.
}
- my %lettdig = &letter_to_digits();
+ my %lettdig = &Apache::lonnet::letter_to_digits();
my $numletts = scalar(keys(%lettdig));
my %orderedforcode;
@@ -8783,9 +8656,14 @@ SCANTRONFORM
}
if ((exists($grader_randomlists_by_symb{$ressymb})) ||
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) {
+ my $currcode;
+ if (exists($grader_randomlists_by_symb{$ressymb})) {
+ $currcode = $scancode;
+ }
my ($analysis,$parts) =
&scantron_partids_tograde($resource,$env{'request.course.id'},
- $uname,$udom,undef,$bubbles_per_row);
+ $uname,$udom,undef,$bubbles_per_row,
+ $currcode);
$partids_by_symb{$ressymb} = $parts;
} else {
$partids_by_symb{$ressymb} = $grader_partids_by_symb{$ressymb};
@@ -9046,6 +8924,7 @@ sub grade_student_bubbles {
sub scantron_upload_scantron_data {
my ($r)=@_;
my $dom = $env{'request.role.domain'};
+ my ($formatoptions,$formattitle,$formatjs) = &scantron_upload_dataformat($dom);
my $domdesc = &Apache::lonnet::domain($dom,'description');
$r->print(&Apache::loncommon::coursebrowser_javascript($dom));
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid',
@@ -9059,8 +8938,7 @@ sub scantron_upload_scantron_data {
&js_escape(\$nofile_alert);
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.");
&js_escape(\$nocourseid_alert);
- $r->print('
-
-
+ '.$formatjs.'
+'));
+ $r->print('