version 1.39, 2005/02/23 23:51:18
|
version 1.41, 2005/02/28 22:37:28
|
Line 85 sub render_resource {
|
Line 85 sub render_resource {
|
my $base; |
my $base; |
($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); |
($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); |
$base = "http://".$ENV{'SERVER_NAME'}.$base; |
$base = "http://".$ENV{'SERVER_NAME'}.$base; |
my $rendered_problem = |
my ($src,$symb)=($resource->src,&Apache::lonnet::escape($resource->symb)); |
&Apache::lonnet::ssi_body($resource->{'src'}.'?symb='.&Apache::lonnet::escape($resource->{'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; |
return '<table bgcolor="ffffff"><tr><td>'. |
return '<table bgcolor="ffffff"><tr><td>'. |
Line 100 sub render_resource {
|
Line 100 sub render_resource {
|
|
|
=pod |
=pod |
|
|
=item &ProblemSelector($AcceptedResponseTypes) |
=item &get_resources |
|
|
|
=cut |
|
|
|
#################################################### |
|
#################################################### |
|
sub get_resources { |
|
my ($navmap,$sequence) = @_; |
|
my @resources = $navmap->retrieveResources($sequence, |
|
sub { shift->is_problem(); }, |
|
0,0,0); |
|
return @resources; |
|
} |
|
|
|
#################################################### |
|
#################################################### |
|
|
|
=pod |
|
|
|
=item &problem_selector($AcceptedResponseTypes) |
|
|
Input: scalar containing regular expression which matches response |
Input: scalar containing regular expression which matches response |
types to show. '.' will yield all, '(option|radiobutton)' will match |
types to show. '.' will yield all, '(option|radiobutton)' will match |
Line 114 Skips 'survey' problems.
|
Line 133 Skips 'survey' problems.
|
|
|
#################################################### |
#################################################### |
#################################################### |
#################################################### |
sub ProblemSelector { |
sub problem_selector { |
my ($AcceptedResponseTypes) = @_; |
my ($AcceptedResponseTypes) = @_; |
my $Str; |
my $Str; |
$Str = "\n<table>\n"; |
$Str = "\n<table>\n"; |
my $rb_count =0; |
my $rb_count =0; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess('all')) { |
my ($navmap,@sequences) = |
next if ($seq->{'num_assess'}<1); |
&Apache::lonstatistics::selected_sequences_with_assessments('all'); |
|
return $navmap if (! ref($navmap)); # error |
|
foreach my $seq (@sequences) { |
my $seq_str = ''; |
my $seq_str = ''; |
foreach my $res (@{$seq->{'contents'}}) { |
foreach my $res (&get_resources($navmap,$seq)) { |
next if ($res->{'type'} ne 'assessment'); |
foreach my $part (@{$res->parts}) { |
foreach my $part (@{$res->{'parts'}}) { |
my @response_ids = $res->responseIds($part); |
my $partdata = $res->{'partdata'}->{$part}; |
my @response_types = $res->responseType($part); |
for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){ |
for (my $i=0;$i<scalar(@response_types);$i++){ |
my $respid = $partdata->{'ResponseIds'}->[$i]; |
my $respid = $response_ids[$i]; |
my $resptype = $partdata->{'ResponseTypes'}->[$i]; |
my $resptype = $response_types[$i]; |
if ($resptype =~ m/$AcceptedResponseTypes/) { |
if ($resptype =~ m/$AcceptedResponseTypes/) { |
my $value = &make_target_id({symb=>$res->{'symb'}, |
my $value = &make_target_id({symb=>$res->symb, |
part=>$part, |
part=>$part, |
respid=>$respid, |
respid=>$respid, |
resptype=>$resptype}); |
resptype=>$resptype}); |
Line 138 sub ProblemSelector {
|
Line 159 sub ProblemSelector {
|
if ($ENV{'form.problemchoice'} eq $value) { |
if ($ENV{'form.problemchoice'} eq $value) { |
$checked = 'checked '; |
$checked = 'checked '; |
} |
} |
my $title = $res->{'title'}; |
my $title = $res->compTitle; |
if (! defined($title) || $title eq '') { |
if (! defined($title) || $title eq '') { |
($title) = ($res->{'src'} =~ m:/([^/]*)$:); |
($title) = ($res->src =~ m:/([^/]*)$:); |
} |
} |
$seq_str .= '<tr>'. |
$seq_str .= '<tr>'. |
qq{<td><input type="radio" id="$rb_count" name="problemchoice" value="$value" $checked /></td>}. |
qq{<td><input type="radio" id="$rb_count" name="problemchoice" value="$value" $checked /></td>}. |
'<td><label for="'.$rb_count.'">'.$resptype.'</label></td>'. |
'<td><label for="'.$rb_count.'">'.$resptype.'</label></td>'. |
'<td><label for="'.$rb_count.'">'.$title.'</label>'; |
'<td><label for="'.$rb_count.'">'.$title.'</label>'; |
if (scalar(@{$partdata->{'ResponseIds'}}) > 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>}; |
$seq_str .= "</td></tr>\n"; |
$seq_str .= "</td></tr>\n"; |
Line 160 sub ProblemSelector {
|
Line 181 sub ProblemSelector {
|
} |
} |
} |
} |
if ($seq_str ne '') { |
if ($seq_str ne '') { |
$Str .= '<tr><td> </td><td colspan="2"><b>'.$seq->{'title'}.'</b></td>'. |
$Str .= '<tr><td> </td><td colspan="2"><b>'.$seq->compTitle.'</b></td>'. |
"</tr>\n".$seq_str; |
"</tr>\n".$seq_str; |
} |
} |
} |
} |
Line 433 sub get_prev_curr_next {
|
Line 454 sub get_prev_curr_next {
|
# |
# |
# Build an array with the data we need to search through |
# Build an array with the data we need to search through |
my @Resource; |
my @Resource; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess('all')) { |
my ($navmap,@sequences) = |
foreach my $res (@{$seq->{'contents'}}) { |
&Apache::lonstatistics::selected_sequences_with_assessments('all'); |
next if ($res->{'type'} ne 'assessment'); |
return $navmap if (! ref($navmap)); |
foreach my $part (@{$res->{'parts'}}) { |
foreach my $seq (@sequences) { |
my $partdata = $res->{'partdata'}->{$part}; |
my @resources = &get_resources($navmap,$seq); |
if ($partdata->{'Survey'} && ($granularity eq 'part_survey')){ |
foreach my $res (@resources) { |
|
foreach my $part (@{$res->parts}) { |
|
if ($res->is_survey($part) && ($granularity eq 'part_survey')){ |
push (@Resource, |
push (@Resource, |
{ symb => $res->{symb}, |
{ symb => $res->symb, |
part => $part, |
part => $part, |
resource => $res, |
resource => $res, |
} ); |
} ); |
} elsif ($granularity eq 'part') { |
} elsif ($granularity eq 'part') { |
push (@Resource, |
push (@Resource, |
{ symb => $res->{symb}, |
{ symb => $res->symb, |
part => $part, |
part => $part, |
resource => $res, |
resource => $res, |
} ); |
} ); |
} elsif ($granularity eq 'response') { |
} elsif ($granularity eq 'response') { |
|
my @response_ids = $res->responseIds($part); |
|
my @response_types = $res->responseType($part); |
for (my $i=0; |
for (my $i=0; |
$i<scalar(@{$partdata->{'ResponseTypes'}}); |
$i<scalar(@response_ids); |
$i++){ |
$i++){ |
my $respid = $partdata->{'ResponseIds'}->[$i]; |
my $respid = $response_ids[$i]; |
my $resptype = $partdata->{'ResponseTypes'}->[$i]; |
my $resptype = $response_types[$i]; |
next if ($resptype !~ m/$AcceptableResponseTypes/); |
next if ($resptype !~ m/$AcceptableResponseTypes/); |
push (@Resource, |
push (@Resource, |
{ symb => $res->{symb}, |
{ symb => $res->symb, |
part => $part, |
part => $part, |
respid => $partdata->{'ResponseIds'}->[$i], |
respid => $respid, |
|
resptype => $resptype, |
resource => $res, |
resource => $res, |
resptype => $resptype |
|
} ); |
} ); |
} |
} |
} |
} |
Line 520 sub get_prev_curr_next {
|
Line 545 sub get_prev_curr_next {
|
$curr = $Resource[$curr_idx ]; |
$curr = $Resource[$curr_idx ]; |
$next = $Resource[$curr_idx+1]; |
$next = $Resource[$curr_idx+1]; |
} |
} |
return ($prev,$curr,$next); |
return ($navmap,$prev,$curr,$next); |
} |
} |
|
|
|
|
Line 1331 sub manage_caches {
|
Line 1356 sub manage_caches {
|
if (defined($update_message)) { |
if (defined($update_message)) { |
$r->print($update_message); |
$r->print($update_message); |
} |
} |
|
if (0) { |
|
&Apache::lonnet::logthis('Updating mysql student data caches'); |
|
} |
&gather_full_student_data($r,$formname,$inputname); |
&gather_full_student_data($r,$formname,$inputname); |
} |
} |
# |
# |