version 1.226, 2003/09/09 18:46:28
|
version 1.265, 2004/07/03 20:45:23
|
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 150 sub real_handler {
|
Line 137 sub real_handler {
|
$r->print('</head>'. |
$r->print('</head>'. |
&Apache::loncommon::bodytag('Navigate Course Contents','', |
&Apache::loncommon::bodytag('Navigate Course Contents','', |
$addentries,'','',$ENV{'form.register'})); |
$addentries,'','',$ENV{'form.register'})); |
$r->print('<script>window.focus();</script>'); |
$r->print('<script>window.focus();</script>'. |
|
&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT')); |
|
|
$r->rflush(); |
$r->rflush(); |
|
|
# Check that it's defined |
# Check that it's defined |
Line 221 sub real_handler {
|
Line 209 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 224 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 249 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 303 sub getLinkForResource {
|
Line 291 sub getLinkForResource {
|
|
|
# Check to see if there are any pages in the stack |
# Check to see if there are any pages in the stack |
foreach $res (@$stack) { |
foreach $res (@$stack) { |
if (defined($res) && $res->is_page()) { |
if (defined($res)) { |
return $res->src(); |
if ($res->is_page()) { |
|
return $res->src(); |
|
} |
|
# in case folder was skipped over as "only sequence" |
|
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); |
|
if ($map=~/\.page$/) { |
|
return &Apache::lonnet::clutter($map).'#'. |
|
&Apache::lonnet::escape(&Apache::lonnet::declutter($src)); |
|
} |
} |
} |
} |
} |
|
|
Line 319 sub getLinkForResource {
|
Line 315 sub getLinkForResource {
|
return $res->src(); |
return $res->src(); |
} |
} |
|
|
# Convenience function: This seperates the logic of how to create |
# Convenience function: This separates the logic of how to create |
# the problem text strings ("Due: DATE", "Open: DATE", "Not yet assigned", |
# the problem text strings ("Due: DATE", "Open: DATE", "Not yet assigned", |
# etc.) into a seperate function. It takes a resource object as the |
# etc.) into a separate function. It takes a resource object as the |
# first parameter, and the part number of the resource as the second. |
# first parameter, and the part number of the resource as the second. |
# It's basically a big switch statement on the status of the resource. |
# It's basically a big switch statement on the status of the resource. |
|
|
Line 331 sub getDescription {
|
Line 327 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 367 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'); |
} |
} |
} |
} |
|
|
# Convenience function, so others can use it: Is the problem due in less then |
# Convenience function, so others can use it: Is the problem due in less then |
# 24 hours, and still can be done? |
# 24 hours, and still can be done? |
|
|
sub dueInLessThen24Hours { |
sub dueInLessThan24Hours { |
my $res = shift; |
my $res = shift; |
my $part = shift; |
my $part = shift; |
my $status = $res->status($part); |
my $status = $res->status($part); |
|
|
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 402 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 425 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 497 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 507 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 867 sub render_resource {
|
Line 865 sub render_resource {
|
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
|
|
my $title = $resource->compTitle(); |
my $title = $resource->compTitle(); |
if ($src =~ /^\/uploaded\//) { |
|
$nonLinkedText=$title; |
|
$title = ''; |
|
} |
|
my $partLabel = ""; |
my $partLabel = ""; |
my $newBranchText = ""; |
my $newBranchText = ""; |
|
|
Line 893 sub render_resource {
|
Line 888 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 959 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 976 sub render_resource {
|
Line 971 sub render_resource {
|
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
} |
} |
|
|
if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// && |
if (!$params->{'resource_nolink'} && !$resource->is_sequence()) { |
!$resource->is_sequence()) { |
|
$result .= " $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>"; |
$result .= " $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>"; |
} else { |
} else { |
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>"; |
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>"; |
Line 1014 sub render_communication_status {
|
Line 1008 sub render_communication_status {
|
|
|
if ($resource->getErrors()) { |
if ($resource->getErrors()) { |
my $errors = $resource->getErrors(); |
my $errors = $resource->getErrors(); |
|
my $errorcount = 0; |
foreach (split(/,/, $errors)) { |
foreach (split(/,/, $errors)) { |
|
last if ($errorcount>=10); # Only output 10 bombs maximum |
if ($_) { |
if ($_) { |
|
$errorcount++; |
$errorHTML .= ' <a href="/adm/email?display=' |
$errorHTML .= ' <a href="/adm/email?display=' |
. &Apache::lonnet::escape($_) . '">' |
. &Apache::lonnet::escape($_) . '">' |
. '<img src="/adm/lonMisc/bomb.gif" ' |
. '<img src="/adm/lonMisc/bomb.gif" ' |
Line 1067 sub render_long_status {
|
Line 1064 sub render_long_status {
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
$color = $colormap{$resource->status}; |
$color = $colormap{$resource->status}; |
|
|
if (dueInLessThen24Hours($resource, $part) || |
if (dueInLessThan24Hours($resource, $part) || |
lastTry($resource, $part)) { |
lastTry($resource, $part)) { |
$color = $hurryUpColor; |
$color = $hurryUpColor; |
} |
} |
Line 1093 sub render_long_status {
|
Line 1090 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 1116 my @statuses = ($resObj->CORRECT, $resOb
|
Line 1116 my @statuses = ($resObj->CORRECT, $resOb
|
use Data::Dumper; |
use Data::Dumper; |
sub render_parts_summary_status { |
sub render_parts_summary_status { |
my ($resource, $part, $params) = @_; |
my ($resource, $part, $params) = @_; |
if (!$resource->is_problem()) { return '<td></td>'; } |
if (!$resource->is_problem() && !$resource->contains_problem) { return '<td></td>'; } |
if ($params->{showParts}) { |
if ($params->{showParts}) { |
return '<td></td>'; |
return '<td></td>'; |
} |
} |
|
|
my $td = "<td align='right'>\n"; |
my $td = "<td align='right'>\n"; |
my $endtd = "</td>\n"; |
my $endtd = "</td>\n"; |
|
my @probs; |
|
|
# If there is a single part, just show the simple status |
if ($resource->contains_problem) { |
if ($resource->singlepart()) { |
@probs=$resource->retrieveResources($resource,sub { $_[0]->is_problem() },1,0); |
my $status = $resource->simpleStatus('0'); |
} else { |
return $td . "<font color='" . $statusColors{$status} . "'>" |
@probs=($resource); |
. $statusStrings{$status} . "</font>" . $endtd; |
} |
} |
my $return; |
|
my %overallstatus; |
# Now we can be sure the $part doesn't really matter. |
my $totalParts; |
my $statusCount = $resource->simpleStatusCount(); |
foreach my $resource (@probs) { |
my @counts; |
# If there is a single part, just show the simple status |
foreach my $status(@statuses) { |
if ($resource->singlepart()) { |
# decouple display order from the simpleStatusCount order |
my $status = $resource->simpleStatus(${$resource->parts}[0]); |
my $slot = Apache::lonnavmaps::resource::statusToSlot($status); |
$overallstatus{$status}++; |
if ($statusCount->[$slot]) { |
$totalParts++; |
push @counts, "<font color='" . $statusColors{$status} . |
next; |
"'>" . $statusCount->[$slot] . ' ' |
} |
|
# Now we can be sure the $part doesn't really matter. |
|
my $statusCount = $resource->simpleStatusCount(); |
|
my @counts; |
|
foreach my $status (@statuses) { |
|
# decouple display order from the simpleStatusCount order |
|
my $slot = Apache::lonnavmaps::resource::statusToSlot($status); |
|
if ($statusCount->[$slot]) { |
|
$overallstatus{$status}+=$statusCount->[$slot]; |
|
$totalParts+=$statusCount->[$slot]; |
|
} |
|
} |
|
} |
|
$return.= $td . $totalParts . ' parts: '; |
|
foreach my $status (@statuses) { |
|
if ($overallstatus{$status}) { |
|
$return.="<font color='" . $statusColors{$status} . |
|
"'>" . $overallstatus{$status} . ' ' |
. $statusStrings{$status} . "</font>"; |
. $statusStrings{$status} . "</font>"; |
} |
} |
} |
} |
|
$return.= $endtd; |
return $td . join (', ', @counts) . $endtd; |
return $return; |
} |
} |
|
|
my @preparedColumns = (\&render_resource, \&render_communication_status, |
my @preparedColumns = (\&render_resource, \&render_communication_status, |
Line 1179 sub render {
|
Line 1197 sub render {
|
my $jump = $args->{'jump'}; |
my $jump = $args->{'jump'}; |
my $here = $args->{'here'}; |
my $here = $args->{'here'}; |
my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0); |
my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0); |
|
my $closeAllPages = setDefault($args->{'closeAllPages'}, 0); |
my $currentJumpDelta = 2; # change this to change how many resources are displayed |
my $currentJumpDelta = 2; # change this to change how many resources are displayed |
# before the current resource when using #current |
# before the current resource when using #current |
|
|
Line 1287 sub render {
|
Line 1306 sub render {
|
$args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition); |
$args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition); |
} |
} |
} |
} |
|
|
# (re-)Locate the jump point, if any |
# (re-)Locate the jump point, if any |
# Note this does not take filtering or hidden into account... need |
# Note this does not take filtering or hidden into account... need |
# to be fixed? |
# to be fixed? |
Line 1325 sub render {
|
Line 1344 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 1363 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 1424 sub render {
|
Line 1443 sub render {
|
$args->{'here'} = $here; |
$args->{'here'} = $here; |
|
|
$args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0 |
$args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0 |
while ($curRes = $it->next()) { |
while ($curRes = $it->next($closeAllPages)) { |
# Maintain indentation level. |
# Maintain indentation level. |
if ($curRes == $it->BEGIN_MAP() || |
if ($curRes == $it->BEGIN_MAP() || |
$curRes == $it->BEGIN_BRANCH() ) { |
$curRes == $it->BEGIN_BRANCH() ) { |
Line 1540 sub render {
|
Line 1559 sub render {
|
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
my $stack = $it->getStack(); |
my $stack = $it->getStack(); |
my $src = getLinkForResource($stack); |
my $src = getLinkForResource($stack); |
|
my $anchor=''; |
|
if ($src=~s/(\#.*$)//) { |
|
$anchor=$1; |
|
} |
my $srcHasQuestion = $src =~ /\?/; |
my $srcHasQuestion = $src =~ /\?/; |
$args->{"resourceLink"} = $src. |
$args->{"resourceLink"} = $src. |
($srcHasQuestion?'&':'?') . |
($srcHasQuestion?'&':'?') . |
'symb=' . &Apache::lonnet::escape($curRes->symb()); |
'symb=' . &Apache::lonnet::escape($curRes->symb()). |
|
$anchor; |
|
|
# Now, display each column. |
# Now, display each column. |
foreach my $col (@$cols) { |
foreach my $col (@$cols) { |
Line 1581 sub render {
|
Line 1604 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 1596 sub render {
|
Line 1618 sub render {
|
# it's quite likely this might fix other browsers, too, and |
# it's quite likely this might fix other browsers, too, and |
# certainly won't hurt anything. |
# certainly won't hurt anything. |
if ($displayedJumpMarker) { |
if ($displayedJumpMarker) { |
$result .= "<script>setTimeout(\"location += '#curloc';\", 0)</script>\n"; |
$result .= " |
|
<script> |
|
if (location.href.indexOf('#curloc')==-1) { |
|
setTimeout(\"location += '#curloc';\", 0) |
|
} |
|
</script>"; |
} |
} |
|
|
$result .= "</table>"; |
$result .= "</table>"; |
Line 1787 sub generate_course_user_opt {
|
Line 1814 sub generate_course_user_opt {
|
|
|
sub generate_email_discuss_status { |
sub generate_email_discuss_status { |
my $self = shift; |
my $self = shift; |
|
my $symb = shift; |
if ($self->{EMAIL_DISCUSS_GENERATED}) { return; } |
if ($self->{EMAIL_DISCUSS_GENERATED}) { return; } |
|
|
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
Line 1799 sub generate_email_discuss_status {
|
Line 1827 sub generate_email_discuss_status {
|
$courseLeaveTime : $logoutTime); |
$courseLeaveTime : $logoutTime); |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
$cdom, $cnum); |
$cdom, $cnum); |
|
my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss', |
|
$ENV{'user.domain'},$ENV{'user.name'},'lastread'); |
|
my %lastreadtime = (); |
|
foreach (keys %lastread) { |
|
my $key = $_; |
|
$key =~ s/_lastread$//; |
|
$lastreadtime{$key} = $lastread{$_}; |
|
} |
|
|
my %feedback=(); |
my %feedback=(); |
my %error=(); |
my %error=(); |
my $keys = &Apache::lonnet::reply('keys:'. |
my $keys = &Apache::lonnet::reply('keys:'. |
Line 1832 sub generate_email_discuss_status {
|
Line 1869 sub generate_email_discuss_status {
|
$self->{ERROR_MSG} = \%error; # what is this? JB |
$self->{ERROR_MSG} = \%error; # what is this? JB |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{EMAIL_STATUS} = \%emailstatus; |
$self->{EMAIL_STATUS} = \%emailstatus; |
|
$self->{LAST_READ} = \%lastreadtime; |
|
|
$self->{EMAIL_DISCUSS_GENERATED} = 1; |
$self->{EMAIL_DISCUSS_GENERATED} = 1; |
} |
} |
Line 1900 sub hasDiscussion {
|
Line 1938 sub hasDiscussion {
|
if (!defined($self->{DISCUSSION_TIME})) { return 0; } |
if (!defined($self->{DISCUSSION_TIME})) { return 0; } |
|
|
#return defined($self->{DISCUSSION_TIME}->{$symb}); |
#return defined($self->{DISCUSSION_TIME}->{$symb}); |
return $self->{DISCUSSION_TIME}->{$symb} > |
|
$self->{LAST_CHECK}; |
# backward compatibility (bulletin boards used to be 'wrapped') |
|
my $ressymb = $symb; |
|
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { |
|
unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) { |
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
|
} |
|
} |
|
|
|
if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) { |
|
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb}; |
|
} else { |
|
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_CHECK}; |
|
} |
} |
} |
|
|
# Private method: Does the given resource (as a symb string) have |
# Private method: Does the given resource (as a symb string) have |
Line 1972 sub getById {
|
Line 2022 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 2148 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 2153 want to know is if I<any> resources matc
|
Line 2207 want to know is if I<any> resources matc
|
parameter will allow you to avoid potentially expensive enumeration of |
parameter will allow you to avoid potentially expensive enumeration of |
all matching resources. |
all matching resources. |
|
|
=item * B<hasResources>(map, filterFunc, recursive): |
=item * B<hasResource>(map, filterFunc, recursive): |
|
|
Convience method for |
Convience method for |
|
|
Line 2341 consisting entirely of empty resources e
|
Line 2395 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 2417 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 2499 sub new {
|
Line 2553 sub new {
|
} |
} |
|
|
# Check: Was this only one resource, a map? |
# Check: Was this only one resource, a map? |
if ($resourceCount == 1 && $resource->is_map() && !$self->{FORCE_TOP}) { |
if ($resourceCount == 1 && $resource->is_sequence() && !$self->{FORCE_TOP}) { |
my $firstResource = $resource->map_start(); |
my $firstResource = $resource->map_start(); |
my $finishResource = $resource->map_finish(); |
my $finishResource = $resource->map_finish(); |
return |
return |
Line 2532 sub new {
|
Line 2586 sub new {
|
|
|
sub next { |
sub next { |
my $self = shift; |
my $self = shift; |
|
my $closeAllPages=shift; |
if ($self->{FINISHED}) { |
if ($self->{FINISHED}) { |
return END_ITERATOR(); |
return END_ITERATOR(); |
} |
} |
Line 2546 sub next {
|
Line 2600 sub next {
|
|
|
if ($self->{RECURSIVE_ITERATOR_FLAG}) { |
if ($self->{RECURSIVE_ITERATOR_FLAG}) { |
# grab the next from the recursive iterator |
# grab the next from the recursive iterator |
my $next = $self->{RECURSIVE_ITERATOR}->next(); |
my $next = $self->{RECURSIVE_ITERATOR}->next($closeAllPages); |
|
|
# is it a begin or end map? If so, update the depth |
# is it a begin or end map? If so, update the depth |
if ($next == BEGIN_MAP() ) { $self->{RECURSIVE_DEPTH}++; } |
if ($next == BEGIN_MAP() ) { $self->{RECURSIVE_DEPTH}++; } |
Line 2660 sub next {
|
Line 2714 sub next {
|
|
|
# That ends the main iterator logic. Now, do we want to recurse |
# That ends the main iterator logic. Now, do we want to recurse |
# down this map (if this resource is a map)? |
# down this map (if this resource is a map)? |
if ($self->{HERE}->is_map() && |
if ( ($self->{HERE}->is_sequence() || (!$closeAllPages && $self->{HERE}->is_page())) && |
(defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { |
(defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { |
$self->{RECURSIVE_ITERATOR_FLAG} = 1; |
$self->{RECURSIVE_ITERATOR_FLAG} = 1; |
my $firstResource = $self->{HERE}->map_start(); |
my $firstResource = $self->{HERE}->map_start(); |
Line 2678 sub next {
|
Line 2732 sub next {
|
my $browsePriv = $self->{HERE}->browsePriv(); |
my $browsePriv = $self->{HERE}->browsePriv(); |
if (!$self->{HERE}->src() || |
if (!$self->{HERE}->src() || |
(!($browsePriv eq 'F') && !($browsePriv eq '2')) ) { |
(!($browsePriv eq 'F') && !($browsePriv eq '2')) ) { |
return $self->next(); |
return $self->next($closeAllPages); |
} |
} |
|
|
return $self->{HERE}; |
return $self->{HERE}; |
Line 2730 package Apache::lonnavmaps::DFSiterator;
|
Line 2784 package Apache::lonnavmaps::DFSiterator;
|
# useful for pre-processing of some kind, and is in fact used by the main |
# useful for pre-processing of some kind, and is in fact used by the main |
# iterator that way, but that's about it. |
# iterator that way, but that's about it. |
# One could imagine merging this into the init routine of the main iterator, |
# One could imagine merging this into the init routine of the main iterator, |
# but this might as well be left seperate, since it is possible some other |
# but this might as well be left separate, since it is possible some other |
# use might be found for it. - Jeremy |
# use might be found for it. - Jeremy |
|
|
# Unlike the main iterator, this DOES return all resources, even blank ones. |
# Unlike the main iterator, this DOES return all resources, even blank ones. |
Line 3147 Returns true if the resource is a sequen
|
Line 3201 Returns true if the resource is a sequen
|
|
|
=cut |
=cut |
|
|
|
sub hasResource { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->hasResource(@_); |
|
} |
|
|
|
sub retrieveResources { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->retrieveResources(@_); |
|
} |
|
|
sub is_html { |
sub is_html { |
my $self=shift; |
my $self=shift; |
Line 3163 sub is_page {
|
Line 3226 sub is_page {
|
sub is_problem { |
sub is_problem { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
return ($src =~ /problem$/); |
return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library)$/) |
|
} |
|
sub contains_problem { |
|
my $self=shift; |
|
if ($self->is_page()) { |
|
my $hasProblem=$self->hasResource($self,sub { $_[0]->is_problem() },1); |
|
return $hasProblem; |
|
} |
|
return 0; |
} |
} |
sub is_sequence { |
sub is_sequence { |
my $self=shift; |
my $self=shift; |
Line 3171 sub is_sequence {
|
Line 3242 sub is_sequence {
|
return $self->navHash("is_map_", 1) && |
return $self->navHash("is_map_", 1) && |
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; |
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; |
} |
} |
|
sub is_survey { |
|
my $self = shift(); |
|
my $part = shift(); |
|
if ($self->parmval('type',$part) eq 'survey') { |
|
return 1; |
|
} |
|
if ($self->src() =~ /\.(survey)$/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
# Private method: Shells out to the parmval in the nav map, handler parts. |
# Private method: Shells out to the parmval in the nav map, handler parts. |
sub parmval { |
sub parmval { |
Line 3347 sub awarded {
|
Line 3429 sub awarded {
|
} |
} |
sub duedate { |
sub duedate { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
|
my $interval=$self->parmval("interval", $part); |
|
if ($interval) { |
|
my $first_access=&Apache::lonnet::get_first_access('map',$self->symb); |
|
if ($first_access) { return ($first_access+$interval); } |
|
} |
return $self->parmval("duedate", $part); |
return $self->parmval("duedate", $part); |
} |
} |
sub maxtries { |
sub maxtries { |
Line 3363 sub opendate {
|
Line 3450 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 3628 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 3640 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 3661 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 3710 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 3722 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 3729 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; |
|
} |
} |
} |
} |
} |
} |
} |
} |
|
my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder'); |
|
if ($resorder) { |
|
my @resorder=split(/,/,$resorder); |
|
foreach my $part (keys(%responseIdHash)) { |
|
my %resids = map { ($_,1) } @{ $responseIdHash{$part} }; |
|
my @neworder; |
|
foreach my $possibleid (@resorder) { |
|
if (exists($resids{$possibleid})) { |
|
push(@neworder,$possibleid); |
|
} |
|
} |
|
$responseIdHash{$part}=\@neworder; |
|
} |
|
} |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
} |
} |
Line 3821 sub getCompletionStatus {
|
Line 3939 sub getCompletionStatus {
|
|
|
my $status = $self->queryRestoreHash('solved', shift); |
my $status = $self->queryRestoreHash('solved', shift); |
|
|
# Left as seperate if statements in case we ever do more with this |
# Left as separate if statements in case we ever do more with this |
if ($status eq 'correct_by_student') {return $self->CORRECT;} |
if ($status eq 'correct_by_student') {return $self->CORRECT;} |
if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; } |
if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; } |
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |
Line 3942 sub status {
|
Line 4060 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 || |