--- loncom/interface/loncoursedata.pm 2002/08/13 00:37:18 1.13 +++ loncom/interface/loncoursedata.pm 2002/08/15 16:11:34 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: loncoursedata.pm,v 1.13 2002/08/13 00:37:18 stredwic Exp $ +# $Id: loncoursedata.pm,v 1.19 2002/08/15 16:11:34 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -201,6 +201,7 @@ sub DownloadCourseInformation { if(!defined($WhatIWant)) { $WhatIWant = '.'; } + $WhatIWant = '.'; %courseData=&Apache::lonnet::dump($courseID, $domain, $name, $WhatIWant); $courseData{'UpToDate'} = 'false'; $courseData{'lastDownloadTime'}=time; @@ -396,11 +397,12 @@ sub ProcessTopResourceMap { $beenHere{'o:'.$partId.$currentResourceID}++; if(defined($cache->{'OptionResponses'})) { $cache->{'OptionResponses'}.= ':::'. - $currentResourceID.':'. + $currentSequence.':'.$currentResourceID.':'. $partId.':'.$responseId; } else { - $cache->{'OptionResponses'}= $currentResourceID. - ':'.$partId.':'.$responseId; + $cache->{'OptionResponses'}= $currentSequence.':'. + $currentResourceID.':'. + $partId.':'.$responseId; } } } @@ -680,6 +682,7 @@ sub ExtractStudentData { my $totalProblems = 0; my $problemsSolved = 0; my $numberOfParts = 0; + my $totalAwarded = 0; foreach my $sequence (split(':', $data->{'orderedSequences'})) { foreach my $problemID (split(':', $data->{$sequence.':problems'})) { my $problem = $data->{$problemID.':problem'}; @@ -691,6 +694,9 @@ sub ExtractStudentData { foreach my $part (split(/\:/,$data->{$sequence.':'. $problemID. ':parts'})) { + $output->{$name.':'.$problemID.':'.$part.':tries'} = 0; + $output->{$name.':'.$problemID.':'.$part.':awarded'} = 0; + $output->{$name.':'.$problemID.':'.$part.':code'} = ' '; $totalProblems++; } $output->{$name.':'.$problemID.':NoVersion'} = 'true'; @@ -791,6 +797,7 @@ sub ExtractStudentData { $partData{$part.':code'}; $output->{$name.':'.$problemID.':'.$part.':awarded'} = $partData{$part.':awarded'}; + $totalAwarded += $partData{$part.':awarded'}; $output->{$name.':'.$problemID.':'.$part.':timestamp'} = $partData{$part.':timestamp'}; foreach my $response (split(':', $data->{$sequence.':'. @@ -813,6 +820,7 @@ sub ExtractStudentData { $output->{$name.':problemsSolved'} = $problemsSolved; $output->{$name.':totalProblems'} = $totalProblems; + $output->{$name.':totalAwarded'} = $totalAwarded; return; } @@ -1006,9 +1014,10 @@ sub DownloadStudentCourseData { my $studentCount = scalar(@$students); my %cache; + my $WhatIWant; - $WhatIWant = '(^version:(\w|\/|\.|-)+?$|'; - $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.'; + $WhatIWant = '(^version:.+?$|'; + $WhatIWant .= '^\d+:.+?:(resource\.\d+\.'; $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$'; $WhatIWant .= '|timestamp)'; $WhatIWant .= ')'; @@ -1016,11 +1025,14 @@ sub DownloadStudentCourseData { if($status eq 'true') { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + + my $displayString; + my $count=0; foreach (@$students) { if($c->aborted()) { return 'Aborted'; } if($status eq 'true') { + $count++; my $displayString = $count.'/'.$studentCount.': '.$_; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1055,7 +1067,6 @@ sub DownloadStudentCourseData { next; } } - $count++; } if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); } @@ -1068,9 +1079,10 @@ sub DownloadStudentCourseDataSeparate { my $title = 'LON-CAPA Statistics'; my $heading = 'Download Course Data'; +# my $WhatIWant = '.'; my $WhatIWant; - $WhatIWant = '(^version:(\w|\/|\.|-)+?$|'; - $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.'; + $WhatIWant = '(^version:.+?$|'; + $WhatIWant .= '^\d+:.+?:(resource\.\d+\.'; $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$'; $WhatIWant .= '|timestamp)'; $WhatIWant .= ')'; @@ -1078,24 +1090,21 @@ sub DownloadStudentCourseDataSeparate { &CheckForResidualDownload($courseID, $cacheDB, $students, $c); my %cache; - my %downloadData; - unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_NEWDB(),0640)) { - return 'Failed to tie temporary download hash.'; - } my $studentCount = scalar(@$students); if($status eq 'true') { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + my $count=0; + my $displayString=''; foreach (@$students) { if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } if($status eq 'true') { - my $displayString = $count.'/'.$studentCount.': '.$_; + $count++; + $displayString = $count.'/'.$studentCount.': '.$_; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1107,7 +1116,6 @@ sub DownloadStudentCourseDataSeparate { } if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } @@ -1116,6 +1124,11 @@ sub DownloadStudentCourseDataSeparate { my $courseData = &DownloadCourseInformation($_, $courseID, $downloadTime, $WhatIWant); + my %downloadData; + unless(tie(%downloadData,'GDBM_File',$residualFile, + &GDBM_WRCREAT(),0640)) { + return 'Failed to tie temporary download hash.'; + } foreach my $key (keys(%$courseData)) { $downloadData{$key} = $courseData->{$key}; if($key =~ /^(con_lost|error|no_such_host)/i) { @@ -1129,8 +1142,8 @@ sub DownloadStudentCourseDataSeparate { } $downloadData{$_.':error'} = 'No course data for '.$_; } + untie(%downloadData); } - $count++; } if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); } @@ -1143,21 +1156,24 @@ sub CheckForResidualDownload { my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db'; if(!-e $residualFile) { - return; + return 'OK'; } my %downloadData; my %cache; - unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640) && - tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { - return; + unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640)) { + return 'Can not tie database for check for residual download: tempDB'; + } + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { + untie(%downloadData); + return 'Can not tie database for check for residual download: cacheDB'; } - my @dataKeys=keys(%downloadData); my @students=(); my %checkStudent; - foreach(@dataKeys) { - my @temp = split(':', $_); + my $key; + while(($key, undef) = each %downloadData) { + my @temp = split(':', $key); my $student = $temp[0].':'.$temp[1]; if(!defined($checkStudent{$student})) { $checkStudent{$student}++; @@ -1172,12 +1188,12 @@ sub CheckForResidualDownload { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + my c$ount=1; foreach my $name (@students) { last if($c->aborted()); if($status eq 'true') { - my $displayString = $count.'/'.$studentCount.': '.$_; + my $displayString = $count.'/'.$studentCount.': '.$name; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1186,11 +1202,6 @@ sub CheckForResidualDownload { } else { &ProcessStudentData(\%cache, \%downloadData, $name); } - foreach (@dataKeys) { - if(/^$name/) { - delete $downloadData{$_}; - } - } $count++; }