# The LearningOnline Network with CAPA # (Publication Handler # # $Id: lonstudentassessment.pm,v 1.1 2002/07/24 14:52:32 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # (Navigate problems for statistical reports # YEAR=2001 # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei # YEAR=2002 # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei # 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei # ### package Apache::lonstudentassessment; use strict; use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; sub BuildStudentAssessmentPage { my ($cacheDB, $students, $courseID, $c)=@_; my %cache; my $Ptr = ''; $Ptr .= ''; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { return 'Unable to tie database.'; } my $selectedName = $cache{'StudentAssessmentStudent'}; for(my $index=0; ($selectedName ne 'All Students') && ($index<(scalar @$students)); $index++) { my $fullname = $cache{$students->[$index].':fullname'}; if($fullname eq $selectedName) { if($cache{'StudentAssessmentMove'} eq 'next') { if($index == ((scalar @$students) - 1)) { $selectedName = $students->[0]; } else { $selectedName = $students->[$index+1]; } } elsif($cache{'StudentAssessmentMove'} eq 'previous') { if($index == 0) { $selectedName = $students->[-1]; } else { $selectedName = $students->[$index-1]; } } else { $selectedName = $students->[$index]; } last; } } $Ptr .= ''."\n"; $Ptr .= ''."\n"; $Ptr .= ''."\n"; $Ptr .= ''."\n"; untie(%cache); $Ptr .= '
Select Map'; $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'StudentAssessment'); $Ptr .= '
Select Student'."\n"; $Ptr .= &Apache::lonhtmlcommon::StudentOptions(\%cache, $students, $selectedName, 'StudentAssessment'); $Ptr .= '
'; $Ptr .= 'aborted()); if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, $_); if(!$c->aborted()) { $Ptr .= &StudentReport(\%cache, $_); } untie(%cache); } } if($selected == 0) { $Ptr .= '

WARNING: '; $Ptr .= 'Please select a student

'; } return $Ptr; } #---- Student Assessment Web Page -------------------------------------------- # ------ Create different Student Report sub StudentReport { my ($cache, $name)=@_; my $Str = ''; if($cache->{$name.':error'} =~ /course/) { my ($username)=split(':',$name); $Str .= 'No course data for student '; $Str .= ''.$username.'.
'; return $Str; } $Str .= ""; $Str .= ''."\n"; my $codes; my $attempts; foreach my $sequence (split(':', $cache->{'orderedSequences'})) { if($cache->{'StudentAssessmentMap'} ne 'All Maps' && $cache->{'StudentAssessmentMap'} ne $cache->{$sequence.':title'}) { next; } $Str .= ''; $Str .= ''; $codes = ''; $attempts = ''; foreach my $problemID (split(':', $cache->{$sequence.':problems'})) { my $problem = $cache->{$problemID.':problem'}; my $LatestVersion = $cache->{$name.':version:'.$problem}; # Output dashes for all the parts of this problem if there # is no version information about the current problem. if(!$LatestVersion) { foreach my $part (split(/\:/,$cache->{$sequence.':'. $problemID. ':parts'})) { $codes .= "-,"; $attempts .= "0,"; } next; } my %partData=undef; # Initialize part data, display skips correctly # Skip refers to when a student made no submissions on that # part/problem. foreach my $part (split(/\:/,$cache->{$sequence.':'. $problemID. ':parts'})) { $partData{$part.':tries'}=0; $partData{$part.':code'}='-'; } # Looping through all the versions of each part, starting with the # oldest version. Basically, it gets the most recent # set of grade data for each part. for(my $Version=1; $Version<=$LatestVersion; $Version++) { foreach my $part (split(/\:/,$cache->{$sequence.':'. $problemID. ':parts'})) { if(!defined($cache->{$name.":$Version:$problem". ":resource.$part.solved"})) { # No grade for this submission, so skip next; } my $tries=0; my $code='U'; $tries = $cache->{$name.":$Version:$problem". ":resource.$part.tries"}; $partData{$part.':tries'}=($tries) ? $tries : 0; my $val = $cache->{$name.":$Version:$problem". ":resource.$part.solved"}; if ($val eq 'correct_by_student') {$code = 'Y';} elsif ($val eq 'correct_by_override') {$code = 'y';} elsif ($val eq 'incorrect_attempted') {$code = 'N';} elsif ($val eq 'incorrect_by_override'){$code = 'N';} elsif ($val eq 'excused') {$code = 'x';} $partData{$part.':code'}=$code; } } # Loop through all the parts for the current problem in the # correct order and prepare the output foreach (split(/\:/,$cache->{$sequence.':'.$problemID. ':parts'})) { $codes .= $partData{$_.':code'}.','; $attempts .= $partData{$_.':tries'}.','; } } $codes =~ s/,$//; $attempts =~ s/,$//; $Str .= ''; $Str .= ''; $Str .= ''."\n"; } $Str .= '
\# Set Title Results Tries
'.$sequence.''.$cache->{$sequence.':title'}.''.$codes.''.$attempts.'
'."\n"; return $Str; } #---- END Student Assessment Web Page ---------------------------------------- 1; __END__