--- loncom/interface/statistics/lonstathelpers.pm 2005/02/28 22:37:28 1.41 +++ loncom/interface/statistics/lonstathelpers.pm 2005/11/12 03:58:55 1.51 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.41 2005/02/28 22:37:28 matthew Exp $ +# $Id: lonstathelpers.pm,v 1.51 2005/11/12 03:58:55 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,7 +49,7 @@ routines that are needed across multiple package Apache::lonstathelpers; use strict; -use Apache::lonnet(); +use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); @@ -68,8 +68,7 @@ use Storable qw(freeze thaw); =item &render_resource($resource) -Input: a resource generated from -&Apache::loncoursedata::get_sequence_assessment_data(). +Input: a navmaps resource Retunrs: a scalar containing html for a rendering of the problem within a table. @@ -82,9 +81,8 @@ sub render_resource { my ($resource) = @_; ## ## Render the problem - my $base; - ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); - $base = "http://".$ENV{'SERVER_NAME'}.$base; + my ($base) = ($resource->src =~ m|^(.*/)[^/]*$|); + $base="http://".$ENV{'SERVER_NAME'}.$base; my ($src,$symb)=($resource->src,&Apache::lonnet::escape($resource->symb)); my $rendered_problem = &Apache::lonnet::ssi_body($src.'?symb='.$symb); $rendered_problem =~ s/<\s*form\s*/$respid, resptype=>$resptype}); my $checked = ''; - if ($ENV{'form.problemchoice'} eq $value) { + if ($env{'form.problemchoice'} eq $value) { $checked = 'checked '; } my $title = $res->compTitle; @@ -181,8 +179,15 @@ sub problem_selector { } } if ($seq_str ne '') { - $Str .= ' '.$seq->compTitle.''. + $Str .= ' '. + ''.$seq->compTitle.''. "\n".$seq_str; + if (defined($sequence_addendum)) { + $Str .= ''. + (' 'x2). + ''.$sequence_addendum.''. + "\n"; + } } } $Str .= "\n"; @@ -216,7 +221,7 @@ and their contents. A checkbox is provi #################################################### sub MultipleProblemSelector { my ($navmap,$inputname,$formname)=@_; - my $cid = $ENV{'request.course.id'}; + my $cid = $env{'request.course.id'}; my $Str; # Massage the input as needed. if (! defined($navmap)) { @@ -257,7 +262,7 @@ END my $iterator = $navmap->getIterator(undef, undef, undef, 1); my $sequence_string; my $seq_id = 0; - my @Accumulator = (&new_accumulator($ENV{'course.'.$cid.'.description'}, + my @Accumulator = (&new_accumulator($env{'course.'.$cid.'.description'}, '', '', $seq_id++, @@ -340,15 +345,10 @@ sub new_accumulator { sub get_selected_symbs { my ($inputfield) = @_; my $field = 'form.'.$inputfield; - my @Symbs; - if (exists($ENV{$field})) { - if (! ref($ENV{$field})) { - @Symbs = (&Apache::lonnet::unescape($ENV{$field})); - } else { - @Symbs = (map {&Apache::lonnet::unescape($_);} @{$ENV{$field}}); - } - } - return @Symbs; + my @symbs = (map { + &Apache::lonnet::unescape($_); + } &Apache::loncommon::get_env_multiple($field)); + return @symbs; } #################################################### @@ -646,7 +646,7 @@ sub analyze_problem_as_student { my $symb = $resource->{'symb'}; my $analysis = &get_from_analysis_cache($sname,$sdom,$symb); if (! defined($analysis)) { - my $courseid = $ENV{'request.course.id'}; + my $courseid = $env{'request.course.id'}; my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze', 'grade_domain' => $sdom, 'grade_username' => $sname, @@ -870,7 +870,7 @@ prior to every analysis lookup. ##################################################### sub ensure_proper_cache { my ($symb) = @_; - my $cid = $ENV{'request.course.id'}; + my $cid = $env{'request.course.id'}; my $new_filename = '/home/httpd/perl/tmp/'. 'problemanalysis_'.$cid.'_analysis_cache.db'; if (! defined($cache_filename) || @@ -1135,8 +1135,8 @@ sub get_problem_data { } } # End of logging code - next if ($key !~ /^$part/); - $key =~ s/^$part\.//; + next if ($key !~ /^\Q$part\E/); + $key =~ s/^\Q$part\E\.//; if (ref($value) eq 'ARRAY') { if ($key eq 'options') { $Partdata{$part}->{'_Options'}=$value; @@ -1259,7 +1259,7 @@ sub limit_by_time_form { } $timecheckbox .= 'OnChange="javascript:toggle_limitby_activity(this.checked);" '; $timecheckbox .= ' />'; - $Str .= ''.&mt('[_1] Limit by time',$timecheckbox).''; + $Str .= ''; $Str .= &mt('Start Time: [_1]',$startdateform).'
'; $Str .= &mt(' End Time: [_1]',$enddateform).'
'; $Str .= ''; @@ -1267,8 +1267,8 @@ sub limit_by_time_form { } sub limit_by_time { - if (exists($ENV{'form.limit_by_time'}) && - $ENV{'form.limit_by_time'} ne '' ) { + if (exists($env{'form.limit_by_time'}) && + $env{'form.limit_by_time'} ne '' ) { return 1; } else { return 0; @@ -1283,43 +1283,6 @@ sub get_time_limits { return ($starttime,$endtime); } - - -#################################################### -#################################################### - -=pod - -=item sections_description - -Inputs: @Sections, an array of sections - -Returns: A text description of the sections selected. - -=cut - -#################################################### -#################################################### -sub sections_description { - my @Sections = @_; - my $sectionstring = ''; - if (scalar(@Sections) > 1) { - if (scalar(@Sections) > 2) { - my $last = pop(@Sections); - $sectionstring = "Sections ".join(', ',@Sections).', and '.$last; - } else { - $sectionstring = "Sections ".join(' and ',@Sections); - } - } else { - if ($Sections[0] eq 'all') { - $sectionstring = "All sections"; - } else { - $sectionstring = "Section ".$Sections[0]; - } - } - return $sectionstring; -} - #################################################### #################################################### @@ -1342,16 +1305,16 @@ sub manage_caches { join(',', map { &Apache::lonnet::escape($_); - } sort(@Apache::lonstatistics::SelectedSections) + } sort(&Apache::lonstatistics::get_selected_sections()) ); my $statuskey = $Apache::lonstatistics::enrollment_status; - if (exists($ENV{'form.ClearCache'}) || - exists($ENV{'form.updatecaches'}) || - (exists($ENV{'form.firstrun'}) && $ENV{'form.firstrun'} ne 'no') || - (exists($ENV{'form.prevsection'}) && - $ENV{'form.prevsection'} ne $sectionkey) || - (exists($ENV{'form.prevenrollstatus'}) && - $ENV{'form.prevenrollstatus'} ne $statuskey) + if (exists($env{'form.ClearCache'}) || + exists($env{'form.updatecaches'}) || + (exists($env{'form.firstrun'}) && $env{'form.firstrun'} ne 'no') || + (exists($env{'form.prevsection'}) && + $env{'form.prevsection'} ne $sectionkey) || + (exists($env{'form.prevenrollstatus'}) && + $env{'form.prevenrollstatus'} ne $statuskey) ) { if (defined($update_message)) { $r->print($update_message); @@ -1372,7 +1335,7 @@ sub manage_caches { '' ); # - if (! exists($ENV{'form.firstrun'})) { + if (! exists($env{'form.firstrun'})) { $r->print(''); } else { $r->print(''); @@ -1405,7 +1368,7 @@ sub gather_full_student_data { return if ($c->aborted()); my $status = &Apache::loncoursedata::ensure_current_full_data ($student->{'username'},$student->{'domain'}, - $ENV{'request.course.id'}); + $env{'request.course.id'}); &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, &mt('last student')); } @@ -1452,7 +1415,7 @@ sub submission_report_form { my $output_selector = $/.'