version 1.372, 2006/08/16 18:07:25
|
version 1.377, 2006/09/27 22:09:16
|
Line 112 sub nameUserString {
|
Line 112 sub nameUserString {
|
#--- Indicate if a response type is coded handgraded or not. --- |
#--- Indicate if a response type is coded handgraded or not. --- |
sub response_type { |
sub response_type { |
my ($symb) = shift; |
my ($symb) = shift; |
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); |
|
my $allkeys = &Apache::lonnet::metadata($url,'keys'); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my %vPart; |
my $res = $navmap->getBySymb($symb); |
foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) { |
my $partlist = $res->parts(); |
$vPart{$partid}=1; |
my (%response_types,%handgrade); |
} |
foreach my $part (@{ $partlist }) { |
my %seen = (); |
my @types = $res->responseType($part); |
my (@partlist,%handgrade,%responseType); |
my @ids = $res->responseIds($part); |
foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) { |
for (my $i=0; $i < scalar(@ids); $i++) { |
if (/^\w+response_.*/ || /^Task_/) { |
$response_types{$part}{$ids[$i]} = $types[$i]; |
my ($responsetype,$part) = split(/_/,$_,2); |
$handgrade{$part.'_'.$ids[$i]} = |
my ($partid,$respid) = split(/_/,$part); |
&Apache::lonnet::EXT('resource.'.$part.'_'.$ids[$i]. |
if ($responsetype eq 'Task') { $respid='0'; } |
'.handgrade',$symb); |
if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) { |
} |
next; |
} |
} |
return ($partlist,\%handgrade,\%response_types); |
if (%vPart && !exists($vPart{$partid})) { |
} |
next; |
|
} |
sub flatten_responseType { |
$responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!! |
my ($responseType) = @_; |
my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb); |
my @part_response_id = |
$handgrade{$part} = ($value eq 'yes' ? 'yes' : 'no'); |
map { |
if (!exists($responseType{$partid})) { $responseType{$partid}={}; } |
my $part = $_; |
$responseType{$partid}->{$respid}=$responsetype; |
map { |
next if ($seen{$partid} > 0); |
[$part,$_] |
$seen{$partid}++; |
} sort(keys(%{ $responseType->{$part} })); |
push @partlist,$partid; |
} sort(keys(%$responseType)); |
} |
return @part_response_id; |
} |
|
return (\@partlist,\%handgrade,\%responseType); |
|
} |
} |
|
|
sub get_display_part { |
sub get_display_part { |
Line 168 sub showResourceInfo {
|
Line 166 sub showResourceInfo {
|
my %resptype = (); |
my %resptype = (); |
my $hdgrade='no'; |
my $hdgrade='no'; |
my %partsseen; |
my %partsseen; |
for my $part_resID (sort keys(%$handgrade)) { |
foreach my $partID (sort keys(%$responseType)) { |
my $handgrade=$$handgrade{$part_resID}; |
foreach my $resID (sort keys(%{ $responseType->{$partID} })) { |
my ($partID,$resID) = split(/_/,$part_resID); |
my $handgrade=$$handgrade{$partID.'_'.$resID}; |
my $responsetype = $responseType->{$partID}->{$resID}; |
my $responsetype = $responseType->{$partID}->{$resID}; |
$hdgrade = $handgrade if ($handgrade eq 'yes'); |
$hdgrade = $handgrade if ($handgrade eq 'yes'); |
$result.='<tr>'; |
$result.='<tr>'; |
if ($checkboxes) { |
if ($checkboxes) { |
if (exists($partsseen{$partID})) { |
if (exists($partsseen{$partID})) { |
$result.="<td> </td>"; |
$result.="<td> </td>"; |
} else { |
} else { |
$result.="<td><input type='checkbox' name='vPart' value='$partID' checked='on' /></td>"; |
$result.="<td><input type='checkbox' name='vPart' value='$partID' checked='on' /></td>"; |
|
} |
|
$partsseen{$partID}=1; |
} |
} |
$partsseen{$partID}=1; |
my $display_part=&get_display_part($partID,$symb); |
} |
$result.='<td><b>Part: </b>'.$display_part.' <font color="#999999">'. |
my $display_part=&get_display_part($partID,$symb); |
$resID.'</font></td>'. |
$result.='<td><b>Part: </b>'.$display_part.' <font color="#999999">'. |
'<td><b>Type: </b>'.$responsetype.'</td></tr>'; |
$resID.'</font></td>'. |
|
'<td><b>Type: </b>'.$responsetype.'</td></tr>'; |
|
# '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>'; |
# '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>'; |
|
} |
} |
} |
$result.='</table>'."\n"; |
$result.='</table>'."\n"; |
return $result,$responseType,$hdgrade,$partlist,$handgrade; |
return $result,$responseType,$hdgrade,$partlist,$handgrade; |
Line 1538 sub handback_box {
|
Line 1537 sub handback_box {
|
my ($symb,$uname,$udom,$counter,$partid,$record) = @_; |
my ($symb,$uname,$udom,$counter,$partid,$record) = @_; |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
my (@respids); |
my (@respids); |
foreach my $part_resp (sort(keys(%$handgrade))) { |
my @part_response_id = &flatten_responseType($responseType); |
my ($part,$resp) = split(/_/,$part_resp); |
foreach my $part_response_id (@part_response_id) { |
|
my ($part,$resp) = @{ $part_response_id }; |
if ($part eq $partid) { |
if ($part eq $partid) { |
push @respids,$resp; |
push(@respids,$resp); |
} |
} |
} |
} |
my $result; |
my $result; |
Line 1579 sub show_problem {
|
Line 1579 sub show_problem {
|
if ($removeform) { |
if ($removeform) { |
$rendered=~s|<form(.*?)>||g; |
$rendered=~s|<form(.*?)>||g; |
$rendered=~s|</form>||g; |
$rendered=~s|</form>||g; |
$rendered=~s|name="submit"|name="would_have_been_submit"|g; |
$rendered=~s|(<input[^>]*name\s*=\s*"?)(\w+)("?)|$1would_have_been_$2$3|g; |
} |
} |
my $companswer; |
my $companswer; |
if ($mode eq 'both' or $mode eq 'answer') { |
if ($mode eq 'both' or $mode eq 'answer') { |
Line 1858 KEYWORDS
|
Line 1858 KEYWORDS
|
$lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0]; |
$lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0]; |
} else { |
} else { |
my %seenparts; |
my %seenparts; |
for my $part (sort keys(%$handgrade)) { |
my @part_response_id = &flatten_responseType($responseType); |
my ($partid,$respid) = split(/_/,$part); |
foreach my $part (@part_response_id) { |
|
my ($partid,$respid) = @{ $part }; |
my $display_part=&get_display_part($partid,$symb); |
my $display_part=&get_display_part($partid,$symb); |
if ($env{"form.$uname:$udom:$partid:submitted_by"}) { |
if ($env{"form.$uname:$udom:$partid:submitted_by"}) { |
if (exists($seenparts{$partid})) { next; } |
if (exists($seenparts{$partid})) { next; } |
Line 1883 KEYWORDS
|
Line 1884 KEYWORDS
|
} |
} |
foreach (@$string) { |
foreach (@$string) { |
my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/; |
my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/; |
if ($part ne ($partid.'_'.$respid)) { next; } |
if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; } |
my ($ressub,$subval) = split(/:/,$_,2); |
my ($ressub,$subval) = split(/:/,$_,2); |
# Similarity check |
# Similarity check |
my $similar=''; |
my $similar=''; |
Line 1903 KEYWORDS
|
Line 1904 KEYWORDS
|
my $order=&get_order($partid,$respid,$symb,$uname,$udom); |
my $order=&get_order($partid,$respid,$symb,$uname,$udom); |
if ($env{'form.lastSub'} eq 'lastonly' || |
if ($env{'form.lastSub'} eq 'lastonly' || |
($env{'form.lastSub'} eq 'hdgrade' && |
($env{'form.lastSub'} eq 'hdgrade' && |
$$handgrade{$part} eq 'yes')) { |
$$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { |
my $display_part=&get_display_part($partid,$symb); |
my $display_part=&get_display_part($partid,$symb); |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '. |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '. |
$display_part.' <font color="#999999">( ID '.$respid. |
$display_part.' <font color="#999999">( ID '.$respid. |
Line 1993 KEYWORDS
|
Line 1994 KEYWORDS
|
my %seen = (); |
my %seen = (); |
my @partlist; |
my @partlist; |
my @gradePartRespid; |
my @gradePartRespid; |
for my $part_resp (sort(keys(%$handgrade))) { |
my @part_response_id = &flatten_responseType($responseType); |
my ($partid,$respid) = split(/_/, $part_resp); |
foreach my $part_response_id (@part_response_id) { |
|
my ($partid,$respid) = @{ $part_response_id }; |
|
my $part_resp = join('_',@{ $part_response_id }); |
next if ($seen{$partid} > 0); |
next if ($seen{$partid} > 0); |
$seen{$partid}++; |
$seen{$partid}++; |
next if ($$handgrade{$part_resp} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/); |
next if ($$handgrade{$part_resp} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/); |
Line 2440 sub handback_files {
|
Line 2443 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 = &propath($domain,$stuname).'/userfiles/portfolio'; |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
foreach my $part_resp (sort(keys(%$handgrade))) { |
|
my ($part_id, $resp_id) = split(/_/,$part_resp); |
my @part_response_id = &flatten_responseType($responseType); |
|
foreach my $part_response_id (@part_response_id) { |
|
my ($part_id,$resp_id) = @{ $part_response_id }; |
|
my $part_resp = join('_',@{ $part_response_id }); |
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) { |
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) { |
# if multiple files are uploaded names will be 'returndoc2','returndoc3' |
# if multiple files are uploaded names will be 'returndoc2','returndoc3' |
my $file_counter = 1; |
my $file_counter = 1; |
Line 2874 sub viewgrades {
|
Line 2880 sub viewgrades {
|
'<table border=0><tr bgcolor="#ffffdd"><td>'; |
'<table border=0><tr bgcolor="#ffffdd"><td>'; |
#radio buttons/text box for assigning points for a section or class. |
#radio buttons/text box for assigning points for a section or class. |
#handles different parts of a problem |
#handles different parts of a problem |
my ($partlist,$handgrade) = &response_type($symb); |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
my %weight = (); |
my %weight = (); |
my $ctsparts = 0; |
my $ctsparts = 0; |
$result.='<table border="0">'; |
$result.='<table border="0">'; |
my %seen = (); |
my %seen = (); |
for (sort keys(%$handgrade)) { |
my @part_response_id = &flatten_responseType($responseType); |
my ($partid,$respid) = split (/_/,$_,2); |
foreach my $part_response_id (@part_response_id) { |
|
my ($partid,$respid) = @{ $part_response_id }; |
|
my $part_resp = join('_',@{ $part_response_id }); |
next if $seen{$partid}; |
next if $seen{$partid}; |
$seen{$partid}++; |
$seen{$partid}++; |
my $handgrade=$$handgrade{$_}; |
my $handgrade=$$handgrade{$part_resp}; |
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); |
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); |
$weight{$partid} = $wgt eq '' ? '1' : $wgt; |
$weight{$partid} = $wgt eq '' ? '1' : $wgt; |
|
|
Line 4772 sub reset_skipping_status {
|
Line 4780 sub reset_skipping_status {
|
&scantron_putfile(undef,$scan_data); |
&scantron_putfile(undef,$scan_data); |
} |
} |
|
|
sub allow_skipping { |
sub start_skipping { |
my ($scan_data,$i)=@_; |
my ($scan_data,$i)=@_; |
my %remembered=split(':',&scan_data($scan_data,'remember_skipping')); |
my %remembered=split(':',&scan_data($scan_data,'remember_skipping')); |
delete($remembered{$i}); |
if ($env{'form.scantron_options_redo'} =~ /^redo_/) { |
|
$remembered{$i}=2; |
|
} else { |
|
$remembered{$i}=1; |
|
} |
&scan_data($scan_data,'remember_skipping',join(':',%remembered)); |
&scan_data($scan_data,'remember_skipping',join(':',%remembered)); |
} |
} |
|
|
sub should_be_skipped { |
sub should_be_skipped { |
my ($scan_data,$i)=@_; |
my ($scanlines,$scan_data,$i)=@_; |
if ($env{'form.scantron_options_redo'} !~ /^redo_/) { |
if ($env{'form.scantron_options_redo'} !~ /^redo_/) { |
# not redoing old skips |
# not redoing old skips |
|
if ($scanlines->{'skipped'}[$i]) { return 1; } |
return 0; |
return 0; |
} |
} |
my %remembered=split(':',&scan_data($scan_data,'remember_skipping')); |
my %remembered=split(':',&scan_data($scan_data,'remember_skipping')); |
if (exists($remembered{$i})) { return 0; } |
|
|
if (exists($remembered{$i}) && $remembered{$i} != 2 ) { |
|
return 0; |
|
} |
return 1; |
return 1; |
} |
} |
|
|
Line 4798 sub remember_current_skipped {
|
Line 4814 sub remember_current_skipped {
|
$to_remember{$i}=1; |
$to_remember{$i}=1; |
} |
} |
} |
} |
|
|
&scan_data($scan_data,'remember_skipping',join(':',%to_remember)); |
&scan_data($scan_data,'remember_skipping',join(':',%to_remember)); |
&scantron_putfile(undef,$scan_data); |
&scantron_putfile(undef,$scan_data); |
} |
} |
Line 4813 sub scantron_warning_screen {
|
Line 4830 sub scantron_warning_screen {
|
my ($button_text)=@_; |
my ($button_text)=@_; |
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'}); |
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'}); |
my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); |
my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); |
my $CODElist="a"; |
my $CODElist; |
if ($scantron_config{'CODElocation'} && |
if ($scantron_config{'CODElocation'} && |
$scantron_config{'CODEstart'} && |
$scantron_config{'CODEstart'} && |
$scantron_config{'CODElength'}) { |
$scantron_config{'CODElength'}) { |
$CODElist=$env{'form.scantron_CODElist'}; |
$CODElist=$env{'form.scantron_CODElist'}; |
if ($CODElist eq '') { $CODElist='<font color="red">None</font>'; } |
if ($env{'form.scantron_CODElist'} eq '') { $CODElist='<font color="red">None</font>'; } |
$CODElist= |
$CODElist= |
'<tr><td><b>List of CODES to validate against:</b></td><td><tt>'. |
'<tr><td><b>List of CODES to validate against:</b></td><td><tt>'. |
$CODElist.'</tt></td></tr>'; |
$env{'form.scantron_CODElist'}.'</tt></td></tr>'; |
} |
} |
return (<<STUFF); |
return (<<STUFF); |
<p> |
<p> |
Line 4903 sub scantron_validate_file {
|
Line 4920 sub scantron_validate_file {
|
} |
} |
if ($env{'form.scantron_options_redo'} eq 'redo_skipped') { |
if ($env{'form.scantron_options_redo'} eq 'redo_skipped') { |
&remember_current_skipped(); |
&remember_current_skipped(); |
&scantron_remove_file('skipped'); |
|
$env{'form.scantron_options_redo'}='redo_skipped_ready'; |
$env{'form.scantron_options_redo'}='redo_skipped_ready'; |
} |
} |
|
|
Line 5073 sub scantron_putfile {
|
Line 5089 sub scantron_putfile {
|
|
|
sub scantron_get_line { |
sub scantron_get_line { |
my ($scanlines,$scan_data,$i)=@_; |
my ($scanlines,$scan_data,$i)=@_; |
if (&should_be_skipped($scan_data,$i)) { return undef; } |
if (&should_be_skipped($scanlines,$scan_data,$i)) { return undef; } |
if ($scanlines->{'skipped'}[$i]) { return undef; } |
#if ($scanlines->{'skipped'}[$i]) { return undef; } |
if ($scanlines->{'corrected'}[$i]) {return $scanlines->{'corrected'}[$i];} |
if ($scanlines->{'corrected'}[$i]) {return $scanlines->{'corrected'}[$i];} |
return $scanlines->{'orig'}[$i]; |
return $scanlines->{'orig'}[$i]; |
} |
} |
Line 5094 sub scantron_put_line {
|
Line 5110 sub scantron_put_line {
|
my ($scanlines,$scan_data,$i,$newline,$skip)=@_; |
my ($scanlines,$scan_data,$i,$newline,$skip)=@_; |
if ($skip) { |
if ($skip) { |
$scanlines->{'skipped'}[$i]=$newline; |
$scanlines->{'skipped'}[$i]=$newline; |
&allow_skipping($scan_data,$i); |
&start_skipping($scan_data,$i); |
return; |
return; |
} |
} |
$scanlines->{'corrected'}[$i]=$newline; |
$scanlines->{'corrected'}[$i]=$newline; |
} |
} |
|
|
|
sub scantron_clear_skip { |
|
my ($scanlines,$scan_data,$i)=@_; |
|
if (exists($scanlines->{'skipped'}[$i])) { |
|
undef($scanlines->{'skipped'}[$i]); |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
sub scantron_filter_not_exam { |
sub scantron_filter_not_exam { |
my ($curres)=@_; |
my ($curres)=@_; |
|
|
Line 5586 SCANTRONFORM
|
Line 5611 SCANTRONFORM
|
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonnet::appenv(%$scan_record); |
&Apache::lonnet::appenv(%$scan_record); |
|
|
|
if (&scantron_clear_skip($scanlines,$scan_data,$i)) { |
|
&scantron_putfile($scanlines,$scan_data); |
|
} |
|
|
my $i=0; |
my $i=0; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |