version 1.40, 2005/02/28 20:16:03
|
version 1.46, 2005/04/07 06:56:24
|
Line 49 routines that are needed across multiple
|
Line 49 routines that are needed across multiple
|
package Apache::lonstathelpers; |
package Apache::lonstathelpers; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::loncoursedata(); |
use Apache::loncoursedata(); |
Line 68 use Storable qw(freeze thaw);
|
Line 68 use Storable qw(freeze thaw);
|
|
|
=item &render_resource($resource) |
=item &render_resource($resource) |
|
|
Input: a resource generated from |
Input: a navmaps resource |
&Apache::loncoursedata::get_sequence_assessment_data(). |
|
|
|
Retunrs: a scalar containing html for a rendering of the problem |
Retunrs: a scalar containing html for a rendering of the problem |
within a table. |
within a table. |
Line 82 sub render_resource {
|
Line 81 sub render_resource {
|
my ($resource) = @_; |
my ($resource) = @_; |
## |
## |
## Render the problem |
## Render the problem |
my $base; |
my ($base) = ($resource->src =~ m|^(.*/)[^/]*$|); |
($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); |
$base="http://".$ENV{'SERVER_NAME'}.$base; |
$base = "http://".$ENV{'SERVER_NAME'}.$base; |
|
my ($src,$symb)=($resource->src,&Apache::lonnet::escape($resource->symb)); |
my ($src,$symb)=($resource->src,&Apache::lonnet::escape($resource->symb)); |
my $rendered_problem = &Apache::lonnet::ssi_body($src.'?symb='.$symb); |
my $rendered_problem = &Apache::lonnet::ssi_body($src.'?symb='.$symb); |
$rendered_problem =~ s/<\s*form\s*/<nop /g; |
$rendered_problem =~ s/<\s*form\s*/<nop /g; |
Line 156 sub problem_selector {
|
Line 154 sub problem_selector {
|
respid=>$respid, |
respid=>$respid, |
resptype=>$resptype}); |
resptype=>$resptype}); |
my $checked = ''; |
my $checked = ''; |
if ($ENV{'form.problemchoice'} eq $value) { |
if ($env{'form.problemchoice'} eq $value) { |
$checked = 'checked '; |
$checked = 'checked '; |
} |
} |
my $title = $res->compTitle; |
my $title = $res->compTitle; |
Line 170 sub problem_selector {
|
Line 168 sub problem_selector {
|
if (scalar(@response_ids) > 1) { |
if (scalar(@response_ids) > 1) { |
$seq_str .= &mt('response').' '.$respid; |
$seq_str .= &mt('response').' '.$respid; |
} |
} |
my $link = $res->{'src'}.'?symb='. |
my $link = $res->src.'?symb='. |
&Apache::lonnet::escape($res->symb); |
&Apache::lonnet::escape($res->symb); |
$seq_str .= (' 'x2). |
$seq_str .= (' 'x2). |
qq{<a target="preview" href="$link">view</a>}; |
qq{<a target="preview" href="$link">view</a>}; |
Line 216 and their contents. A checkbox is provi
|
Line 214 and their contents. A checkbox is provi
|
#################################################### |
#################################################### |
sub MultipleProblemSelector { |
sub MultipleProblemSelector { |
my ($navmap,$inputname,$formname)=@_; |
my ($navmap,$inputname,$formname)=@_; |
my $cid = $ENV{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
my $Str; |
my $Str; |
# Massage the input as needed. |
# Massage the input as needed. |
if (! defined($navmap)) { |
if (! defined($navmap)) { |
Line 257 END
|
Line 255 END
|
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $sequence_string; |
my $sequence_string; |
my $seq_id = 0; |
my $seq_id = 0; |
my @Accumulator = (&new_accumulator($ENV{'course.'.$cid.'.description'}, |
my @Accumulator = (&new_accumulator($env{'course.'.$cid.'.description'}, |
'', |
'', |
'', |
'', |
$seq_id++, |
$seq_id++, |
Line 341 sub get_selected_symbs {
|
Line 339 sub get_selected_symbs {
|
my ($inputfield) = @_; |
my ($inputfield) = @_; |
my $field = 'form.'.$inputfield; |
my $field = 'form.'.$inputfield; |
my @Symbs; |
my @Symbs; |
if (exists($ENV{$field})) { |
if (exists($env{$field})) { |
if (! ref($ENV{$field})) { |
if (! ref($env{$field})) { |
@Symbs = (&Apache::lonnet::unescape($ENV{$field})); |
@Symbs = (&Apache::lonnet::unescape($env{$field})); |
} else { |
} else { |
@Symbs = (map {&Apache::lonnet::unescape($_);} @{$ENV{$field}}); |
@Symbs = (map {&Apache::lonnet::unescape($_);} @{$env{$field}}); |
} |
} |
} |
} |
return @Symbs; |
return @Symbs; |
Line 646 sub analyze_problem_as_student {
|
Line 644 sub analyze_problem_as_student {
|
my $symb = $resource->{'symb'}; |
my $symb = $resource->{'symb'}; |
my $analysis = &get_from_analysis_cache($sname,$sdom,$symb); |
my $analysis = &get_from_analysis_cache($sname,$sdom,$symb); |
if (! defined($analysis)) { |
if (! defined($analysis)) { |
my $courseid = $ENV{'request.course.id'}; |
my $courseid = $env{'request.course.id'}; |
my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze', |
my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze', |
'grade_domain' => $sdom, |
'grade_domain' => $sdom, |
'grade_username' => $sname, |
'grade_username' => $sname, |
Line 870 prior to every analysis lookup.
|
Line 868 prior to every analysis lookup.
|
##################################################### |
##################################################### |
sub ensure_proper_cache { |
sub ensure_proper_cache { |
my ($symb) = @_; |
my ($symb) = @_; |
my $cid = $ENV{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
my $new_filename = '/home/httpd/perl/tmp/'. |
my $new_filename = '/home/httpd/perl/tmp/'. |
'problemanalysis_'.$cid.'_analysis_cache.db'; |
'problemanalysis_'.$cid.'_analysis_cache.db'; |
if (! defined($cache_filename) || |
if (! defined($cache_filename) || |
Line 1267 sub limit_by_time_form {
|
Line 1265 sub limit_by_time_form {
|
} |
} |
|
|
sub limit_by_time { |
sub limit_by_time { |
if (exists($ENV{'form.limit_by_time'}) && |
if (exists($env{'form.limit_by_time'}) && |
$ENV{'form.limit_by_time'} ne '' ) { |
$env{'form.limit_by_time'} ne '' ) { |
return 1; |
return 1; |
} else { |
} else { |
return 0; |
return 0; |
Line 1283 sub get_time_limits {
|
Line 1281 sub get_time_limits {
|
return ($starttime,$endtime); |
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; |
|
} |
|
|
|
#################################################### |
#################################################### |
#################################################### |
#################################################### |
|
|
Line 1342 sub manage_caches {
|
Line 1303 sub manage_caches {
|
join(',', |
join(',', |
map { |
map { |
&Apache::lonnet::escape($_); |
&Apache::lonnet::escape($_); |
} sort(@Apache::lonstatistics::SelectedSections) |
} sort(&Apache::lonstatistics::get_selected_sections()) |
); |
); |
my $statuskey = $Apache::lonstatistics::enrollment_status; |
my $statuskey = $Apache::lonstatistics::enrollment_status; |
if (exists($ENV{'form.ClearCache'}) || |
if (exists($env{'form.ClearCache'}) || |
exists($ENV{'form.updatecaches'}) || |
exists($env{'form.updatecaches'}) || |
(exists($ENV{'form.firstrun'}) && $ENV{'form.firstrun'} ne 'no') || |
(exists($env{'form.firstrun'}) && $env{'form.firstrun'} ne 'no') || |
(exists($ENV{'form.prevsection'}) && |
(exists($env{'form.prevsection'}) && |
$ENV{'form.prevsection'} ne $sectionkey) || |
$env{'form.prevsection'} ne $sectionkey) || |
(exists($ENV{'form.prevenrollstatus'}) && |
(exists($env{'form.prevenrollstatus'}) && |
$ENV{'form.prevenrollstatus'} ne $statuskey) |
$env{'form.prevenrollstatus'} ne $statuskey) |
) { |
) { |
if (defined($update_message)) { |
if (defined($update_message)) { |
$r->print($update_message); |
$r->print($update_message); |
Line 1372 sub manage_caches {
|
Line 1333 sub manage_caches {
|
'<input type="hidden" name="prevenrollstatus" value="'.$statuskey.'" />' |
'<input type="hidden" name="prevenrollstatus" value="'.$statuskey.'" />' |
); |
); |
# |
# |
if (! exists($ENV{'form.firstrun'})) { |
if (! exists($env{'form.firstrun'})) { |
$r->print('<input type="hidden" name="firstrun" value="yes" />'); |
$r->print('<input type="hidden" name="firstrun" value="yes" />'); |
} else { |
} else { |
$r->print('<input type="hidden" name="firstrun" value="no" />'); |
$r->print('<input type="hidden" name="firstrun" value="no" />'); |
Line 1405 sub gather_full_student_data {
|
Line 1366 sub gather_full_student_data {
|
return if ($c->aborted()); |
return if ($c->aborted()); |
my $status = &Apache::loncoursedata::ensure_current_full_data |
my $status = &Apache::loncoursedata::ensure_current_full_data |
($student->{'username'},$student->{'domain'}, |
($student->{'username'},$student->{'domain'}, |
$ENV{'request.course.id'}); |
$env{'request.course.id'}); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&mt('last student')); |
&mt('last student')); |
} |
} |
Line 1452 sub submission_report_form {
|
Line 1413 sub submission_report_form {
|
my $output_selector = $/.'<select name="output">'.$/; |
my $output_selector = $/.'<select name="output">'.$/; |
foreach ('HTML','Excel','CSV') { |
foreach ('HTML','Excel','CSV') { |
$output_selector .= ' <option value="'.lc($_).'"'; |
$output_selector .= ' <option value="'.lc($_).'"'; |
if ($ENV{'form.output'} eq lc($_)) { |
if ($env{'form.output'} eq lc($_)) { |
$output_selector .= ' selected '; |
$output_selector .= ' selected '; |
} |
} |
$output_selector .='>'.&mt($_).'</option>'.$/; |
$output_selector .='>'.&mt($_).'</option>'.$/; |