version 1.46, 2005/04/07 06:56:24
|
version 1.55, 2008/09/14 15:16:29
|
Line 60 use Time::Local();
|
Line 60 use Time::Local();
|
use Spreadsheet::WriteExcel(); |
use Spreadsheet::WriteExcel(); |
use GDBM_File; |
use GDBM_File; |
use Storable qw(freeze thaw); |
use Storable qw(freeze thaw); |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
#################################################### |
#################################################### |
#################################################### |
#################################################### |
Line 83 sub render_resource {
|
Line 86 sub render_resource {
|
## Render the problem |
## Render the problem |
my ($base) = ($resource->src =~ m|^(.*/)[^/]*$|); |
my ($base) = ($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->link,&escape($resource->shown_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; |
$rendered_problem =~ s|(<\s*/form\s*>)|<\/nop>|g; |
$rendered_problem =~ s|(<\s*/form\s*>)|<\/nop>|g; |
Line 132 Skips 'survey' problems.
|
Line 135 Skips 'survey' problems.
|
#################################################### |
#################################################### |
#################################################### |
#################################################### |
sub problem_selector { |
sub problem_selector { |
my ($AcceptedResponseTypes) = @_; |
my ($AcceptedResponseTypes,$sequence_addendum) = @_; |
my $Str; |
my $Str; |
$Str = "\n<table>\n"; |
$Str = "\n<table>\n"; |
my $rb_count =0; |
my $rb_count =0; |
Line 168 sub problem_selector {
|
Line 171 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->link.'?symb='.&escape($res->shown_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>}; |
$seq_str .= "</td></tr>\n"; |
$seq_str .= "</td></tr>\n"; |
Line 179 sub problem_selector {
|
Line 181 sub problem_selector {
|
} |
} |
} |
} |
if ($seq_str ne '') { |
if ($seq_str ne '') { |
$Str .= '<tr><td> </td><td colspan="2"><b>'.$seq->compTitle.'</b></td>'. |
$Str .= '<tr><td> </td>'. |
|
'<td colspan="2"><b>'.$seq->compTitle.'</b></td>'. |
"</tr>\n".$seq_str; |
"</tr>\n".$seq_str; |
|
if (defined($sequence_addendum)) { |
|
$Str .= '<tr>'. |
|
('<td> </td>'x2). |
|
'<td align="right">'.$sequence_addendum.'</td>'. |
|
"</tr>\n"; |
|
} |
} |
} |
} |
} |
$Str .= "</table>\n"; |
$Str .= "</table>\n"; |
Line 316 sub new_accumulator {
|
Line 325 sub new_accumulator {
|
} |
} |
$target .= 'id="'.$seq_id.':'.$item_id++.'" '; |
$target .= 'id="'.$seq_id.':'.$item_id++.'" '; |
$target.= |
$target.= |
'value="'.&Apache::lonnet::escape($res->symb).'" />'. |
'value="'.&escape($res->symb).'" />'. |
' '.$res->compTitle.'</label>'. |
' '.$res->compTitle.'</label>'. |
(' 'x2).'<a target="preview" '. |
(' 'x2).'<a target="preview" '. |
'href="'.$res->src.'?symb='. |
'href="'.$res->link.'?symb='. |
&Apache::lonnet::escape($res->symb).'">view</a>'. |
&escape($res->shown_symb).'">view</a>'. |
'</td></tr>'.$/; |
'</td></tr>'.$/; |
} else { |
} else { |
if (defined($target)) { |
if (defined($target)) { |
Line 338 sub new_accumulator {
|
Line 347 sub new_accumulator {
|
sub get_selected_symbs { |
sub get_selected_symbs { |
my ($inputfield) = @_; |
my ($inputfield) = @_; |
my $field = 'form.'.$inputfield; |
my $field = 'form.'.$inputfield; |
my @Symbs; |
my @symbs = (map { |
if (exists($env{$field})) { |
&unescape($_); |
if (! ref($env{$field})) { |
} &Apache::loncommon::get_env_multiple($field)); |
@Symbs = (&Apache::lonnet::unescape($env{$field})); |
return @symbs; |
} else { |
|
@Symbs = (map {&Apache::lonnet::unescape($_);} @{$env{$field}}); |
|
} |
|
} |
|
return @Symbs; |
|
} |
} |
|
|
#################################################### |
#################################################### |
Line 371 Used by Apache::lonstathelpers::ProblemS
|
Line 375 Used by Apache::lonstathelpers::ProblemS
|
#################################################### |
#################################################### |
sub make_target_id { |
sub make_target_id { |
my ($target) = @_; |
my ($target) = @_; |
my $id = &Apache::lonnet::escape($target->{'symb'}).':'. |
my $id = &escape($target->{'symb'}).':'. |
&Apache::lonnet::escape($target->{'part'}).':'. |
&escape($target->{'part'}).':'. |
&Apache::lonnet::escape($target->{'respid'}).':'. |
&escape($target->{'respid'}).':'. |
&Apache::lonnet::escape($target->{'resptype'}); |
&escape($target->{'resptype'}); |
return $id; |
return $id; |
} |
} |
|
|
Line 399 sub get_target_from_id {
|
Line 403 sub get_target_from_id {
|
my ($id) = @_; |
my ($id) = @_; |
if (! ref($id)) { |
if (! ref($id)) { |
my ($symb,$part,$respid,$resptype) = split(':',$id); |
my ($symb,$part,$respid,$resptype) = split(':',$id); |
return ({ symb => &Apache::lonnet::unescape($symb), |
return ({ symb => &unescape($symb), |
part => &Apache::lonnet::unescape($part), |
part => &unescape($part), |
respid => &Apache::lonnet::unescape($respid), |
respid => &unescape($respid), |
resptype => &Apache::lonnet::unescape($resptype)}); |
resptype => &unescape($resptype)}); |
} elsif (ref($id) eq 'ARRAY') { |
} elsif (ref($id) eq 'ARRAY') { |
my @Return; |
my @Return; |
foreach my $selected (@$id) { |
foreach my $selected (@$id) { |
my ($symb,$part,$respid,$resptype) = split(':',$selected); |
my ($symb,$part,$respid,$resptype) = split(':',$selected); |
push(@Return,{ symb => &Apache::lonnet::unescape($symb), |
push(@Return,{ symb => &unescape($symb), |
part => &Apache::lonnet::unescape($part), |
part => &unescape($part), |
respid => &Apache::lonnet::unescape($respid), |
respid => &unescape($respid), |
resptype => &Apache::lonnet::unescape($resptype)}); |
resptype => &unescape($resptype)}); |
} |
} |
return \@Return; |
return \@Return; |
} |
} |
Line 429 current resource.
|
Line 433 current resource.
|
Inputs: $target (see &Apache::lonstathelpers::get_target_from_id()) |
Inputs: $target (see &Apache::lonstathelpers::get_target_from_id()) |
$AcceptableResponseTypes, regular expression matching acceptable |
$AcceptableResponseTypes, regular expression matching acceptable |
response types, |
response types, |
$granularity, either 'part', 'response', or 'part_survey' |
$granularity, either 'part', 'response', 'part_survey', or 'part_task' |
|
|
Returns: three hash references, $prev, $curr, $next, which refer to the |
Returns: three hash references, $prev, $curr, $next, which refer to the |
preceeding, current, or following problem parts or responses, depending |
preceeding, current, or following problem parts or responses, depending |
Line 465 sub get_prev_curr_next {
|
Line 469 sub get_prev_curr_next {
|
part => $part, |
part => $part, |
resource => $res, |
resource => $res, |
} ); |
} ); |
|
} elsif ($res->is_task($part) && ($granularity eq 'part_task')){ |
|
push (@Resource, |
|
{ symb => $res->symb, |
|
part => $part, |
|
resource => $res, |
|
} ); |
} elsif ($granularity eq 'part') { |
} elsif ($granularity eq 'part') { |
push (@Resource, |
push (@Resource, |
{ symb => $res->symb, |
{ symb => $res->symb, |
Line 497 sub get_prev_curr_next {
|
Line 507 sub get_prev_curr_next {
|
my $curr_idx; |
my $curr_idx; |
for ($curr_idx=0;$curr_idx<$#Resource;$curr_idx++) { |
for ($curr_idx=0;$curr_idx<$#Resource;$curr_idx++) { |
my $curr_item = $Resource[$curr_idx]; |
my $curr_item = $Resource[$curr_idx]; |
if ($granularity eq 'part' || $granularity eq 'part_survey') { |
if ($granularity =~ /^(part|part_survey|part_task)$/) { |
if ($curr_item->{'symb'} eq $target->{'symb'} && |
if ($curr_item->{'symb'} eq $target->{'symb'} && |
$curr_item->{'part'} eq $target->{'part'}) { |
$curr_item->{'part'} eq $target->{'part'}) { |
last; |
last; |
Line 512 sub get_prev_curr_next {
|
Line 522 sub get_prev_curr_next {
|
} |
} |
} |
} |
my $curr_item = $Resource[$curr_idx]; |
my $curr_item = $Resource[$curr_idx]; |
if ($granularity eq 'part' || $granularity eq 'part_survey') { |
if ($granularity =~ /^(part|part_survey|part_task)$/) { |
if ($curr_item->{'symb'} ne $target->{'symb'} || |
if ($curr_item->{'symb'} ne $target->{'symb'} || |
$curr_item->{'part'} ne $target->{'part'}) { |
$curr_item->{'part'} ne $target->{'part'}) { |
# bogus symb - return nothing |
# bogus symb - return nothing |
Line 725 sub get_answer {
|
Line 735 sub get_answer {
|
my ($prefix,$key,%Answer) = @_; |
my ($prefix,$key,%Answer) = @_; |
my $returnvalue; |
my $returnvalue; |
if (exists($Answer{$key})) { |
if (exists($Answer{$key})) { |
my $student_answer = $Answer{$key}->[0]; |
if (ref($Answer{$key}) eq 'HASH') { |
if (! defined($student_answer)) { |
my $which = 'INTERNAL'; |
$student_answer = $Answer{$key}->[1]; |
if (!exists($Answer{$key}{$which})) { |
} |
$which = (sort(keys(%{ $Answer{$key} })))[0]; |
$returnvalue = $student_answer; |
} |
|
my $student_answer = $Answer{$key}{$which}[0][0]; |
|
$returnvalue = $student_answer; |
|
} else { |
|
&Apache::lonnet::logthis("error analyzing problem. got a answer of type ".ref($Answer{$key})); |
|
} |
} else { |
} else { |
if (exists($Answer{$prefix.'.shown'})) { |
if (exists($Answer{$prefix.'.shown'})) { |
# The response has foils |
# The response has foils |
Line 787 sub load_analysis_cache {
|
Line 802 sub load_analysis_cache {
|
my $storedstring; |
my $storedstring; |
my %cache_db; |
my %cache_db; |
if (tie(%cache_db,'GDBM_File',$cache_filename,&GDBM_READER(),0640)) { |
if (tie(%cache_db,'GDBM_File',$cache_filename,&GDBM_READER(),0640)) { |
$storedstring = $cache_db{&Apache::lonnet::escape($symb)}; |
$storedstring = $cache_db{&escape($symb)}; |
untie(%cache_db); |
untie(%cache_db); |
} |
} |
if (defined($storedstring)) { |
if (defined($storedstring)) { |
Line 839 Writes the in memory cache to disk so th
|
Line 854 Writes the in memory cache to disk so th
|
sub write_analysis_cache { |
sub write_analysis_cache { |
return if (! defined($current_symb) || ! defined($cache_filename)); |
return if (! defined($current_symb) || ! defined($cache_filename)); |
my %cache_db; |
my %cache_db; |
my $key = &Apache::lonnet::escape($current_symb); |
my $key = &escape($current_symb); |
if (tie(%cache_db,'GDBM_File',$cache_filename,&GDBM_WRCREAT(),0640)) { |
if (tie(%cache_db,'GDBM_File',$cache_filename,&GDBM_WRCREAT(),0640)) { |
my $storestring = freeze(\%cache); |
my $storestring = freeze(\%cache); |
$cache_db{$key}=$storestring; |
$cache_db{$key}=$storestring; |
Line 1133 sub get_problem_data {
|
Line 1148 sub get_problem_data {
|
} |
} |
} |
} |
# End of logging code |
# End of logging code |
next if ($key !~ /^$part/); |
next if ($key !~ /^\Q$part\E/); |
$key =~ s/^$part\.//; |
$key =~ s/^\Q$part\E\.//; |
if (ref($value) eq 'ARRAY') { |
if (ref($value) eq 'ARRAY') { |
if ($key eq 'options') { |
if ($key eq 'options') { |
$Partdata{$part}->{'_Options'}=$value; |
$Partdata{$part}->{'_Options'}=$value; |
Line 1257 sub limit_by_time_form {
|
Line 1272 sub limit_by_time_form {
|
} |
} |
$timecheckbox .= 'OnChange="javascript:toggle_limitby_activity(this.checked);" '; |
$timecheckbox .= 'OnChange="javascript:toggle_limitby_activity(this.checked);" '; |
$timecheckbox .= ' />'; |
$timecheckbox .= ' />'; |
$Str .= '<legend>'.&mt('[_1] Limit by time',$timecheckbox).'</legend>'; |
$Str .= '<legend><label>'.&mt('[_1] Limit by time',$timecheckbox).'</label></legend>'; |
$Str .= &mt('Start Time: [_1]',$startdateform).'<br />'; |
$Str .= &mt('Start Time: [_1]',$startdateform).'<br />'; |
$Str .= &mt(' End Time: [_1]',$enddateform).'<br />'; |
$Str .= &mt(' End Time: [_1]',$enddateform).'<br />'; |
$Str .= '</fieldset>'; |
$Str .= '</fieldset>'; |
Line 1302 sub manage_caches {
|
Line 1317 sub manage_caches {
|
my $sectionkey = |
my $sectionkey = |
join(',', |
join(',', |
map { |
map { |
&Apache::lonnet::escape($_); |
&escape($_); |
} sort(&Apache::lonstatistics::get_selected_sections()) |
} sort(&Apache::lonstatistics::get_selected_sections()) |
); |
); |
my $statuskey = $Apache::lonstatistics::enrollment_status; |
my $statuskey = $Apache::lonstatistics::enrollment_status; |