--- loncom/interface/statistics/lonstathelpers.pm 2004/11/08 15:14:52 1.30 +++ loncom/interface/statistics/lonstathelpers.pm 2005/02/23 02:03:42 1.38 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.30 2004/11/08 15:14:52 matthew Exp $ +# $Id: lonstathelpers.pm,v 1.38 2005/02/23 02:03:42 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,7 +86,7 @@ sub render_resource { ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); $base = "http://".$ENV{'SERVER_NAME'}.$base; my $rendered_problem = - &Apache::lonnet::ssi_body($resource->{'src'}); + &Apache::lonnet::ssi_body($resource->{'src'}.'?symb='.&Apache::lonnet::escape($resource->{'symb'})); $rendered_problem =~ s/<\s*form\s*/)|<\/nop>|g; return '\n"; $rb_count++; } @@ -280,16 +282,6 @@ END return $Str; } -sub get_title { - my ($title,$src) = @_; - if ($title eq '') { - ($title) = ($src =~ m|/([^/]+)$|); - } else { - $title =~ s/\:/:/g; - } - return $title; -} - sub new_accumulator { my ($title,$src,$symb,$seq_id,$inputname) = @_; my $target; @@ -308,7 +300,8 @@ sub new_accumulator { 'value="'.&Apache::lonnet::escape($res->symb).'" />'. ' '.$res->compTitle.''. (' 'x2).'view'. + 'href="'.$res->src.'?symb='. + &Apache::lonnet::escape($res->{'symb'}).'">view'. ''.$/; } else { if (defined($target)) { @@ -555,6 +548,7 @@ Returns: nothing ##################################################### sub GetStudentAnswers { my ($r,$problem,$Students,$formname,$inputname) = @_; + my %answers; my $status_type; if (defined($formname)) { $status_type = 'inline'; @@ -582,6 +576,7 @@ sub GetStudentAnswers { ($resource,$sname,$sdom,$partid,$respid); &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, &mt('last student')); + $answers{$answer}++; $student->{'answer'} = $answer; } &Apache::lonstathelpers::write_analysis_cache(); @@ -589,7 +584,7 @@ sub GetStudentAnswers { $r->rflush(); # close progress window &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); - return; + return \%answers; } ##################################################### @@ -1130,7 +1125,7 @@ sub get_problem_data { $Partdata{$part}->{'_Foils'}->{$foil}->{'_Concept'}= $concept; } - } elsif ($key =~ /^(incorrect|answer|ans_low|ans_high|str_type)$/) { + } elsif ($key =~ /^(unit|incorrect|answer|ans_low|ans_high|str_type)$/) { $Partdata{$part}->{$key}=$value; } } else { @@ -1336,9 +1331,7 @@ sub manage_caches { if (defined($update_message)) { $r->print($update_message); } - &Apache::lonstatistics::Gather_Full_Student_Data($r,$formname, - $inputname); - + &gather_full_student_data($r,$formname,$inputname); } # my @Buttons = @@ -1360,8 +1353,90 @@ sub manage_caches { return @Buttons; } +sub gather_full_student_data { + my ($r,$formname,$inputname) = @_; + my $status_type; + if (defined($formname)) { + $status_type = 'inline'; + } else { + $status_type = 'popup'; + } + my $c = $r->connection(); + # + &Apache::loncoursedata::clear_internal_caches(); + # + my @Students = @Apache::lonstatistics::Students; + # + # Open the progress window + my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin + ($r,&mt('Student Data Compilation Status'), + &mt('Student Data Compilation Progress'), scalar(@Students), + $status_type,undef,$formname,$inputname); + # + while (my $student = shift @Students) { + return if ($c->aborted()); + my $status = &Apache::loncoursedata::ensure_current_full_data + ($student->{'username'},$student->{'domain'}, + $ENV{'request.course.id'}); + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, + &mt('last student')); + } + &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); + $r->rflush(); + return; +} + +#################################################### +#################################################### + +=pod + +=item &submission_report_form + +Input: The originating reportSelected value for the current stats page. +Output: Scalar containing HTML with needed form elements and a link to +the student submission reports page. + +=cut +#################################################### +#################################################### +sub submission_report_form { + my ($original_report) = @_; + # Note: In the link below we change the reportSelected value. If + # the user hits the 'back' button on the browser after getting their + # student submissions report, this value may still be around. So we + # output a script block to set it properly. If the $original_report + # value is unset, you are just asking for trouble. + if (! defined($original_report)) { + &Apache::lonnet::logthis + ('someone called lonstathelpers::submission_report_form without '. + ' enough input.'); + } + my $html = $/. + ''. + ''. + ''. + ''; + my $output_selector = $/.''.$/; + my $link = ''; + $html.= &mt('View data as [_1] [_2]go[_3]',$output_selector, + $link,'').$/; + return $html +} #################################################### ####################################################
'. @@ -149,8 +149,10 @@ sub ProblemSelector { if (scalar(@{$partdata->{'ResponseIds'}}) > 1) { $seq_str .= &mt('response').' '.$respid; } + my $link = $res->{'src'}.'?symb='. + &Apache::lonnet::escape($res->{'symb'}); $seq_str .= (' 'x2). - qq{view}; + qq{view}; $seq_str .= "