version 1.226, 2003/09/09 18:46:28
|
version 1.246, 2004/02/12 18:00:33
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# (Page Handler |
### |
# |
|
# (TeX Content Handler |
|
# |
|
# 05/29/00,05/30 Gerd Kortemeyer) |
|
# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, |
|
# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer) |
|
# |
|
# 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21,9/24,9/25 Gerd Kortemeyer |
|
# YEAR=2002 |
|
# 1/1 Gerd Kortemeyer |
|
# Oct-Nov Jeremy Bowers |
|
# YEAR=2003 |
|
# Jeremy Bowers ... lots of days |
|
|
|
package Apache::lonnavmaps; |
package Apache::lonnavmaps; |
|
|
Line 46 use strict;
|
Line 33 use strict;
|
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmenu(); |
use Apache::lonmenu(); |
|
use Apache::lonlocal; |
use POSIX qw (floor strftime); |
use POSIX qw (floor strftime); |
use Data::Dumper; # for debugging, not always used |
use Data::Dumper; # for debugging, not always used |
|
|
Line 106 sub real_handler {
|
Line 94 sub real_handler {
|
# Handle header-only request |
# Handle header-only request |
if ($r->header_only) { |
if ($r->header_only) { |
if ($ENV{'browser.mathml'}) { |
if ($ENV{'browser.mathml'}) { |
$r->content_type('text/xml'); |
&Apache::loncommon::content_type($r,'text/xml'); |
} else { |
} else { |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
} |
} |
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
Line 116 sub real_handler {
|
Line 104 sub real_handler {
|
|
|
# Send header, don't cache this page |
# Send header, don't cache this page |
if ($ENV{'browser.mathml'}) { |
if ($ENV{'browser.mathml'}) { |
$r->content_type('text/xml'); |
&Apache::loncommon::content_type($r,'text/xml'); |
} else { |
} else { |
$r->content_type('text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
} |
} |
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
Line 126 sub real_handler {
|
Line 114 sub real_handler {
|
# Create the nav map |
# Create the nav map |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
|
|
|
if (!defined($navmap)) { |
if (!defined($navmap)) { |
my $requrl = $r->uri; |
my $requrl = $r->uri; |
$ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; |
$ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; |
Line 134 sub real_handler {
|
Line 121 sub real_handler {
|
} |
} |
|
|
$r->print("<html><head>\n"); |
$r->print("<html><head>\n"); |
$r->print("<title>Navigate Course Contents</title>"); |
$r->print("<title>".&mt('Navigate Course Contents')."</title>"); |
# ------------------------------------------------------------ Get query string |
# ------------------------------------------------------------ Get query string |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']); |
|
|
Line 221 sub real_handler {
|
Line 208 sub real_handler {
|
} |
} |
} else { |
} else { |
$r->print("<a href='navmaps?jumpToFirstHomework'>" . |
$r->print("<a href='navmaps?jumpToFirstHomework'>" . |
"Go To My First Homework Problem</a> "); |
&mt("Go To My First Homework Problem")."</a> "); |
} |
} |
|
|
my $suppressEmptySequences = 0; |
my $suppressEmptySequences = 0; |
Line 236 sub real_handler {
|
Line 223 sub real_handler {
|
$filterFunc = sub { my $res = shift; |
$filterFunc = sub { my $res = shift; |
return $res->completable() || $res->is_map(); |
return $res->completable() || $res->is_map(); |
}; |
}; |
$r->print("<p><font size='+2'>Uncompleted Homework</font></p>"); |
$r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>"); |
$ENV{'form.filter'} = ''; |
$ENV{'form.filter'} = ''; |
$ENV{'form.condition'} = 1; |
$ENV{'form.condition'} = 1; |
$resource_no_folder_link = 1; |
$resource_no_folder_link = 1; |
} else { |
} else { |
$r->print("<a href='navmaps?showOnlyHomework'>" . |
$r->print("<a href='navmaps?showOnlyHomework'>" . |
"Show Only Uncompleted Homework</a> "); |
&mt("Show Only Uncompleted Homework")."</a> "); |
} |
} |
|
|
# renderer call |
# renderer call |
Line 261 sub real_handler {
|
Line 248 sub real_handler {
|
# user knows there was no error. |
# user knows there was no error. |
if ($renderArgs->{'counter'} == 0) { |
if ($renderArgs->{'counter'} == 0) { |
if ($showOnlyHomework) { |
if ($showOnlyHomework) { |
$r->print("<p><font size='+1'>All homework is currently completed.</font></p>"); |
$r->print("<p><font size='+1'>".&mt("All homework is currently completed").".</font></p>"); |
} else { # both jumpToFirstHomework and normal use the same: course must be empty |
} else { # both jumpToFirstHomework and normal use the same: course must be empty |
$r->print("<p><font size='+1'>This course is empty.</font></p>"); |
$r->print("<p><font size='+1'>This course is empty.</font></p>"); |
} |
} |
Line 331 sub getDescription {
|
Line 318 sub getDescription {
|
my $status = $res->status($part); |
my $status = $res->status($part); |
|
|
if ($status == $res->NETWORK_FAILURE) { |
if ($status == $res->NETWORK_FAILURE) { |
return "Having technical difficulties; please check status later"; |
return &mt("Having technical difficulties; please check status later"); |
} |
} |
if ($status == $res->NOTHING_SET) { |
if ($status == $res->NOTHING_SET) { |
return "Not currently assigned."; |
return &mt("Not currently assigned."); |
} |
} |
if ($status == $res->OPEN_LATER) { |
if ($status == $res->OPEN_LATER) { |
return "Open " . timeToHumanString($res->opendate($part)); |
return "Open " . timeToHumanString($res->opendate($part)); |
} |
} |
if ($status == $res->OPEN) { |
if ($status == $res->OPEN) { |
if ($res->duedate($part)) { |
if ($res->duedate($part)) { |
return "Due " . timeToHumanString($res->duedate($part)); |
return &mt("Due")." " .timeToHumanString($res->duedate($part)); |
} else { |
} else { |
return "Open, no due date"; |
return &mt("Open, no due date"); |
} |
} |
} |
} |
if ($status == $res->PAST_DUE_ANSWER_LATER) { |
if ($status == $res->PAST_DUE_ANSWER_LATER) { |
return "Answer open " . timeToHumanString($res->answerdate($part)); |
return &mt("Answer open")." " . timeToHumanString($res->answerdate($part)); |
} |
} |
if ($status == $res->PAST_DUE_NO_ANSWER) { |
if ($status == $res->PAST_DUE_NO_ANSWER) { |
return "Was due " . timeToHumanString($res->duedate($part)); |
return &mt("Was due")." " . timeToHumanString($res->duedate($part)); |
} |
} |
if ($status == $res->ANSWER_OPEN) { |
if ($status == $res->ANSWER_OPEN) { |
return "Answer available"; |
return &mt("Answer available"); |
} |
} |
if ($status == $res->EXCUSED) { |
if ($status == $res->EXCUSED) { |
return "Excused by instructor"; |
return &mt("Excused by instructor"); |
} |
} |
if ($status == $res->ATTEMPTED) { |
if ($status == $res->ATTEMPTED) { |
return "Answer submitted, not yet graded."; |
return &mt("Answer submitted, not yet graded"); |
} |
} |
if ($status == $res->TRIES_LEFT) { |
if ($status == $res->TRIES_LEFT) { |
my $tries = $res->tries($part); |
my $tries = $res->tries($part); |
Line 371 sub getDescription {
|
Line 358 sub getDescription {
|
$triesString = "<b>$triesString</b>"; |
$triesString = "<b>$triesString</b>"; |
} |
} |
} |
} |
if ($res->duedate()) { |
if ($res->duedate($part)) { |
return "Due " . timeToHumanString($res->duedate($part)) . |
return &mt("Due")." " . timeToHumanString($res->duedate($part)) . |
" $triesString"; |
" $triesString"; |
} else { |
} else { |
return "No due date $triesString"; |
return &mt("No due date")." $triesString"; |
} |
} |
} |
} |
if ($status == $res->ANSWER_SUBMITTED) { |
if ($status == $res->ANSWER_SUBMITTED) { |
return 'Answer submitted'; |
return &mt('Answer submitted'); |
} |
} |
} |
} |
|
|
Line 393 sub dueInLessThen24Hours {
|
Line 380 sub dueInLessThen24Hours {
|
|
|
return ($status == $res->OPEN() || |
return ($status == $res->OPEN() || |
$status == $res->TRIES_LEFT()) && |
$status == $res->TRIES_LEFT()) && |
$res->duedate() && $res->duedate() < time()+(24*60*60) && |
$res->duedate($part) && $res->duedate($part) < time()+(24*60*60) && |
$res->duedate() > time(); |
$res->duedate($part) > time(); |
} |
} |
|
|
# Convenience function, so others can use it: Is there only one try remaining for the |
# Convenience function, so others can use it: Is there only one try remaining for the |
Line 406 sub lastTry {
|
Line 393 sub lastTry {
|
my $tries = $res->tries($part); |
my $tries = $res->tries($part); |
my $maxtries = $res->maxtries($part); |
my $maxtries = $res->maxtries($part); |
return $tries && $maxtries && $maxtries > 1 && |
return $tries && $maxtries && $maxtries > 1 && |
$maxtries - $tries == 1 && $res->duedate() && |
$maxtries - $tries == 1 && $res->duedate($part) && |
$res->duedate() > time(); |
$res->duedate($part) > time(); |
} |
} |
|
|
# This puts a human-readable name on the ENV variable. |
# This puts a human-readable name on the ENV variable. |
Line 429 sub timeToHumanString {
|
Line 416 sub timeToHumanString {
|
my ($time) = @_; |
my ($time) = @_; |
# zero, '0' and blank are bad times |
# zero, '0' and blank are bad times |
if (!$time) { |
if (!$time) { |
return 'never'; |
return &mt('never'); |
} |
} |
|
unless (&Apache::lonlocal::current_language()=~/^en/) { |
|
return &Apache::lonlocal::locallocaltime($time); |
|
} |
my $now = time(); |
my $now = time(); |
|
|
my @time = localtime($time); |
my @time = localtime($time); |
Line 499 sub timeToHumanString {
|
Line 488 sub timeToHumanString {
|
# HH:MM |
# HH:MM |
if ( $delta < $day * 5 ) { |
if ( $delta < $day * 5 ) { |
my $timeStr = strftime("%A, %b %e at %I:%M %P", localtime($time)); |
my $timeStr = strftime("%A, %b %e at %I:%M %P", localtime($time)); |
$timeStr =~ s/12:00 am/midnight/; |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 pm/noon/; |
$timeStr =~ s/12:00 pm/noon/; |
return ($inPast ? "last " : "next ") . |
return ($inPast ? "last " : "next ") . |
$timeStr; |
$timeStr; |
Line 509 sub timeToHumanString {
|
Line 498 sub timeToHumanString {
|
if ( $time[5] == $now[5]) { |
if ( $time[5] == $now[5]) { |
# Return on Month Day, HH:MM meridian |
# Return on Month Day, HH:MM meridian |
my $timeStr = strftime("on %A, %b %e at %I:%M %P", localtime($time)); |
my $timeStr = strftime("on %A, %b %e at %I:%M %P", localtime($time)); |
$timeStr =~ s/12:00 am/midnight/; |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 pm/noon/; |
$timeStr =~ s/12:00 pm/noon/; |
return $timeStr; |
return $timeStr; |
} |
} |
|
|
# Not this year, so show the year |
# Not this year, so show the year |
my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time)); |
my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time)); |
$timeStr =~ s/12:00 am/midnight/; |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 pm/noon/; |
$timeStr =~ s/12:00 pm/noon/; |
return $timeStr; |
return $timeStr; |
} |
} |
Line 893 sub render_resource {
|
Line 882 sub render_resource {
|
$icon = $params->{'indentString'}; |
$icon = $params->{'indentString'}; |
} |
} |
} else { |
} else { |
my $curfext= (split (/\./,$resource->src))[-1]; |
$icon = "<img src='".&Apache::loncommon::icon($resource->src). |
my $embstyle = &Apache::loncommon::fileembstyle($curfext); |
"' alt='' border='0' />"; |
# The unless conditional that follows is a bit of overkill |
|
if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) { |
|
$icon = "<img src='/adm/lonIcons/$curfext.gif' alt='' border='0' />"; |
|
} |
|
} |
} |
|
|
# Display the correct map icon to open or shut map |
# Display the correct map icon to open or shut map |
Line 968 sub render_resource {
|
Line 953 sub render_resource {
|
|
|
if ($resource->is_problem() && $part ne '0' && |
if ($resource->is_problem() && $part ne '0' && |
!$params->{'condensed'}) { |
!$params->{'condensed'}) { |
$partLabel = " (Part $part)"; |
my $displaypart=&Apache::lonnet::EXT('resource.'.$part.'.display', |
|
$resource->symb()); |
|
unless ($displaypart) { $displaypart=$part; } |
|
$partLabel = " (Part: $displaypart)"; |
|
$link.='#'.&Apache::lonnet::escape($part); |
$title = ""; |
$title = ""; |
} |
} |
|
|
Line 1093 sub render_long_status {
|
Line 1082 sub render_long_status {
|
return $result; |
return $result; |
} |
} |
|
|
|
# Colors obtained by taking the icons, matching the colors, and |
|
# possibly reducing the Value (HSV) of the color, if it's too bright |
|
# for text, generally by one third or so. |
my %statusColors = |
my %statusColors = |
( |
( |
$resObj->CLOSED => '#000000', |
$resObj->CLOSED => '#000000', |
$resObj->OPEN => '#000000', |
$resObj->OPEN => '#998b13', |
$resObj->CORRECT => '#000000', |
$resObj->CORRECT => '#26933f', |
$resObj->INCORRECT => '#000000', |
$resObj->INCORRECT => '#c48207', |
$resObj->ATTEMPTED => '#000000', |
$resObj->ATTEMPTED => '#a87510', |
$resObj->ERROR => '#000000' |
$resObj->ERROR => '#000000' |
); |
); |
my %statusStrings = |
my %statusStrings = |
Line 1144 sub render_parts_summary_status {
|
Line 1136 sub render_parts_summary_status {
|
} |
} |
} |
} |
|
|
return $td . join (', ', @counts) . $endtd; |
return $td . $resource->countParts() . ' parts: ' . join (', ', @counts) . $endtd; |
} |
} |
|
|
my @preparedColumns = (\&render_resource, \&render_communication_status, |
my @preparedColumns = (\&render_resource, \&render_communication_status, |
Line 1325 sub render {
|
Line 1317 sub render {
|
$result.='<tr><td align="right" valign="bottom">Key: </td>'; |
$result.='<tr><td align="right" valign="bottom">Key: </td>'; |
if ($navmap->{LAST_CHECK}) { |
if ($navmap->{LAST_CHECK}) { |
$result .= |
$result .= |
'<img src="/adm/lonMisc/chat.gif"> New discussion since '. |
'<img src="/adm/lonMisc/chat.gif"> '.&mt('New discussion since').' '. |
strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). |
strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). |
'</td><td align="center" valign="bottom"> '. |
'</td><td align="center" valign="bottom"> '. |
'<img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>'. |
'<img src="/adm/lonMisc/feedback.gif"> '.&mt('New message (click to open)').'<p>'. |
'</td>'; |
'</td>'; |
} else { |
} else { |
$result .= '<td align="center" valign="bottom"> '. |
$result .= '<td align="center" valign="bottom"> '. |
'<img src="/adm/lonMisc/chat.gif"> Discussions</td><td align="center" valign="bottom">'. |
'<img src="/adm/lonMisc/chat.gif"> '.&mt('Discussions').'</td><td align="center" valign="bottom">'. |
' <img src="/adm/lonMisc/feedback.gif"> New message (click to open)'. |
' <img src="/adm/lonMisc/feedback.gif"> '.&mt('New message (click to open)'). |
'</td>'; |
'</td>'; |
} |
} |
|
|
Line 1344 sub render {
|
Line 1336 sub render {
|
if ($condition) { |
if ($condition) { |
$result.="<a href=\"navmaps?condition=0&filter=&$queryString" . |
$result.="<a href=\"navmaps?condition=0&filter=&$queryString" . |
"&here=" . Apache::lonnet::escape($here) . |
"&here=" . Apache::lonnet::escape($here) . |
"\">Close All Folders</a>"; |
"\">".&mt('Close All Folders')."</a>"; |
} else { |
} else { |
$result.="<a href=\"navmaps?condition=1&filter=&$queryString" . |
$result.="<a href=\"navmaps?condition=1&filter=&$queryString" . |
"&here=" . Apache::lonnet::escape($here) . |
"&here=" . Apache::lonnet::escape($here) . |
"\">Open All Folders</a>"; |
"\">".&mt('Open All Folders')."</a>"; |
} |
} |
$result .= "<br /><br />\n"; |
$result .= "<br /><br />\n"; |
} |
} |
Line 1581 sub render {
|
Line 1573 sub render {
|
# If we have the connection, make sure the user is still connected |
# If we have the connection, make sure the user is still connected |
my $c = $r->connection; |
my $c = $r->connection; |
if ($c->aborted()) { |
if ($c->aborted()) { |
Apache::lonnet::logthis("navmaps aborted"); |
|
# Who cares what we do, nobody will see it anyhow. |
# Who cares what we do, nobody will see it anyhow. |
return ''; |
return ''; |
} |
} |
Line 1972 sub getById {
|
Line 1963 sub getById {
|
sub getBySymb { |
sub getBySymb { |
my $self = shift; |
my $self = shift; |
my $symb = shift; |
my $symb = shift; |
my ($mapUrl, $id, $filename) = split (/___/, $symb); |
my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb); |
my $map = $self->getResourceByUrl($mapUrl); |
my $map = $self->getResourceByUrl($mapUrl); |
return $self->getById($map->map_pc() . '.' . $id); |
return $self->getById($map->map_pc() . '.' . $id); |
} |
} |
Line 2098 sub parmval_real {
|
Line 2089 sub parmval_real {
|
|
|
# ----------------------------------------------------- fourth , check default |
# ----------------------------------------------------- fourth , check default |
|
|
my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default'); |
my $meta_rwhat=$rwhat; |
|
$meta_rwhat=~s/\./_/g; |
|
my $default=&Apache::lonnet::metadata($fn,$meta_rwhat); |
|
if (defined($default)) { return $default} |
|
$default=&Apache::lonnet::metadata($fn,'parameter_'.$meta_rwhat); |
if (defined($default)) { return $default} |
if (defined($default)) { return $default} |
|
|
# --------------------------------------------------- fifth , cascade up parts |
# --------------------------------------------------- fifth , cascade up parts |
Line 2341 consisting entirely of empty resources e
|
Line 2336 consisting entirely of empty resources e
|
ending resource, will cause a lot of BRANCH_STARTs and BRANCH_ENDs, |
ending resource, will cause a lot of BRANCH_STARTs and BRANCH_ENDs, |
but only one resource will be returned. |
but only one resource will be returned. |
|
|
|
=back |
|
|
=head2 Normal Usage |
=head2 Normal Usage |
|
|
Normal usage of the iterator object is to do the following: |
Normal usage of the iterator object is to do the following: |
Line 2361 the depth of the iterator to see when it
|
Line 2358 the depth of the iterator to see when it
|
code. It is difficult to get right and harder to understand then |
code. It is difficult to get right and harder to understand then |
this. They should be migrated to this new style. |
this. They should be migrated to this new style. |
|
|
=back |
|
|
|
=cut |
=cut |
|
|
# Here are the tokens for the iterator: |
# Here are the tokens for the iterator: |
Line 3363 sub opendate {
|
Line 3358 sub opendate {
|
} |
} |
sub problemstatus { |
sub problemstatus { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
return $self->parmval("problemstatus", $part); |
return lc $self->parmval("problemstatus", $part); |
} |
} |
sub sig { |
sub sig { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
Line 3541 sub responseType {
|
Line 3536 sub responseType {
|
my $part = shift; |
my $part = shift; |
|
|
$self->extractParts(); |
$self->extractParts(); |
return $self->{RESPONSE_TYPES}->{$part}; |
if (defined($self->{RESPONSE_TYPES}->{$part})) { |
|
return @{$self->{RESPONSE_TYPES}->{$part}}; |
|
} else { |
|
return undef; |
|
} |
} |
} |
|
|
sub responseIds { |
sub responseIds { |
Line 3549 sub responseIds {
|
Line 3548 sub responseIds {
|
my $part = shift; |
my $part = shift; |
|
|
$self->extractParts(); |
$self->extractParts(); |
return $self->{RESPONSE_IDS}->{$part}; |
if (defined($self->{RESPONSE_IDS}->{$part})) { |
|
return @{$self->{RESPONSE_IDS}->{$part}}; |
|
} else { |
|
return undef; |
|
} |
} |
} |
|
|
# Private function: Extracts the parts information, both part names and |
# Private function: Extracts the parts information, both part names and |
Line 3566 sub extractParts {
|
Line 3569 sub extractParts {
|
|
|
# Retrieve part count, if this is a problem |
# Retrieve part count, if this is a problem |
if ($self->is_problem()) { |
if ($self->is_problem()) { |
|
my $partorder = &Apache::lonnet::metadata($self->src(), 'partorder'); |
my $metadata = &Apache::lonnet::metadata($self->src(), 'packages'); |
my $metadata = &Apache::lonnet::metadata($self->src(), 'packages'); |
if (!$metadata) { |
|
$self->{RESOURCE_ERROR} = 1; |
|
$self->{PARTS} = []; |
|
$self->{PART_TYPE} = {}; |
|
return; |
|
} |
|
foreach (split(/\,/,$metadata)) { |
|
if ($_ =~ /^part_(.*)$/) { |
|
my $part = $1; |
|
# This floods the logs if it blows up |
|
if (defined($parts{$part})) { |
|
Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb()); |
|
} |
|
|
|
# check to see if part is turned off. |
if ($partorder) { |
|
my @parts; |
if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) { |
for my $part (split (/,/,$partorder)) { |
$parts{$part} = 1; |
if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) { |
} |
push @parts, $part; |
} |
$parts{$part} = 1; |
|
} |
|
} |
|
$self->{PARTS} = \@parts; |
|
} else { |
|
if (!$metadata) { |
|
$self->{RESOURCE_ERROR} = 1; |
|
$self->{PARTS} = []; |
|
$self->{PART_TYPE} = {}; |
|
return; |
|
} |
|
foreach (split(/\,/,$metadata)) { |
|
if ($_ =~ /^part_(.*)$/) { |
|
my $part = $1; |
|
# This floods the logs if it blows up |
|
if (defined($parts{$part})) { |
|
&Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb()); |
|
} |
|
|
|
# check to see if part is turned off. |
|
|
|
if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) { |
|
$parts{$part} = 1; |
|
} |
|
} |
|
} |
|
my @sortedParts = sort keys %parts; |
|
$self->{PARTS} = \@sortedParts; |
} |
} |
|
|
|
|
my @sortedParts = sort keys %parts; |
|
$self->{PARTS} = \@sortedParts; |
|
|
|
my %responseIdHash; |
my %responseIdHash; |
my %responseTypeHash; |
my %responseTypeHash; |
Line 3603 sub extractParts {
|
Line 3618 sub extractParts {
|
} |
} |
|
|
# Now, the unfortunate thing about this is that parts, part name, and |
# Now, the unfortunate thing about this is that parts, part name, and |
# response if are delimited by underscores, but both the part |
# response id are delimited by underscores, but both the part |
# name and response id can themselves have underscores in them. |
# name and response id can themselves have underscores in them. |
# So we have to use our knowlege of part names to figure out |
# So we have to use our knowlege of part names to figure out |
# where the part names begin and end, and even then, it is possible |
# where the part names begin and end, and even then, it is possible |
Line 3615 sub extractParts {
|
Line 3630 sub extractParts {
|
my $partIdSoFar = ''; |
my $partIdSoFar = ''; |
my @partChunks = split /_/, $partStuff; |
my @partChunks = split /_/, $partStuff; |
my $i = 0; |
my $i = 0; |
|
|
for ($i = 0; $i < scalar(@partChunks); $i++) { |
for ($i = 0; $i < scalar(@partChunks); $i++) { |
if ($partIdSoFar) { $partIdSoFar .= '_'; } |
if ($partIdSoFar) { $partIdSoFar .= '_'; } |
$partIdSoFar .= $partChunks[$i]; |
$partIdSoFar .= $partChunks[$i]; |
Line 3623 sub extractParts {
|
Line 3637 sub extractParts {
|
my @otherChunks = @partChunks[$i+1..$#partChunks]; |
my @otherChunks = @partChunks[$i+1..$#partChunks]; |
my $responseId = join('_', @otherChunks); |
my $responseId = join('_', @otherChunks); |
push @{$responseIdHash{$partIdSoFar}}, $responseId; |
push @{$responseIdHash{$partIdSoFar}}, $responseId; |
$responseTypeHash{$partIdSoFar} = $responseType; |
push @{$responseTypeHash{$partIdSoFar}}, $responseType; |
last; |
|
} |
} |
} |
} |
} |
} |
} |
} |
|
|
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
} |
} |
Line 3942 sub status {
|
Line 3954 sub status {
|
#if ($self->{RESOURCE_ERROR}) { return NETWORK_FAILURE; } |
#if ($self->{RESOURCE_ERROR}) { return NETWORK_FAILURE; } |
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; } |
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; } |
|
|
my $suppressFeedback = lc($self->parmval("problemstatus", $part)) eq 'no'; |
my $suppressFeedback = $self->problemstatus($part) eq 'no'; |
|
# If there's an answer date and we're past it, don't |
|
# suppress the feedback; student should know |
|
if ($self->answerdate($part) && $self->answerdate($part) < time()) { |
|
$suppressFeedback = 0; |
|
} |
|
|
# There are a few whole rows we can dispose of: |
# There are a few whole rows we can dispose of: |
if ($completionStatus == CORRECT || |
if ($completionStatus == CORRECT || |