--- loncom/homework/grades.pm 2007/07/19 09:52:59 1.422
+++ loncom/homework/grades.pm 2007/08/21 18:48:18 1.431
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.422 2007/07/19 09:52:59 foxr Exp $
+# $Id: grades.pm,v 1.431 2007/08/21 18:48:18 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,6 @@ use LONCAPA;
use POSIX qw(floor);
-my %oldessays=();
my %perm=();
# ----- These first few routines are general use routines.----
@@ -538,7 +537,7 @@ sub compute_points {
#
sub most_similar {
- my ($uname,$udom,$uessay)=@_;
+ my ($uname,$udom,$uessay,$old_essays)=@_;
# ignore spaces and punctuation
@@ -555,23 +554,22 @@ sub most_similar {
my $scrsid='';
my $sessay='';
# go through all essays ...
- foreach my $tkey (keys %oldessays) {
- my ($tname,$tdom,$tcrsid)=split(/\./,$tkey);
+ foreach my $tkey (keys(%$old_essays)) {
+ my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey));
# ... except the same student
- if (($tname ne $uname) || ($tdom ne $udom)) {
- my $tessay=$oldessays{$tkey};
- $tessay=~s/\W+/ /gs;
+ next if (($tname eq $uname) && ($tdom eq $udom));
+ my $tessay=$old_essays->{$tkey};
+ $tessay=~s/\W+/ /gs;
# String similarity gives up if not even limit
- my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit);
+ my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit);
# Found one
- if ($tsimilar>$limit) {
- $limit=$tsimilar;
- $sname=$tname;
- $sdom=$tdom;
- $scrsid=$tcrsid;
- $sessay=$oldessays{$tkey};
- }
- }
+ if ($tsimilar>$limit) {
+ $limit=$tsimilar;
+ $sname=$tname;
+ $sdom=$tdom;
+ $scrsid=$tcrsid;
+ $sessay=$old_essays->{$tkey};
+ }
}
if ($limit>0.6) {
return ($sname,$sdom,$scrsid,$sessay,$limit);
@@ -1691,6 +1689,7 @@ sub submission {
'" src="'.$request->dir_config('lonIconsURL').
'/check.gif" height="16" border="0" />';
+ my %old_essays;
# header info
if ($counter == 0) {
&sub_page_js($request);
@@ -1805,7 +1804,7 @@ KEYWORDS
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
$apath=&escape($apath);
$apath=~s/\W/\_/gs;
- %oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ %old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
}
}
@@ -1943,12 +1942,21 @@ KEYWORDS
my $similar='';
if($env{'form.checkPlag'}){
my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$subval);
+ &most_similar($uname,$udom,$subval,\%old_essays);
if ($osim) {
$osim=int($osim*100.0);
- $similar="
Essay".
- " is $osim% similar to an essay by ".
- &Apache::loncommon::plainname($oname,$odom).
+ my %old_course_desc =
+ &Apache::lonnet::coursedescription($ocrsid,
+ {'one_time' => 1});
+
+ $similar="
".
+ &mt('Essay is [_1]% similar to an essay by [_2] ([_3]:[_4]) in course [_5] (course id [_6]:[_7])',
+ $osim,
+ &Apache::loncommon::plainname($oname,$odom),
+ $oname,$odom,
+ $old_course_desc{'description'},
+ $old_course_desc{'num'},
+ $old_course_desc{'domain'}).
'
'.
&keywords_highlight($oessay).
'
';
@@ -2963,14 +2971,15 @@ sub viewgrades {
''."\n";
my $sectionClass;
+ my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
if ($env{'form.section'} eq 'all') {
$sectionClass='Class
';
} elsif ($env{'form.section'} eq 'none') {
- $sectionClass='Students in no Section ';
+ $sectionClass=&mt('Students in no Section').'';
} else {
- $sectionClass='Students in Section '.$env{'form.section'}.'';
+ $sectionClass=&mt('Students in Section(s) [_1]',$section_display).'';
}
- $result.='
Assign Common Grade To '.$sectionClass;
+ $result.='
'.&mt('Assign Common Grade To [_1]',$sectionClass);
$result.= '
'."\n".
'
';
#radio buttons/text box for assigning points for a section or class.
@@ -3827,7 +3836,7 @@ LISTJAVASCRIPT
$result.='
@@ -4621,13 +4741,62 @@ SCANTRONFORM
return
}
-# Parse and return the scantron configuration line selected as a
-# hash of configuration file fields.
-#
-# Parameters:
-# which - the name of the configuration to parse from the file.
-# If the named configuration is not in the file, an empty
-# hash is returned.
+=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 ID number starts
+ IDlength - length of the student 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
+
+=cut
sub get_scantron_config {
my ($which) = @_;
@@ -4661,15 +4830,25 @@ sub get_scantron_config {
return %config;
}
-# creates a hash keyed by student id that conains
-# the corresponding student username:domain.
-# Parameters:
-# reference to the class list hash. This is a hash
-# keyed by student name:domain whose elements are references
-# to arrays containng various chunks of information
-# about the student. (See loncoursedata for more info).
-#
-#
+=pod
+
+=item username_to_idmap
+
+ creates a hash keyed by student id with values of the corresponding
+ student username:domain.
+
+ Arguments:
+
+ $classlist - reference to the class list hash. This is a hash
+ keyed by student name:domain whose elements are references
+ to arrays containing various chunks of information
+ about the student. (See loncoursedata for more info).
+
+ Returns
+ %idmap - the constructed hash
+
+=cut
+
sub username_to_idmap {
my ($classlist)= @_;
my %idmap;
@@ -4679,22 +4858,51 @@ sub username_to_idmap {
}
return %idmap;
}
-#
-# Make a correction in a scantron line?
-# Parameters:
-# scantron_config - Format of the scantron file
-# scan_data - Hash of line by line info about the scan(?).
-# line - Scantron line to edit?
-# whichline
-# field
-# args - Keyword/value hash of additional parameters.
-#
+
+=pod
+
+=item scantron_fixup_scanline
+
+ Process a requested correction to a scanline.
+
+ Arguments:
+ $scantron_config - hash from &get_scantron_config()
+ $scan_data - hash of correction information
+ (see &scantron_getfile())
+ $line - existing scanline
+ $whichline - line number of the passed in scanline
+ $field - type of change to process
+ (either
+ 'ID' -> correct the student ID number
+ 'CODE' -> correct the CODE
+ 'answer' -> fixup the submitted answers)
+
+ $args - hash of additional info,
+ - 'ID'
+ 'newid' -> studentID to use in replacement
+ of existing one
+ - 'CODE'
+ 'CODE_ignore_dup' - set to true if duplicates
+ should be ignored.
+ 'CODE' - is new code or 'use_unfound'
+ if the existing unfound code should
+ be used as is
+ - 'answer'
+ 'response' - new answer or 'none' if blank
+ 'question' - the bubble line to change
+
+ Returns:
+ $line - the modified scanline
+
+ Side effects:
+ $scan_data - may be updated
+
+=cut
+
sub scantron_fixup_scanline {
my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_;
- #
- # ID field, args->{'newid'} is the new value of the ID field.
- #
+
if ($field eq 'ID') {
if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) {
return ($line,1,'New value too large');
@@ -4709,11 +4917,6 @@ sub scantron_fixup_scanline {
&scan_data($scan_data,"$whichline.user",
$args->{'username'}.':'.$args->{'domain'});
}
- # CODE Field,
- # args->{CODE_ignore_dup} is true if duplicates should be ignored.
- # args->{CODE} is new code or 'use_unfound' if an unfound code should
- # be used as is?
- #
} elsif ($field eq 'CODE') {
if ($args->{'CODE_ignore_dup'}) {
&scan_data($scan_data,"$whichline.CODE_ignore_dup",'1');
@@ -4729,11 +4932,6 @@ sub scantron_fixup_scanline {
substr($line,$$scantron_config{'CODEstart'}-1,
$$scantron_config{'CODElength'})=$args->{'CODE'};
}
- #
- # Edit the answer field.
- # args->{'response'} - new answer or 'none' if blank.
- # args->{'question'} - the question (number?)?.
- #
} elsif ($field eq 'answer') {
my $length=$scantron_config->{'Qlength'};
my $off=$scantron_config->{'Qoff'};
@@ -4760,16 +4958,26 @@ sub scantron_fixup_scanline {
}
return $line;
}
-# Edit or look up an item in the scan_data hash.
-# Parameters:
-# scan_data - The hash.
-# key - shorthand of the key to edit (actual key is
-# scatronfilename_key.
-# data - New value of the hash entry.
-# delete - If defined, the entry is removed from the table.
-# Returns:
-# The new value of the hash table field (undefined if deleted).
-#
+
+=pod
+
+=item scan_data
+
+ Edit or look up an item in the scan_data hash.
+
+ Arguments:
+ $scan_data - The hash (see scantron_getfile)
+ $key - shorthand of the key to edit (actual key is
+ scantronfilename_key).
+ $data - New value of the hash entry.
+ $delete - If true, the entry is removed from the hash.
+
+ Returns:
+ The new value of the hash table field (undefined if deleted).
+
+=cut
+
+
sub scan_data {
my ($scan_data,$key,$value,$delete)=@_;
my $filename=$env{'form.scantron_selectfile'};
@@ -4779,20 +4987,61 @@ sub scan_data {
if ($delete) { delete($scan_data->{$filename.'_'.$key}); }
return $scan_data->{$filename.'_'.$key};
}
-#
-# Decode a line on the uploaded scantron file:
-# Arguments:
-# line - The text of the scantron file line to process
-# whichline - Line number(?)
-# scantron_config - Hash describing the format of the scantron lines.
-# scan_data - Hash being built up of the entire scantron file.
-# justHeader - True if should not process question answers but only
-# the stuff to the left of the answers.
-# Returns:
-# Hash of data from the line?
-#
+
+=pod
+
+=item scantron_parse_scanline
+
+ Decodes a scanline from the selected scantron file
+
+ Arguments:
+ line - The text of the scantron file line to process
+ whichline - Line number
+ scantron_config - Hash describing the format of the scantron lines.
+ scan_data - Hash of extra information about the scanline
+ (see scantron_getfile for more information)
+ just_header - True if should not process question answers but only
+ the stuff to the left of the answers.
+ Returns:
+ Hash containing the result of parsing the scanline
+
+ Keys are all proceeded by the string 'scantron.'
+
+ CODE - the CODE in use for this scanline
+ useCODE - 1 if the CODE is invalid but it usage has been forced
+ by the operator
+ CODE_ignore_dup - 1 if the CODE is a duplicated use when unique
+ CODEs were selected, but the usage has been
+ forced by the operator
+ ID - student ID
+ PaperID - if used, the ID number printed on the sheet when the
+ paper was scanned
+ FirstName - first name from the sheet
+ LastName - last name from the sheet
+
+ if just_header was not true these key may also exist
+
+ missingerror - a list of bubbled line numbers that had a blank bubble
+ that is considered an error (if the operator had already
+ okayed a blank bubble line as really being blank then
+ that bubble line number won't appear here.
+ doubleerror - a list of bubbled line numbers that had more than one
+ bubble filled in and has not been corrected by the
+ operator
+ maxquest - the number of the last bubble line that was parsed
+
+ ( starts at 1)
+ .answer - zero or more letters representing the selected
+ letters from the scanline for the bubble line
+ .
+ if blank there was either no bubble or there where
+ multiple bubbles, (consult the keys missingerror and
+ doubleerror if this is an error condition)
+
+=cut
+
sub scantron_parse_scanline {
- my ($line,$whichline,$scantron_config,$scan_data,$justHeader)=@_;
+ my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_;
my %record;
my $questions=substr($line,$$scantron_config{'Qstart'}-1); # Answers
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff
@@ -4825,7 +5074,7 @@ sub scantron_parse_scanline {
$record{'scantron.LastName'}=
substr($data,$$scantron_config{'LastName'}-1,
$$scantron_config{'LastNamelength'});
- if ($justHeader) { return \%record; }
+ if ($just_header) { return \%record; }
my @alphabet=('A'..'Z');
my $questnum=0;
@@ -4898,6 +5147,24 @@ sub scantron_parse_scanline {
return \%record;
}
+=pod
+
+=item scantron_add_delay
+
+ Adds an error message that occurred during the grading phase to a
+ queue of messages to be shown after grading pass is complete
+
+ Arguments:
+ $delayqueue - arrary ref of hash ref of error messages
+ $scanline - the scanline that caused the error
+ $errormesage - the error message
+ $errorcode - a numeric code for the error
+
+ Side Effects:
+ updates the $delayqueue to have a new hash ref of the error
+
+=cut
+
sub scantron_add_delay {
my ($delayqueue,$scanline,$errormessage,$errorcode)=@_;
push(@$delayqueue,
@@ -4906,6 +5173,24 @@ sub scantron_add_delay {
);
}
+=pod
+
+=item scantron_find_student
+
+ Finds the username for the current scanline
+
+ Arguments:
+ $scantron_record - hash result from scantron_parse_scanline
+ $scan_data - hash of correction information
+ (see &scantron_getfile() form more information)
+ $idmap - hash from &username_to_idmap()
+ $line - number of current scanline
+
+ Returns:
+ Either 'username:domain' or undef if unknown
+
+=cut
+
sub scantron_find_student {
my ($scantron_record,$scan_data,$idmap,$line)=@_;
my $scanID=$$scantron_record{'scantron.ID'};
@@ -4920,6 +5205,15 @@ sub scantron_find_student {
return undef;
}
+=pod
+
+=item scantron_filter
+
+ Filter sub for lonnavmaps, filters out hidden resources if ignore
+ hidden resources was selected
+
+=cut
+
sub scantron_filter {
my ($curres)=@_;
@@ -4936,6 +5230,15 @@ sub scantron_filter {
return 0;
}
+=pod
+
+=item scantron_process_corrections
+
+ Gets correction information out of submitted form data and corrects
+ the scanline
+
+=cut
+
sub scantron_process_corrections {
my ($r) = @_;
my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
@@ -4993,12 +5296,30 @@ sub scantron_process_corrections {
}
}
+=pod
+
+=item reset_skipping_status
+
+ Forgets the current set of remember skipped scanlines (and thus
+ reverts back to considering all lines in the
+ scantron_skipped_ file)
+
+=cut
+
sub reset_skipping_status {
my ($scanlines,$scan_data)=&scantron_getfile();
&scan_data($scan_data,'remember_skipping',undef,1);
&scantron_putfile(undef,$scan_data);
}
+=pod
+
+=item start_skipping
+
+ Marks a scanline to be skipped.
+
+=cut
+
sub start_skipping {
my ($scan_data,$i)=@_;
my %remembered=split(':',&scan_data($scan_data,'remember_skipping'));
@@ -5010,6 +5331,14 @@ sub start_skipping {
&scan_data($scan_data,'remember_skipping',join(':',%remembered));
}
+=pod
+
+=item should_be_skipped
+
+ Checks whether a scanline should be skipped.
+
+=cut
+
sub should_be_skipped {
my ($scanlines,$scan_data,$i)=@_;
if ($env{'form.scantron_options_redo'} !~ /^redo_/) {
@@ -5025,6 +5354,15 @@ sub should_be_skipped {
return 1;
}
+=pod
+
+=item remember_current_skipped
+
+ Discovers what scanlines are in the scantron_skipped_
+ file and remembers them into scan_data for later use.
+
+=cut
+
sub remember_current_skipped {
my ($scanlines,$scan_data)=&scantron_getfile();
my %to_remember;
@@ -5038,6 +5376,16 @@ sub remember_current_skipped {
&scantron_putfile(undef,$scan_data);
}
+=pod
+
+=item check_for_error
+
+ Checks if there was an error when attempting to remove a specific
+ scantron_.. bubble sheet data file. Prints out an error if
+ something went wrong.
+
+=cut
+
sub check_for_error {
my ($r,$result)=@_;
if ($result ne 'ok' && $result ne 'not_found' ) {
@@ -5045,6 +5393,15 @@ sub check_for_error {
}
}
+=pod
+
+=item scantron_warning_screen
+
+ Interstitial screen to make sure the operator has selected the
+ correct options before we start the validation phase.
+
+=cut
+
sub scantron_warning_screen {
my ($button_text)=@_;
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'});
@@ -5077,6 +5434,15 @@ $CODElist
STUFF
}
+=pod
+
+=item scantron_do_warning
+
+ Check if the operator has picked something for all required
+ fields. Error out if something is missing.
+
+=cut
+
sub scantron_do_warning {
my ($r)=@_;
my ($symb)=&get_symb($r);
@@ -5108,6 +5474,14 @@ STUFF
return '';
}
+=pod
+
+=item scantron_form_start
+
+ html hidden input for remembering all selected grading options
+
+=cut
+
sub scantron_form_start {
my ($max_bubble)=@_;
my $result= <print("
Gathering neccessary info.
");$r->rflush();
+ $r->print("
Gathering necessary info.
");$r->rflush();
#get the student pick code ready
$r->print(&Apache::loncommon::studentbrowser_javascript());
my $max_bubble=&scantron_get_maxbubble();
@@ -5208,6 +5594,17 @@ STUFF
return '';
}
+
+=pod
+
+=item scantron_remove_file
+
+ Removes the requested bubble sheet data file, makes sure that
+ scantron_original_ is never removed
+
+
+=cut
+
sub scantron_remove_file {
my ($which)=@_;
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
@@ -5222,6 +5619,18 @@ sub scantron_remove_file {
return &Apache::lonnet::removeuserfile($cname,$cdom,$file);
}
+
+=pod
+
+=item scantron_remove_scan_data
+
+ Removes all scan_data correction for the requested bubble sheet
+ data file. (In the case that both the are doing skipped records we need
+ to remember the old skipped lines for the time being so that element
+ persists for a while.)
+
+=cut
+
sub scantron_remove_scan_data {
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -5244,6 +5653,51 @@ sub scantron_remove_scan_data {
return $result;
}
+
+=pod
+
+=item scantron_getfile
+
+ Fetches the requested bubble sheet data file (all 3 versions), and
+ the scan_data hash
+
+ Arguments:
+ None
+
+ Returns:
+ 2 hash references
+
+ - first one has
+ orig -
+ corrected -
+ skipped - each of which points to an array ref of the specified
+ file broken up into individual lines
+ count - number of scanlines
+
+ - second is the scan_data hash possible keys are
+ ($number refers to scanline numbered $number and thus the key affects
+ only that scanline
+ $bubline refers to the specific bubble line element and the aspects
+ refers to that specific bubble line element)
+
+ $number.user - username:domain to use
+ $number.CODE_ignore_dup
+ - ignore the duplicate CODE error
+ $number.useCODE
+ - use the CODE in the scanline as is
+ $number.no_bubble.$bubline
+ - it is valid that there is no bubbled in bubble
+ at $number $bubline
+ remember_skipping
+ - a frozen hash containing keys of $number and values
+ of either
+ 1 - we are on a 'do skipped records pass' and plan
+ on processing this line
+ 2 - we are on a 'do skipped records pass' and this
+ scanline has been marked to skip yet again
+
+=cut
+
sub scantron_getfile {
#FIXME really would prefer a scantron directory
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
@@ -5276,6 +5730,21 @@ sub scantron_getfile {
return (\%scanlines,\%scan_data);
}
+=pod
+
+=item lonnet_putfile
+
+ Wrapper routine to call &Apache::lonnet::finishuserfileupload
+
+ Arguments:
+ $contents - data to store
+ $filename - filename to store $contents into
+
+ Returns:
+ result value from &Apache::lonnet::finishuserfileupload
+
+=cut
+
sub lonnet_putfile {
my ($contents,$filename)=@_;
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
@@ -5285,6 +5754,22 @@ sub lonnet_putfile {
}
+=pod
+
+=item scantron_putfile
+
+ Stores the current version of the bubble sheet data files, and the
+ scan_data hash. (Does not modify the original version only the
+ corrected and skipped versions.
+
+ Arguments:
+ $scanlines - hash ref that looks like the first return value from
+ &scantron_getfile()
+ $scan_data - hash ref that looks like the second return value from
+ &scantron_getfile()
+
+=cut
+
sub scantron_putfile {
my ($scanlines,$scan_data) = @_;
#FIXME really would prefer a scantron directory
@@ -5305,6 +5790,28 @@ sub scantron_putfile {
&Apache::lonnet::put('nohist_scantrondata',$scan_data,$cdom,$cname);
}
+=pod
+
+=item scantron_get_line
+
+ Returns the correct version of the scanline
+
+ Arguments:
+ $scanlines - hash ref that looks like the first return value from
+ &scantron_getfile()
+ $scan_data - hash ref that looks like the second return value from
+ &scantron_getfile()
+ $i - number of the requested line (starts at 0)
+
+ Returns:
+ A scanline, (either the original or the corrected one if it
+ exists), or undef if the requested scanline should be
+ skipped. (Either because it's an skipped scanline, or it's an
+ unskipped scanline and we are not doing a 'do skipped scanlines'
+ pass.
+
+=cut
+
sub scantron_get_line {
my ($scanlines,$scan_data,$i)=@_;
if (&should_be_skipped($scanlines,$scan_data,$i)) { return undef; }
@@ -5313,6 +5820,23 @@ sub scantron_get_line {
return $scanlines->{'orig'}[$i];
}
+=pod
+
+=item scantron_todo_count
+
+ Counts the number of scanlines that need processing.
+
+ Arguments:
+ $scanlines - hash ref that looks like the first return value from
+ &scantron_getfile()
+ $scan_data - hash ref that looks like the second return value from
+ &scantron_getfile()
+
+ Returns:
+ $count - number of scanlines to process
+
+=cut
+
sub get_todo_count {
my ($scanlines,$scan_data)=@_;
my $count=0;
@@ -5324,6 +5848,25 @@ sub get_todo_count {
return $count;
}
+=pod
+
+=item scantron_put_line
+
+ Updates the 'corrected' or 'skipped' versions of the bubble sheet
+ data file.
+
+ Arguments:
+ $scanlines - hash ref that looks like the first return value from
+ &scantron_getfile()
+ $scan_data - hash ref that looks like the second return value from
+ &scantron_getfile()
+ $i - line number to update
+ $newline - contents of the updated scanline
+ $skip - if true make the line for skipping and update the
+ 'skipped' file
+
+=cut
+
sub scantron_put_line {
my ($scanlines,$scan_data,$i,$newline,$skip)=@_;
if ($skip) {
@@ -5334,6 +5877,21 @@ sub scantron_put_line {
$scanlines->{'corrected'}[$i]=$newline;
}
+=pod
+
+=item scantron_clear_skip
+
+ Remove a line from the 'skipped' file
+
+ Arguments:
+ $scanlines - hash ref that looks like the first return value from
+ &scantron_getfile()
+ $scan_data - hash ref that looks like the second return value from
+ &scantron_getfile()
+ $i - line number to update
+
+=cut
+
sub scantron_clear_skip {
my ($scanlines,$scan_data,$i)=@_;
if (exists($scanlines->{'skipped'}[$i])) {
@@ -5343,6 +5901,15 @@ sub scantron_clear_skip {
return 0;
}
+=pod
+
+=item scantron_filter_not_exam
+
+ Filter routine used by &Apache::lonnavmaps::retrieveResources(), to
+ filter out resources that are not marked as 'exam' mode
+
+=cut
+
sub scantron_filter_not_exam {
my ($curres)=@_;
@@ -5359,6 +5926,15 @@ sub scantron_filter_not_exam {
return 0;
}
+=pod
+
+=item scantron_validate_sequence
+
+ Validates the selected sequence, checking for resource that are
+ not set to exam mode.
+
+=cut
+
sub scantron_validate_sequence {
my ($r,$currentphase) = @_;
@@ -5382,6 +5958,15 @@ sub scantron_validate_sequence {
return (0,$currentphase+1);
}
+=pod
+
+=item scantron_validate_ID
+
+ Validates all scanlines in the selected file to not have any
+ invalid or underspecified student IDs
+
+=cut
+
sub scantron_validate_ID {
my ($r,$currentphase) = @_;
@@ -5444,6 +6029,36 @@ sub scantron_validate_ID {
return (0,$currentphase+1);
}
+=pod
+
+=item scantron_get_correction
+
+ Builds the interface screen to interact with the operator to fix a
+ specific error condition in a specific scanline
+
+ Arguments:
+ $r - Apache request object
+ $i - number of the current scanline
+ $scan_record - hash ref as returned from &scantron_parse_scanline()
+ $scan_config - hash ref as returned from &get_scantron_config()
+ $line - full contents of the current scanline
+ $error - error condition, valid values are
+ 'incorrectCODE', 'duplicateCODE',
+ 'doublebubble', 'missingbubble',
+ 'duplicateID', 'incorrectID'
+ $arg - extra information needed
+ For errors:
+ - duplicateID - paper number that this studentID was seen before on
+ - duplicateCODE - array ref of the paper numbers this CODE was
+ seen on before
+ - incorrectCODE - current incorrect CODE
+ - doublebubble - array ref of the bubble lines that have double
+ bubble errors
+ - missingbubble - array ref of the bubble lines that have missing
+ bubble errors
+
+=cut
+
sub scantron_get_correction {
my ($r,$i,$scan_record,$scan_config,$line,$error,$arg)=@_;
@@ -5567,15 +6182,23 @@ ENDSCRIPT
$r->print("\n");
}
-#
-# Ask the grader to select the actual bubble
-#
-# Arguments:
-# r - Apache request.
-# scan_config - Hash of the scantron format selected.
-# quest - Question being evaluated
-# selected - array of selected bubbles
-# lines - if present, number of bubble lines in questions.
+
+=pod
+
+=item scantron_bubble_selector
+
+ Generates the html radiobuttons to correct a single bubble line
+ possibly showing the existing the selected bubbles if known
+
+ Arguments:
+ $r - Apache request object
+ $scan_config - hash from &get_scantron_config()
+ $quest - number of the bubble line to make a corrector for
+ $selected - array of letters of previously selected bubbles
+ $lines - if present, number of bubble lines to show
+
+=cut
+
sub scantron_bubble_selector {
my ($r,$scan_config,$quest,@selected, $lines)=@_;
my $max=$$scan_config{'Qlength'};
@@ -5637,6 +6260,22 @@ sub scantron_bubble_selector {
$r->print('
');
}
+=pod
+
+=item num_matches
+
+ Counts the number of characters that are the same between the two arguments.
+
+ Arguments:
+ $orig - CODE from the scanline
+ $code - CODE to match against
+
+ Returns:
+ $count - integer count of the number of same characters between the
+ two arguments
+
+=cut
+
sub num_matches {
my ($orig,$code) = @_;
my @code=split(//,$code);
@@ -5648,6 +6287,26 @@ sub num_matches {
return $same;
}
+=pod
+
+=item scantron_get_closely_matching_CODEs
+
+ Cycles through all CODEs and finds the set that has the greatest
+ number of same characters as the provided CODE
+
+ Arguments:
+ $allcodes - hash ref returned by &get_codes()
+ $CODE - CODE from the current scanline
+
+ Returns:
+ 2 element list
+ - first elements is number of how closely matching the best fit is
+ (5 means best set has 5 matching characters)
+ - second element is an arrary ref containing the set of valid CODEs
+ that best fit the passed in CODE
+
+=cut
+
sub scantron_get_closely_matching_CODEs {
my ($allcodes,$CODE)=@_;
my @CODEs;
@@ -5658,6 +6317,23 @@ sub scantron_get_closely_matching_CODEs
return ($#CODEs,$CODEs[-1]);
}
+=pod
+
+=item get_codes
+
+ Builds a hash which has keys of all of the valid CODEs from the selected
+ set of remembered CODEs.
+
+ Arguments:
+ $old_name - name of the set of remembered CODEs
+ $cdom - domain of the course
+ $cnum - internal course name
+
+ Returns:
+ %allcodes - keys are the valid CODEs, values are all 1
+
+=cut
+
sub get_codes {
my ($old_name, $cdom, $cnum) = @_;
if (!$old_name) {
@@ -5680,6 +6356,16 @@ sub get_codes {
return %allcodes;
}
+=pod
+
+=item scantron_validate_CODE
+
+ Validates all scanlines in the selected file to not have any
+ invalid or underspecified CODEs and that none of the codes are
+ duplicated if this was requested.
+
+=cut
+
sub scantron_validate_CODE {
my ($r,$currentphase) = @_;
my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
@@ -5731,6 +6417,15 @@ sub scantron_validate_CODE {
return (0,$currentphase+1);
}
+=pod
+
+=item scantron_validate_doublebubble
+
+ Validates all scanlines in the selected file to not have any
+ bubble lines with multiple bubbles marked.
+
+=cut
+
sub scantron_validate_doublebubble {
my ($r,$currentphase) = @_;
#get student info
@@ -5754,6 +6449,19 @@ sub scantron_validate_doublebubble {
return (0,$currentphase+1);
}
+=pod
+
+=item scantron_get_maxbubble
+
+ Returns the maximum number of bubble lines that are expected to
+ occur. Does this by walking the selected sequence rendering the
+ resource and then checking &Apache::lonxml::get_problem_counter()
+ for what the current value of the problem counter is.
+
+ Caches the result to $env{'form.scantron_maxbubble'}
+
+=cut
+
sub scantron_get_maxbubble {
if (defined($env{'form.scantron_maxbubble'}) &&
$env{'form.scantron_maxbubble'}) {
@@ -5780,6 +6488,15 @@ sub scantron_get_maxbubble {
return $env{'form.scantron_maxbubble'};
}
+=pod
+
+=item scantron_validate_missingbubbles
+
+ Validates all scanlines in the selected file to not have any
+ bubble lines with missing bubbles that haven't been verified as missing.
+
+=cut
+
sub scantron_validate_missingbubbles {
my ($r,$currentphase) = @_;
#get student info
@@ -5812,6 +6529,30 @@ sub scantron_validate_missingbubbles {
return (0,$currentphase+1);
}
+=pod
+
+=item scantron_process_students
+
+ Routine that does the actual grading of the bubble sheet information.
+
+ The parsed scanline hash is added to %env
+
+ Then foreach unskipped scanline it does an &Apache::lonnet::ssi()
+ foreach resource , with the form data of
+
+ 'submitted' =>'scantron'
+ 'grade_target' =>'grade',
+ 'grade_username'=> username of student
+ 'grade_domain' => domain of student
+ 'grade_courseid'=> of course
+ 'grade_symb' => symb of resource to grade
+
+ This triggers a grading pass. The problem grading code takes care
+ of converting the bubbled letter information (now in %env) into a
+ valid submission.
+
+=cut
+
sub scantron_process_students {
my ($r) = @_;
my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($env{'form.selectpage'});
@@ -5916,6 +6657,14 @@ SCANTRONFORM
return '';
}
+=pod
+
+=item scantron_upload_scantron_data
+
+ Creates the screen for adding a new bubble sheet data file to a course.
+
+=cut
+
sub scantron_upload_scantron_data {
my ($r)=@_;
$r->print(&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}));
@@ -5952,6 +6701,15 @@ UPLOAD
return '';
}
+=pod
+
+=item scantron_upload_scantron_data_save
+
+ Adds a provided bubble information data file to the course if user
+ has the correct privileges to do so.
+
+=cut
+
sub scantron_upload_scantron_data_save {
my($r)=@_;
my ($symb)=&get_symb($r,1);
@@ -6007,6 +6765,14 @@ sub scantron_upload_scantron_data_save {
return '';
}
+=pod
+
+=item valid_file
+
+ Validates that the requested bubble data file exists in the course.
+
+=cut
+
sub valid_file {
my ($requested_file)=@_;
foreach my $filename (sort(&scantron_filenames())) {
@@ -6015,6 +6781,16 @@ sub valid_file {
return 0;
}
+=pod
+
+=item scantron_download_scantron_data
+
+ Shows a list of the three internal files (original, corrected,
+ skipped) for a specific bubble sheet data file that exists in the
+ course.
+
+=cut
+
sub scantron_download_scantron_data {
my ($r)=@_;
my $default_form_data=&defaultFormData(&get_symb($r,1));
@@ -6051,6 +6827,12 @@ DOWNLOAD
return '';
}
+=pod
+
+=back
+
+=cut
+
#-------- end of section for handling grading scantron forms -------
#
#-------------------------------------------------------------------
@@ -6151,7 +6933,7 @@ GRADINGMENUJS
$result.='