version 1.48, 2003/05/21 14:43:01
|
version 1.53, 2003/06/07 14:45:41
|
Line 85 my $Statistics;
|
Line 85 my $Statistics;
|
|
|
=item $show 'all', 'totals', or 'scores' determines how much data is output |
=item $show 'all', 'totals', or 'scores' determines how much data is output |
|
|
|
=item $single_student_mode evaluates to true if we are showing only one |
|
student. |
|
|
=cut |
=cut |
|
|
####################################################### |
####################################################### |
Line 92 my $Statistics;
|
Line 95 my $Statistics;
|
my $show_links; |
my $show_links; |
my $output_mode; |
my $output_mode; |
my $show; |
my $show; |
|
my $single_student_mode; |
|
|
####################################################### |
####################################################### |
####################################################### |
####################################################### |
Line 127 Inputs:
|
Line 131 Inputs:
|
sub BuildStudentAssessmentPage { |
sub BuildStudentAssessmentPage { |
my ($r,$c)=@_; |
my ($r,$c)=@_; |
undef($Statistics); |
undef($Statistics); |
|
$single_student_mode = 1 if ($ENV{'form.SelectedStudent'}); |
# |
# |
# Print out the HTML headers for the interface |
# Print out the HTML headers for the interface |
# This also parses the output mode selector |
# This also parses the output mode selector |
# This step must always be done. |
# This step must always be done. |
$r->print(&CreateInterface()); |
$r->print(&CreateInterface()); |
$r->print('<input type="hidden" name="notfirstrun" value="true" />'); |
$r->print('<input type="hidden" name="notfirstrun" value="true" />'); |
|
$r->print('<input type="hidden" name="sort" value="'. |
|
$ENV{'form.sort'}.'" />'); |
$r->rflush(); |
$r->rflush(); |
if (! exists($ENV{'form.notfirstrun'})) { |
if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) { |
$r->print(<<ENDMSG); |
$r->print(<<ENDMSG); |
<p> |
<p> |
<font size="+2"> |
<font size="+2"> |
Line 168 ENDMSG
|
Line 175 ENDMSG
|
# |
# |
if($c->aborted()) { return ; } |
if($c->aborted()) { return ; } |
# |
# |
|
# Determine which students we want to look at |
|
my @Students; |
|
if ($single_student_mode) { |
|
@Students = (&Apache::lonstatistics::current_student()); |
|
$r->print(&next_and_previous_buttons()); |
|
$r->rflush(); |
|
} else { |
|
@Students = @Apache::lonstatistics::Students; |
|
} |
|
# |
# Call the initialize routine selected above |
# Call the initialize routine selected above |
$initialize->($r); |
$initialize->($r); |
foreach my $student (@Apache::lonstatistics::Students) { |
foreach my $student (@Students) { |
if($c->aborted()) { |
if($c->aborted()) { |
$finish->($r); |
$finish->($r); |
return ; |
return ; |
Line 186 ENDMSG
|
Line 203 ENDMSG
|
|
|
####################################################### |
####################################################### |
####################################################### |
####################################################### |
|
sub next_and_previous_buttons { |
|
my $Str = ''; |
|
$Str .= '<input type="hidden" name="SelectedStudent" value="'. |
|
$ENV{'form.SelectedStudent'}.'" />'; |
|
# |
|
# Build the previous student link |
|
my $previous = &Apache::lonstatistics::previous_student(); |
|
my $previousbutton = ''; |
|
if (defined($previous)) { |
|
my $sname = $previous->{'username'}.':'.$previous->{'domain'}; |
|
$previousbutton .= '<input type="button" value="'. |
|
'Previous Student ('. |
|
$previous->{'username'}.'@'.$previous->{'domain'}.')'. |
|
'" onclick="document.Statistics.SelectedStudent.value='. |
|
"'".$sname."'".';'. |
|
'document.Statistics.submit();" />'; |
|
} else { |
|
$previousbutton .= '<input type="button" value="'. |
|
'Previous student (none)'.'" />'; |
|
} |
|
# |
|
# Build the next student link |
|
my $next = &Apache::lonstatistics::next_student(); |
|
my $nextbutton = ''; |
|
if (defined($next)) { |
|
my $sname = $next->{'username'}.':'.$next->{'domain'}; |
|
$nextbutton .= '<input type="button" value="'. |
|
'Next Student ('. |
|
$next->{'username'}.'@'.$next->{'domain'}.')'. |
|
'" onclick="document.Statistics.SelectedStudent.value='. |
|
"'".$sname."'".';'. |
|
'document.Statistics.submit();" />'; |
|
} else { |
|
$nextbutton .= '<input type="button" value="'. |
|
'Next student (none)'.'" />'; |
|
} |
|
# |
|
# Build the 'all students' button |
|
my $all = ''; |
|
$all .= '<input type="button" value="All Students" '. |
|
'" onclick="document.Statistics.SelectedStudent.value='. |
|
"''".';'.'document.Statistics.submit();" />'; |
|
$Str .= $previousbutton.(' 'x5).$all.(' 'x5).$nextbutton; |
|
return $Str; |
|
} |
|
|
|
####################################################### |
|
####################################################### |
|
|
sub get_student_fields_to_show { |
sub get_student_fields_to_show { |
my @to_show = @Apache::lonstatistics::SelectedStudentData; |
my @to_show = @Apache::lonstatistics::SelectedStudentData; |
Line 396 sub CreateAndParseOutputSelector {
|
Line 461 sub CreateAndParseOutputSelector {
|
my $elementname = 'chartoutputmode'; |
my $elementname = 'chartoutputmode'; |
# |
# |
# Format for output options is 'mode, restrictions'; |
# Format for output options is 'mode, restrictions'; |
my $selected = 'html, with links'; |
my $selected = 'html, without links'; |
if (exists($ENV{'form.'.$elementname})) { |
if (exists($ENV{'form.'.$elementname})) { |
if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { |
if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { |
$selected = $ENV{'form.'.$elementname}->[0]; |
$selected = $ENV{'form.'.$elementname}->[0]; |
Line 538 sub html_outputstudent {
|
Line 603 sub html_outputstudent {
|
my $studentstats; |
my $studentstats; |
my $PerformanceStr = ''; |
my $PerformanceStr = ''; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
my ($performance,$score,$seq_max) = |
my ($performance,$performance_length,$score,$seq_max) = |
&StudentPerformanceOnSequence($student,\%StudentsData, |
&StudentPerformanceOnSequence($student,\%StudentsData, |
$seq,$show_links); |
$seq,$show_links); |
my $ratio = $score.'/'.$seq_max; |
my $ratio = $score.'/'.$seq_max; |
Line 551 sub html_outputstudent {
|
Line 616 sub html_outputstudent {
|
$performance .= ' 'x($seq->{'width'}-length($performance)); |
$performance .= ' 'x($seq->{'width'}-length($performance)); |
} else { |
} else { |
# Pad with extra spaces |
# Pad with extra spaces |
$performance .= ' 'x($seq->{'width'}-$seq_max- |
$performance .= ' 'x($seq->{'width'}-$performance_length- |
length($ratio) |
length($ratio) |
).$ratio; |
).$ratio; |
} |
} |
Line 595 sub html_finish {
|
Line 660 sub html_finish {
|
} else { |
} else { |
$r->print("</pre>\n"); |
$r->print("</pre>\n"); |
} |
} |
$r->print(&StudentAverageTotal()); |
if ($single_student_mode) { |
|
$r->print(&SingleStudentTotal()); |
|
} else { |
|
$r->print(&StudentAverageTotal()); |
|
} |
$r->rflush(); |
$r->rflush(); |
return; |
return; |
} |
} |
Line 638 sub StudentAverageTotal {
|
Line 707 sub StudentAverageTotal {
|
return $Str; |
return $Str; |
} |
} |
|
|
|
sub SingleStudentTotal { |
|
my $student = &Apache::lonstatistics::current_student(); |
|
my $Str = "<h3>Summary table for ".$student->{'fullname'}." ". |
|
$student->{'username'}.'@'.$student->{'domain'}."</h3>\n"; |
|
$Str .= '<table border=2 cellspacing="1">'."\n"; |
|
$Str .= |
|
"<tr><th>Sequence or Folder</th><th>Score</th><th>Maximum</th></tr>\n"; |
|
my $total = 0; |
|
my $total_max = 0; |
|
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
|
my $value = $Statistics->{$seq->{'symb'}}->{'score'}; |
|
my $max = $Statistics->{$seq->{'symb'}}->{'max'}; |
|
$Str .= '<tr><td>'.$seq->{'title'}.'</td>'. |
|
'<td align="right">'.$value.'</td>'. |
|
'<td align="right">'.$max.'</td></tr>'."\n"; |
|
$total += $value; |
|
$total_max +=$max; |
|
} |
|
$Str .= '<tr><td><b>Total</b></td>'. |
|
'<td align="right">'.$total.'</td>'. |
|
'<td align="right">'.$total_max."</td></tr>\n"; |
|
$Str .= "</table>\n"; |
|
return $Str; |
|
} |
|
|
} |
} |
|
|
####################################################### |
####################################################### |
Line 893 sub excel_outputstudent {
|
Line 987 sub excel_outputstudent {
|
# |
# |
# Write out sequence scores and totals data |
# Write out sequence scores and totals data |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
my ($performance,$score,$seq_max) = |
my ($performance,$performance_length,$score,$seq_max) = |
&StudentPerformanceOnSequence($student,\%StudentsData, |
&StudentPerformanceOnSequence($student,\%StudentsData, |
$seq,'no'); |
$seq,'no'); |
if ($show eq 'totals' || $show eq 'scores') { |
if ($show eq 'totals' || $show eq 'scores') { |
Line 995 sub csv_initialize{
|
Line 1089 sub csv_initialize{
|
$Str .= '"",'; # first row empty on the student fields |
$Str .= '"",'; # first row empty on the student fields |
$Str2 .= '"'.&Apache::loncommon::csv_translate($field).'",'; |
$Str2 .= '"'.&Apache::loncommon::csv_translate($field).'",'; |
} elsif ($show eq 'all') { |
} elsif ($show eq 'all') { |
$Str .= '"'.&Apache::loncommon::csv_translate($field).'",'; |
$Str .= '"",'; |
|
$Str2 .= '"'.&Apache::loncommon::csv_translate($field).'",'; |
} |
} |
} |
} |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
Line 1009 sub csv_initialize{
|
Line 1104 sub csv_initialize{
|
} elsif ($show eq 'all') { |
} elsif ($show eq 'all') { |
$Str .= '"'.&Apache::loncommon::csv_translate($seq->{'title'}). |
$Str .= '"'.&Apache::loncommon::csv_translate($seq->{'title'}). |
'",'; |
'",'; |
$Str .= '"",'x($seq->{'num_assess_parts'}-1); |
$Str .= '"",'x($seq->{'num_assess_parts'}-1+2); |
$Str .= '"score","total possible",'; |
foreach my $res (@{$seq->{'contents'}}) { |
|
foreach my $part (@{$res->{'parts'}}) { |
|
$Str2 .= '"'.&Apache::loncommon::csv_translate($res->{'title'}.', Part '.$part).'",'; |
|
} |
|
} |
|
$Str2 .= '"score","total possible",'; |
} |
} |
} |
} |
chop($Str); |
chop($Str); |
Line 1053 sub csv_outputstudent {
|
Line 1153 sub csv_outputstudent {
|
# |
# |
# Output performance data |
# Output performance data |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { |
my ($performance,$score,$seq_max) = |
my ($performance,$performance_length,$score,$seq_max) = |
&StudentPerformanceOnSequence($student,\%StudentsData, |
&StudentPerformanceOnSequence($student,\%StudentsData, |
$seq,'no'); |
$seq,'no'); |
if ($show eq 'scores') { |
if ($show eq 'scores') { |
Line 1125 sub StudentPerformanceOnSequence {
|
Line 1225 sub StudentPerformanceOnSequence {
|
$links = 'no' if (! defined($links)); |
$links = 'no' if (! defined($links)); |
my $Str = ''; |
my $Str = ''; |
my ($sum,$max) = (0,0); |
my ($sum,$max) = (0,0); |
|
my $performance_length = 0; |
foreach my $resource (@{$seq->{'contents'}}) { |
foreach my $resource (@{$seq->{'contents'}}) { |
next if ($resource->{'type'} ne 'assessment'); |
next if ($resource->{'type'} ne 'assessment'); |
my $resource_data = $studentdata->{$resource->{'symb'}}; |
my $resource_data = $studentdata->{$resource->{'symb'}}; |
my $value = ''; |
my $value = ''; |
foreach my $partnum (@{$resource->{'parts'}}) { |
foreach my $partnum (@{$resource->{'parts'}}) { |
$max++; |
$max++; |
|
$performance_length++; |
my $symbol = ' '; # default to space |
my $symbol = ' '; # default to space |
# |
# |
if (exists($resource_data->{'resource.'.$partnum.'.solved'})) { |
if (exists($resource_data->{'resource.'.$partnum.'.solved'})) { |
Line 1172 sub StudentPerformanceOnSequence {
|
Line 1274 sub StudentPerformanceOnSequence {
|
$symbol = ' '; |
$symbol = ' '; |
} |
} |
} |
} |
|
# if ($symbol ne ' ') { |
|
# $attempted_sum++; |
|
# } |
# |
# |
if ( ($links eq 'yes' && $symbol ne ' ') || |
if ( ($links eq 'yes' && $symbol ne ' ') || |
($links eq 'all')) { |
($links eq 'all')) { |
|
if (length($symbol) > 1) { |
|
&Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1'); |
|
} |
$symbol = '<a href="/adm/grades'. |
$symbol = '<a href="/adm/grades'. |
'?symb='.&Apache::lonnet::escape($resource->{'symb'}). |
'?symb='.&Apache::lonnet::escape($resource->{'symb'}). |
'&student='.$student->{'username'}. |
'&student='.$student->{'username'}. |
Line 1185 sub StudentPerformanceOnSequence {
|
Line 1293 sub StudentPerformanceOnSequence {
|
} |
} |
$Str .= $value; |
$Str .= $value; |
} |
} |
return ($Str,$sum,$max); |
if ($seq->{'randompick'}) { |
|
$max = $seq->{'randompick'}; |
|
} |
|
return ($Str,$performance_length,$sum,$max); |
} |
} |
|
|
####################################################### |
####################################################### |