version 1.298, 2004/09/29 19:13:20
|
version 1.398, 2007/04/27 17:59:50
|
Line 30
|
Line 30
|
package Apache::lonnavmaps; |
package Apache::lonnavmaps; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use GDBM_File; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmenu(); |
use Apache::lonenc(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonnet; |
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 |
|
use Time::HiRes qw( gettimeofday tv_interval ); |
|
use LONCAPA; |
|
|
# symbolic constants |
# symbolic constants |
sub SYMB { return 1; } |
sub SYMB { return 1; } |
Line 53 my %statusIconMap =
|
Line 56 my %statusIconMap =
|
$resObj->CLOSED => '', |
$resObj->CLOSED => '', |
$resObj->OPEN => 'navmap.open.gif', |
$resObj->OPEN => 'navmap.open.gif', |
$resObj->CORRECT => 'navmap.correct.gif', |
$resObj->CORRECT => 'navmap.correct.gif', |
|
$resObj->PARTIALLY_CORRECT => 'navmap.partial.gif', |
$resObj->INCORRECT => 'navmap.wrong.gif', |
$resObj->INCORRECT => 'navmap.wrong.gif', |
$resObj->ATTEMPTED => 'navmap.ellipsis.gif', |
$resObj->ATTEMPTED => 'navmap.ellipsis.gif', |
$resObj->ERROR => '' |
$resObj->ERROR => '' |
Line 77 my %colormap =
|
Line 81 my %colormap =
|
$resObj->OPEN => '', |
$resObj->OPEN => '', |
$resObj->NOTHING_SET => '', |
$resObj->NOTHING_SET => '', |
$resObj->ATTEMPTED => '', |
$resObj->ATTEMPTED => '', |
$resObj->ANSWER_SUBMITTED => '' |
$resObj->ANSWER_SUBMITTED => '', |
|
$resObj->PARTIALLY_CORRECT => '#006600' |
); |
); |
# And a special case in the nav map; what to do when the assignment |
# And a special case in the nav map; what to do when the assignment |
# is not yet done and due in less then 24 hours |
# is not yet done and due in less than 24 hours |
my $hurryUpColor = "#FF0000"; |
my $hurryUpColor = "#FF0000"; |
|
|
sub launch_win { |
|
my ($mode,$script,$toplinkitems)=@_; |
|
my $result; |
|
if ($script ne 'no') { |
|
$result.='<script type="text/javascript">'; |
|
} |
|
$result.='function launch_navmapwin() { |
|
newWindow=open(\'/adm/navmaps?launchExternal\',\'loncapanav\',\'width=400,height=600,scrollbars=1\'); |
|
}'; |
|
if ($mode eq 'now') { |
|
$result.="\nlaunch_navmapwin();\n"; |
|
} |
|
if ($script ne 'no') { |
|
$result.='</script>'; |
|
} |
|
if ($mode eq 'link') { |
|
&add_linkitem($toplinkitems,'launchnav','launch_navmapwin()', |
|
"Launch navigation window"); |
|
} |
|
return $result; |
|
} |
|
|
|
sub close { |
sub close { |
if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; } |
if ($env{'environment.remotenavmap'} ne 'on') { return ''; } |
return(<<ENDCLOSE); |
return(<<ENDCLOSE); |
<script type="text/javascript"> |
<script type="text/javascript"> |
window.status='Accessing Nav Control'; |
window.status='Accessing Nav Control'; |
Line 119 window.status='Done.';
|
Line 102 window.status='Done.';
|
ENDCLOSE |
ENDCLOSE |
} |
} |
|
|
sub nav_control_js { |
|
my $nav=($ENV{'environment.remotenavmap'} eq 'on'); |
|
return (<<NAVCONTROL); |
|
var w_loncapanav_flag="$nav"; |
|
|
|
|
|
function gonav(url) { |
|
if (w_loncapanav_flag != 1) { |
|
gopost(url,''); |
|
} else { |
|
navwindow=window.open(url, |
|
"loncapanav","height=600,width=400,scrollbars=1"); |
|
} |
|
} |
|
NAVCONTROL |
|
} |
|
|
|
sub update { |
sub update { |
if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; } |
if ($env{'environment.remotenavmap'} ne 'on') { return ''; } |
if (!$ENV{'request.course.id'}) { return ''; } |
if (!$env{'request.course.id'}) { return ''; } |
if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; } |
if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; } |
return(<<ENDUPDATE); |
return(<<ENDUPDATE); |
<form name="navform"></form> |
<form name="navform"></form> |
Line 150 this.document.navform.submit();
|
Line 116 this.document.navform.submit();
|
ENDUPDATE |
ENDUPDATE |
} |
} |
|
|
sub handler { |
|
my $r = shift; |
|
real_handler($r); |
|
} |
|
|
|
sub real_handler { |
|
my $r = shift; |
|
|
|
# Handle header-only request |
|
if ($r->header_only) { |
|
if ($ENV{'browser.mathml'}) { |
|
&Apache::loncommon::content_type($r,'text/xml'); |
|
} else { |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
} |
|
$r->send_http_header; |
|
return OK; |
|
} |
|
|
|
# Send header, don't cache this page |
|
if ($ENV{'browser.mathml'}) { |
|
&Apache::loncommon::content_type($r,'text/xml'); |
|
} else { |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
} |
|
&Apache::loncommon::no_cache($r); |
|
$r->send_http_header; |
|
|
|
my %toplinkitems=(); |
|
|
|
if ($ENV{QUERY_STRING} eq 'collapseExternal') { |
|
&Apache::lonnet::put('environment',{'remotenavmap' => 'off'}); |
|
&Apache::lonnet::appenv('environment.remotenavmap' => 'off'); |
|
my $menu=&Apache::lonmenu::reopenmenu(); |
|
my $navstatus=&Apache::lonmenu::get_nav_status(); |
|
if ($menu) { |
|
$menu=(<<MENU) |
|
swmenu=$menu |
|
swmenu.clearTimeout(swmenu.menucltim); |
|
$navstatus |
|
MENU |
|
} else { |
|
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
|
my $mainwindow='window.open('.$nothing.',"loncapaclient","",false);'; |
|
$menu=(<<MENU) |
|
swmenu=$mainwindow |
|
$navstatus |
|
MENU |
|
} |
|
$r->print(<<"ENDSUBM"); |
|
<html> |
|
<head> |
|
<script type="text/javascript"> |
|
function submitthis() { |
|
$menu |
|
self.close(); |
|
} |
|
|
|
</script> |
|
</head> |
|
<body bgcolor="#FFFFFF" onLoad="submitthis()"></body> |
|
</html> |
|
ENDSUBM |
|
return; |
|
} |
|
if ($ENV{QUERY_STRING} eq 'launchExternal') { |
|
&Apache::lonnet::put('environment',{'remotenavmap' => 'on'}); |
|
&Apache::lonnet::appenv('environment.remotenavmap' => 'on'); |
|
} |
|
|
|
# Create the nav map |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
|
|
if (!defined($navmap)) { |
|
my $requrl = $r->uri; |
|
$ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
$r->print("<html><head>\n"); |
|
$r->print("<title>".&mt('Navigate Course Contents')."</title>"); |
|
# ------------------------------------------------------------ Get query string |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework']); |
|
|
|
# ----------------------------------------------------- Force menu registration |
|
my $addentries=''; |
|
my $more_unload; |
|
my $body_only=''; |
|
if ($ENV{'environment.remotenavmap'} eq 'on') { |
|
$r->print('<script type="text/javascript"> |
|
function collapse() { |
|
this.document.location="/adm/navmaps?collapseExternal"; |
|
} |
|
</script>'); |
|
# FIXME need to be smarter to only catch window close events |
|
# $more_unload="collapse()" |
|
$body_only=1; |
|
} |
|
if ($ENV{'form.register'}) { |
|
$addentries=' onLoad="'.&Apache::lonmenu::loadevents(). |
|
'" onUnload="'.&Apache::lonmenu::unloadevents().';'. |
|
$more_unload.'"'; |
|
$r->print(&Apache::lonmenu::registerurl(1)); |
|
} else { |
|
$addentries=' onUnload="'.$more_unload.'"'; |
|
} |
|
|
|
# Header |
|
$r->print('</head>'. |
|
&Apache::loncommon::bodytag('Navigate Course Contents','', |
|
$addentries,$body_only,'', |
|
$ENV{'form.register'})); |
|
$r->print('<script>window.focus();</script>'); |
|
|
|
$r->rflush(); |
|
|
|
# Check that it's defined |
|
if (!($navmap->courseMapDefined())) { |
|
$r->print(&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT')); |
|
$r->print('<font size="+2" color="red">Coursemap undefined.</font>' . |
|
'</body></html>'); |
|
return OK; |
|
} |
|
|
|
# See if there's only one map in the top-level, if we don't |
|
# already have a filter... if so, automatically display it |
|
# (older code; should use retrieveResources) |
|
if ($ENV{QUERY_STRING} !~ /filter/) { |
|
my $iterator = $navmap->getIterator(undef, undef, undef, 0); |
|
my $curRes; |
|
my $sequenceCount = 0; |
|
my $sequenceId; |
|
while ($curRes = $iterator->next()) { |
|
if (ref($curRes) && $curRes->is_sequence()) { |
|
$sequenceCount++; |
|
$sequenceId = $curRes->map_pc(); |
|
} |
|
} |
|
|
|
if ($sequenceCount == 1) { |
|
# The automatic iterator creation in the render call |
|
# will pick this up. We know the condition because |
|
# the defined($ENV{'form.filter'}) also ensures this |
|
# is a fresh call. |
|
$ENV{'form.filter'} = "$sequenceId"; |
|
} |
|
} |
|
|
|
if ($ENV{QUERY_STRING} eq 'launchExternal') { |
|
$r->print(' |
|
<form name="returnwin" action="/adm/flip?postdata=return%3a" |
|
method="post" target="loncapaclient"> |
|
</form>'); |
|
$r->print(' |
|
<script type="text/javascript"> |
|
this.document.returnwin.submit(); |
|
</script>'); |
|
} |
|
|
|
if ($ENV{'environment.remotenavmap'} ne 'on') { |
|
$r->print(&launch_win('link','yes',\%toplinkitems)); |
|
} |
|
if ($ENV{'environment.remotenavmap'} eq 'on') { |
|
&add_linkitem(\%toplinkitems,'closenav','collapse()', |
|
"Close navigation window"); |
|
} |
|
|
|
my $jumpToFirstHomework = 0; |
|
# Check to see if the student is jumping to next open, do-able problem |
|
if ($ENV{QUERY_STRING} =~ /^jumpToFirstHomework/) { |
|
$jumpToFirstHomework = 1; |
|
# Find the next homework problem that they can do. |
|
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
|
my $curRes; |
|
my $foundDoableProblem = 0; |
|
my $problemRes; |
|
|
|
while (($curRes = $iterator->next()) && !$foundDoableProblem) { |
|
if (ref($curRes) && $curRes->is_problem()) { |
|
my $status = $curRes->status(); |
|
if ($curRes->completable()) { |
|
$problemRes = $curRes; |
|
$foundDoableProblem = 1; |
|
|
|
# Pop open all previous maps |
|
my $stack = $iterator->getStack(); |
|
pop @$stack; # last resource in the stack is the problem |
|
# itself, which we don't need in the map stack |
|
my @mapPcs = map {$_->map_pc()} @$stack; |
|
$ENV{'form.filter'} = join(',', @mapPcs); |
|
|
|
# Mark as both "here" and "jump" |
|
$ENV{'form.postsymb'} = $curRes->symb(); |
|
} |
|
} |
|
} |
|
|
|
# If we found no problems, print a note to that effect. |
|
if (!$foundDoableProblem) { |
|
$r->print("<font size='+2'>All homework assignments have been completed.</font><br /><br />"); |
|
} |
|
} else { |
|
&add_linkitem(\%toplinkitems,'firsthomework', |
|
'location.href="navmaps?jumpToFirstHomework"', |
|
"Show Me My First Homework Problem"); |
|
} |
|
|
|
my $suppressEmptySequences = 0; |
|
my $filterFunc = undef; |
|
my $resource_no_folder_link = 0; |
|
|
|
# Display only due homework. |
|
my $showOnlyHomework = 0; |
|
if ($ENV{'form.showOnlyHomework'} eq "1") { |
|
$showOnlyHomework = 1; |
|
$suppressEmptySequences = 1; |
|
$filterFunc = sub { my $res = shift; |
|
return $res->completable() || $res->is_map(); |
|
}; |
|
&add_linkitem(\%toplinkitems,'everything', |
|
'location.href="navmaps?sort='.$ENV{'form.sort'}.'"', |
|
"Show Everything"); |
|
$r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>"); |
|
$ENV{'form.filter'} = ''; |
|
$ENV{'form.condition'} = 1; |
|
$resource_no_folder_link = 1; |
|
} else { |
|
&add_linkitem(\%toplinkitems,'uncompleted', |
|
'location.href="navmaps?sort='.$ENV{'form.sort'}. |
|
'&showOnlyHomework=1"', |
|
"Show Only Uncompleted Homework"); |
|
} |
|
|
|
my %selected=($ENV{'form.sort'} => 'selected=on'); |
|
my $sort_html=("<form> |
|
<nobr> |
|
<input type=\"hidden\" name=\"showOnlyHomework\" value=\"".$ENV{'form.showOnlyHomework'}."\" /> |
|
<input type=\"submit\" value=\"".&mt('Sort by:')."\" /> |
|
<select name=\"sort\"> |
|
<option value=\"default\" $selected{'default'}>".&mt('Default')."</option> |
|
<option value=\"title\" $selected{'title'} >".&mt('Title')."</option> |
|
<option value=\"duedate\" $selected{'duedate'}>".&mt('Duedate')."</option> |
|
<option value=\"discussion\" $selected{'discussion'}>".&mt('Has Discussion')."</option> |
|
</select> |
|
</nobr> |
|
</form>"); |
|
# renderer call |
|
my $renderArgs = { 'cols' => [0,1,2,3], |
|
'sort' => $ENV{'form.sort'}, |
|
'url' => '/adm/navmaps', |
|
'navmap' => $navmap, |
|
'suppressNavmap' => 1, |
|
'suppressEmptySequences' => $suppressEmptySequences, |
|
'filterFunc' => $filterFunc, |
|
'resource_no_folder_link' => $resource_no_folder_link, |
|
'sort_html'=> $sort_html, |
|
'r' => $r, |
|
'caller' => 'navmapsdisplay', |
|
'linkitems' => \%toplinkitems}; |
|
my $render = render($renderArgs); |
|
$navmap->untieHashes(); |
|
|
|
# If no resources were printed, print a reassuring message so the |
|
# user knows there was no error. |
|
if ($renderArgs->{'counter'} == 0) { |
|
if ($showOnlyHomework) { |
|
$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 |
|
$r->print("<p><font size='+1'>This course is empty.</font></p>"); |
|
} |
|
} |
|
|
|
$r->print("</body></html>"); |
|
$r->rflush(); |
|
|
|
return OK; |
|
} |
|
|
|
# Convenience functions: Returns a string that adds or subtracts |
# Convenience functions: Returns a string that adds or subtracts |
# the second argument from the first hash, appropriate for the |
# the second argument from the first hash, appropriate for the |
# query string that determines which folders to recurse on |
# query string that determines which folders to recurse on |
Line 451 sub removeFromFilter {
|
Line 139 sub removeFromFilter {
|
|
|
# Convenience function: Given a stack returned from getStack on the iterator, |
# Convenience function: Given a stack returned from getStack on the iterator, |
# return the correct src() value. |
# return the correct src() value. |
# Later, this should add an anchor when we start putting anchors in pages. |
|
sub getLinkForResource { |
sub getLinkForResource { |
my $stack = shift; |
my $stack = shift; |
my $res; |
my $res; |
Line 459 sub getLinkForResource {
|
Line 146 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)) { |
if (defined($res)) { |
|
my $anchor; |
if ($res->is_page()) { |
if ($res->is_page()) { |
return $res->src(); |
foreach my $item (@$stack) { if (defined($item)) { $anchor = $item; } } |
|
$anchor=&escape($anchor->shown_symb()); |
|
return ($res->link(),$res->shown_symb(),$anchor); |
} |
} |
# in case folder was skipped over as "only sequence" |
# in case folder was skipped over as "only sequence" |
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); |
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); |
if ($map=~/\.page$/) { |
if ($map=~/\.page$/) { |
return &Apache::lonnet::clutter($map).'#'. |
my $url=&Apache::lonnet::clutter($map); |
&Apache::lonnet::escape(&Apache::lonnet::declutter($src)); |
$anchor=&escape($src->shown_symb()); |
|
return ($url,$res->shown_symb(),$anchor); |
} |
} |
} |
} |
} |
} |
Line 475 sub getLinkForResource {
|
Line 166 sub getLinkForResource {
|
# (when we first recurse on a map, it puts an undefined resource |
# (when we first recurse on a map, it puts an undefined resource |
# on the bottom because $self->{HERE} isn't defined yet, and we |
# on the bottom because $self->{HERE} isn't defined yet, and we |
# want the src for the map anyhow) |
# want the src for the map anyhow) |
foreach (@$stack) { |
foreach my $item (@$stack) { |
if (defined($_)) { $res = $_; } |
if (defined($item)) { $res = $item; } |
} |
} |
|
|
return $res->src(); |
return ($res->link(),$res->shown_symb()); |
} |
} |
|
|
# Convenience function: This separates the logic of how to create |
# Convenience function: This separates the logic of how to create |
Line 500 sub getDescription {
|
Line 191 sub getDescription {
|
return &mt("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),'start'); |
} |
} |
if ($status == $res->OPEN) { |
if ($status == $res->OPEN) { |
if ($res->duedate($part)) { |
if ($res->duedate($part)) { |
return &mt("Due")." " .timeToHumanString($res->duedate($part)); |
return &mt("Due")." " .timeToHumanString($res->duedate($part),'end'); |
} else { |
} else { |
return &mt("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 &mt("Answer open")." " . timeToHumanString($res->answerdate($part)); |
return &mt("Answer open")." " . timeToHumanString($res->answerdate($part),'start'); |
} |
} |
if ($status == $res->PAST_DUE_NO_ANSWER) { |
if ($status == $res->PAST_DUE_NO_ANSWER) { |
return &mt("Was due")." " . timeToHumanString($res->duedate($part)); |
return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); |
} |
} |
if ($status == $res->ANSWER_OPEN) { |
if (($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) |
|
&& $res->handgrade($part) ne 'yes') { |
return &mt("Answer available"); |
return &mt("Answer available"); |
} |
} |
if ($status == $res->EXCUSED) { |
if ($status == $res->EXCUSED) { |
Line 535 sub getDescription {
|
Line 227 sub getDescription {
|
} |
} |
} |
} |
if ($res->duedate($part)) { |
if ($res->duedate($part)) { |
return &mt("Due")." " . timeToHumanString($res->duedate($part)) . |
return &mt("Due")." " . timeToHumanString($res->duedate($part),'end') . |
" $triesString"; |
" $triesString"; |
} else { |
} else { |
return &mt("No due date")." $triesString"; |
return &mt("No due date")." $triesString"; |
Line 546 sub getDescription {
|
Line 238 sub getDescription {
|
} |
} |
} |
} |
|
|
# 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 than |
# 24 hours, and still can be done? |
# 24 hours, and still can be done? |
|
|
sub dueInLessThan24Hours { |
sub dueInLessThan24Hours { |
Line 561 sub dueInLessThan24Hours {
|
Line 253 sub dueInLessThan24Hours {
|
} |
} |
|
|
# 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 |
# part, with more then one try to begin with, not due yet and still can be done? |
# part, with more than one try to begin with, not due yet and still can be done? |
sub lastTry { |
sub lastTry { |
my $res = shift; |
my $res = shift; |
my $part = shift; |
my $part = shift; |
Line 573 sub lastTry {
|
Line 265 sub lastTry {
|
$res->duedate($part) > 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. |
|
|
sub advancedUser { |
sub advancedUser { |
return $ENV{'request.role.adv'}; |
return $env{'request.role.adv'}; |
} |
} |
|
|
|
|
Line 588 sub advancedUser {
|
Line 280 sub advancedUser {
|
# print "Answer available $timestring" |
# print "Answer available $timestring" |
# Very, very, very, VERY English-only... goodness help a localizer on |
# Very, very, very, VERY English-only... goodness help a localizer on |
# this func... |
# this func... |
|
|
|
|
sub timeToHumanString { |
sub timeToHumanString { |
my ($time) = @_; |
my ($time,$type,$format) = @_; |
|
|
# zero, '0' and blank are bad times |
# zero, '0' and blank are bad times |
if (!$time) { |
if (!$time) { |
return &mt('never'); |
return &mt('never'); |
Line 627 sub timeToHumanString {
|
Line 322 sub timeToHumanString {
|
my $tense = $inPast ? " ago" : ""; |
my $tense = $inPast ? " ago" : ""; |
my $prefix = $inPast ? "" : "in "; |
my $prefix = $inPast ? "" : "in "; |
|
|
# Less then a minute |
# Less than a minute |
if ( $delta < $minute ) { |
if ( $delta < $minute ) { |
if ($delta == 1) { return "${prefix}1 second$tense"; } |
if ($delta == 1) { return "${prefix}1 second$tense"; } |
return "$prefix$delta seconds$tense"; |
return "$prefix$delta seconds$tense"; |
} |
} |
|
|
# Less then an hour |
# Less than an hour |
if ( $delta < $hour ) { |
if ( $delta < $hour ) { |
# If so, use minutes |
# If so, use minutes |
my $minutes = floor($delta / 60); |
my $minutes = floor($delta / 60); |
Line 641 sub timeToHumanString {
|
Line 336 sub timeToHumanString {
|
return "$prefix$minutes minutes$tense"; |
return "$prefix$minutes minutes$tense"; |
} |
} |
|
|
# Is it less then 24 hours away? If so, |
# Is it less than 24 hours away? If so, |
# display hours + minutes |
# display hours + minutes |
if ( $delta < $hour * 24) { |
if ( $delta < $hour * 24) { |
my $hours = floor($delta / $hour); |
my $hours = floor($delta / $hour); |
Line 660 sub timeToHumanString {
|
Line 355 sub timeToHumanString {
|
return "$prefix$hourString$minuteString$tense"; |
return "$prefix$hourString$minuteString$tense"; |
} |
} |
|
|
# Less then 5 days away, display day of the week and |
# If there's a caller supplied format, use it. |
|
|
|
if($format ne '') { |
|
my $timeStr = strftime($format, localtime($time)); |
|
return $timeStr.&Apache::lonlocal::gettimezone($time); |
|
} |
|
|
|
# Less than 5 days away, display day of the week and |
# 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/00:00/; |
$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 " : "this ") . |
$timeStr; |
$timeStr.&Apache::lonlocal::gettimezone($time); |
} |
} |
|
|
|
my $conjunction='on'; |
|
if ($type eq 'start') { |
|
$conjunction='at'; |
|
} elsif ($type eq 'end') { |
|
$conjunction='by'; |
|
} |
# Is it this year? |
# Is it this year? |
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("$conjunction %A, %b %e at %I:%M %P", localtime($time)); |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 pm/noon/; |
$timeStr =~ s/12:00 pm/noon/; |
return $timeStr; |
return $timeStr.&Apache::lonlocal::gettimezone($time); |
} |
} |
|
|
# Not this year, so show the year |
# Not this year, so show the year |
my $timeStr = strftime("on %A, %b %e %Y at %I:%M %P", localtime($time)); |
my $timeStr = strftime("$conjunction %A, %b %e %Y at %I:%M %P", localtime($time)); |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 am/00:00/; |
$timeStr =~ s/12:00 pm/noon/; |
$timeStr =~ s/12:00 pm/noon/; |
return $timeStr; |
return $timeStr.&Apache::lonlocal::gettimezone($time); |
} |
} |
} |
} |
|
|
Line 718 to compute due to the amount of data tha
|
Line 427 to compute due to the amount of data tha
|
processed. |
processed. |
|
|
Apache::lonnavmaps provides an object model for manipulating this |
Apache::lonnavmaps provides an object model for manipulating this |
information in a higher-level fashion then directly manipulating |
information in a higher-level fashion than directly manipulating |
the hash. It also provides access to several auxilary functions |
the hash. It also provides access to several auxilary functions |
that aren't necessarily stored in the Big Hash, but are a per- |
that aren't necessarily stored in the Big Hash, but are a per- |
resource sort of value, like whether there is any feedback on |
resource sort of value, like whether there is any feedback on |
Line 764 Apache::lonnavmaps::render({}).
|
Line 473 Apache::lonnavmaps::render({}).
|
=head2 Overview of Columns |
=head2 Overview of Columns |
|
|
The renderer will build an HTML table for the navmap and return |
The renderer will build an HTML table for the navmap and return |
it. The table is consists of several columns, and a row for each |
it. The table consists of several columns, and a row for each |
resource (or possibly each part). You tell the renderer how many |
resource (or possibly each part). You tell the renderer how many |
columns to create and what to place in each column, optionally using |
columns to create and what to place in each column, optionally using |
one or more of the prepared columns, and the renderer will assemble |
one or more of the prepared columns, and the renderer will assemble |
Line 879 automatically.
|
Line 588 automatically.
|
|
|
=over 4 |
=over 4 |
|
|
=item * B<iterator>: default: constructs one from %ENV |
=item * B<iterator>: default: constructs one from %env |
|
|
A reference to a fresh ::iterator to use from the navmaps. The |
A reference to a fresh ::iterator to use from the navmaps. The |
rendering will reflect the options passed to the iterator, so you can |
rendering will reflect the options passed to the iterator, so you can |
use that to just render a certain part of the course, if you like. If |
use that to just render a certain part of the course, if you like. If |
one is not passed, the renderer will attempt to construct one from |
one is not passed, the renderer will attempt to construct one from |
ENV{'form.filter'} and ENV{'form.condition'} information, plus the |
env{'form.filter'} and env{'form.condition'} information, plus the |
'iterator_map' parameter if any. |
'iterator_map' parameter if any. |
|
|
=item * B<iterator_map>: default: not used |
=item * B<iterator_map>: default: not used |
Line 895 instruct the renderer to render only a p
|
Line 604 instruct the renderer to render only a p
|
the source of the map you want to process, like |
the source of the map you want to process, like |
'/res/103/jerf/navmap.course.sequence'. |
'/res/103/jerf/navmap.course.sequence'. |
|
|
=item * B<navmap>: default: constructs one from %ENV |
=item * B<navmap>: default: constructs one from %env |
|
|
A reference to a navmap, used only if an iterator is not passed in. If |
A reference to a navmap, used only if an iterator is not passed in. If |
this is necessary to make an iterator but it is not passed in, a new |
this is necessary to make an iterator but it is not passed in, a new |
one will be constructed based on ENV info. This is useful to do basic |
one will be constructed based on env info. This is useful to do basic |
error checking before passing it off to render. |
error checking before passing it off to render. |
|
|
=item * B<r>: default: must be passed in |
=item * B<r>: default: must be passed in |
Line 925 then only one line will be displayed for
|
Line 634 then only one line will be displayed for
|
all parts will always be displayed. If showParts is 0, this is |
all parts will always be displayed. If showParts is 0, this is |
ignored. |
ignored. |
|
|
=item * B<jumpCount>: default: determined from %ENV |
=item * B<jumpCount>: default: determined from %env |
|
|
A string identifying the URL to place the anchor 'curloc' at. |
A string identifying the URL to place the anchor 'curloc' at. |
It is the responsibility of the renderer user to |
It is the responsibility of the renderer user to |
ensure that the #curloc is in the URL. By default, determined through |
ensure that the #curloc is in the URL. By default, determined through |
the use of the ENV{} 'jump' information, and should normally "just |
the use of the env{} 'jump' information, and should normally "just |
work" correctly. |
work" correctly. |
|
|
=item * B<here>: default: empty string |
=item * B<here>: default: empty string |
Line 958 are allowing the user to open and close
|
Line 667 are allowing the user to open and close
|
|
|
Describes the currently-open row number to cause the browser to jump |
Describes the currently-open row number to cause the browser to jump |
to, because the user just opened that folder. By default, pulled from |
to, because the user just opened that folder. By default, pulled from |
the Jump information in the ENV{'form.*'}. |
the Jump information in the env{'form.*'}. |
|
|
=item * B<printKey>: default: false |
=item * B<printKey>: default: false |
|
|
Line 1027 sub render_resource {
|
Line 736 sub render_resource {
|
my $nonLinkedText = ''; # stuff after resource title not in link |
my $nonLinkedText = ''; # stuff after resource title not in link |
|
|
my $link = $params->{"resourceLink"}; |
my $link = $params->{"resourceLink"}; |
|
|
|
# The URL part is not escaped at this point, but the symb is... |
|
# The stuff to the left of the ? must have ' replaced by \' since |
|
# it will be quoted with ' in the href. |
|
|
|
my ($left,$right) = split(/\?/, $link); |
|
$link = $left.'?'.$right; |
|
|
my $src = $resource->src(); |
my $src = $resource->src(); |
my $it = $params->{"iterator"}; |
my $it = $params->{"iterator"}; |
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
Line 1038 sub render_resource {
|
Line 755 sub render_resource {
|
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); |
# If this is a new branch, label it so |
# If this is a new branch, label it so |
if ($params->{'isNewBranch'}) { |
if ($params->{'isNewBranch'}) { |
$newBranchText = "<img src='$location/branch.gif' border='0' />"; |
$newBranchText = "<img src='$location/branch.gif' border='0' alt='Branch' />"; |
} |
} |
|
|
# links to open and close the folder |
# links to open and close the folder |
my $linkopen = "<a href='$link'>"; |
|
|
|
|
my $linkopen = "<a href=\"$link\">"; |
|
|
|
|
my $linkclose = "</a>"; |
my $linkclose = "</a>"; |
|
|
# Default icon: unknown page |
# Default icon: unknown page |
my $icon = "<img src='$location/unknown.gif' alt='' border='0' />"; |
my $icon = "<img src='$location/unknown.gif' alt='' border='0' alt=' ' ' />"; |
|
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
if ($part eq '0' || $params->{'condensed'}) { |
if ($part eq '0' || $params->{'condensed'}) { |
$icon ='<img src="'.$location.'/problem.gif" alt="" border="0" />'; |
$icon = '<img src="'.$location.'/'; |
|
if ($resource->is_task()) { |
|
$icon .= 'task.gif" alt="'.&mt('Task'); |
|
} else { |
|
$icon .= 'problem.gif" alt="'.&mt('Problem'); |
|
} |
|
$icon .='" border="0" />'; |
} else { |
} else { |
$icon = $params->{'indentString'}; |
$icon = $params->{'indentString'}; |
} |
} |
} else { |
} else { |
$icon = "<img src='".&Apache::loncommon::lonhttpdurl(&Apache::loncommon::icon($resource->src))."' alt='' border='0' />"; |
$icon = "<img src='".&Apache::loncommon::icon($resource->src)."' alt=' ' border='0' />"; |
} |
} |
|
|
# Display the correct map icon to open or shut map |
# Display the correct map icon to open or shut map |
Line 1067 sub render_resource {
|
Line 794 sub render_resource {
|
} |
} |
|
|
my $folderType = $resource->is_sequence() ? 'folder' : 'page'; |
my $folderType = $resource->is_sequence() ? 'folder' : 'page'; |
|
my $title=$resource->title; |
|
$title=~s/\"/\"/g; |
if (!$params->{'resource_no_folder_link'}) { |
if (!$params->{'resource_no_folder_link'}) { |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "<img src='$location/$icon' alt='' border='0' />"; |
$icon = "<img src='$location/$icon' alt=\"". |
|
($nowOpen ? &mt('Open Folder') : &mt('Close Folder')).' '.$title."\" border='0' />"; |
|
|
$linkopen = "<a href='" . $params->{'url'} . '?' . |
$linkopen = "<a href=\"" . $params->{'url'} . '?' . |
$params->{'queryString'} . '&filter='; |
$params->{'queryString'} . '&filter='; |
$linkopen .= ($nowOpen xor $it->{CONDITION}) ? |
$linkopen .= ($nowOpen xor $it->{CONDITION}) ? |
addToFilter($filter, $mapId) : |
addToFilter($filter, $mapId) : |
removeFromFilter($filter, $mapId); |
removeFromFilter($filter, $mapId); |
$linkopen .= "&condition=" . $it->{CONDITION} . '&hereType=' |
$linkopen .= "&condition=" . $it->{CONDITION} . '&hereType=' |
. $params->{'hereType'} . '&here=' . |
. $params->{'hereType'} . '&here=' . |
&Apache::lonnet::escape($params->{'here'}) . |
&escape($params->{'here'}) . |
'&jump=' . |
'&jump=' . |
&Apache::lonnet::escape($resource->symb()) . |
&escape($resource->symb()) . |
"&folderManip=1'>"; |
"&folderManip=1\">"; |
|
|
} else { |
} else { |
# Don't allow users to manipulate folder |
# Don't allow users to manipulate folder |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . |
'.nomanip.gif'; |
'.nomanip.gif'; |
$icon = "<img src='$location/$icon' alt='' border='0' />"; |
$icon = "<img src='$location/$icon' alt=\"". |
|
($nowOpen ? &mt('Open Folder') : &mt('Close Folder')).' '.$title."\" border='0' />"; |
|
|
$linkopen = ""; |
$linkopen = ""; |
$linkclose = ""; |
$linkclose = ""; |
Line 1095 sub render_resource {
|
Line 826 sub render_resource {
|
} |
} |
|
|
if ($resource->randomout()) { |
if ($resource->randomout()) { |
$nonLinkedText .= ' <i>(hidden)</i> '; |
$nonLinkedText .= ' <i>('.&mt('hidden').')</i> '; |
|
} |
|
if (!$resource->condval()) { |
|
$nonLinkedText .= ' <i>('.&mt('conditionally hidden').')</i> '; |
} |
} |
|
|
# We're done preparing and finally ready to start the rendering |
# We're done preparing and finally ready to start the rendering |
my $result = "<td align='left' valign='center'>"; |
my $result = "<td align='left' valign='middle'>"; |
|
|
my $indentLevel = $params->{'indentLevel'}; |
my $indentLevel = $params->{'indentLevel'}; |
if ($newBranchText) { $indentLevel--; } |
if ($newBranchText) { $indentLevel--; } |
Line 1110 sub render_resource {
|
Line 844 sub render_resource {
|
} |
} |
|
|
# Decide what to display |
# Decide what to display |
|
|
$result .= "$newBranchText$linkopen$icon$linkclose"; |
$result .= "$newBranchText$linkopen$icon$linkclose"; |
|
|
my $curMarkerBegin = ''; |
my $curMarkerBegin = ''; |
Line 1118 sub render_resource {
|
Line 853 sub render_resource {
|
# Is this the current resource? |
# Is this the current resource? |
if (!$params->{'displayedHereMarker'} && |
if (!$params->{'displayedHereMarker'} && |
$resource->symb() eq $params->{'here'} ) { |
$resource->symb() eq $params->{'here'} ) { |
$curMarkerBegin = '<font color="red" size="+2">> </font>'; |
$curMarkerBegin = '<font color="red" size="+2">></font>'; |
$curMarkerEnd = '<font color="red" size="+2"><</font>'; |
$curMarkerEnd = '<font color="red" size="+2"><</font>'; |
$params->{'displayedHereMarker'} = 1; |
$params->{'displayedHereMarker'} = 1; |
} |
} |
Line 1126 sub render_resource {
|
Line 861 sub render_resource {
|
if ($resource->is_problem() && $part ne '0' && |
if ($resource->is_problem() && $part ne '0' && |
!$params->{'condensed'}) { |
!$params->{'condensed'}) { |
my $displaypart=$resource->part_display($part); |
my $displaypart=$resource->part_display($part); |
$partLabel = " (Part: $displaypart)"; |
$partLabel = " (".&mt('Part: [_1]', $displaypart).")"; |
$link.='#'.&Apache::lonnet::escape($part); |
if ($link!~/\#/) { $link.='#'.&escape($part); } |
$title = ""; |
$title = ""; |
} |
} |
|
|
if ($params->{'condensed'} && $resource->countParts() > 1) { |
if ($params->{'condensed'} && $resource->countParts() > 1) { |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' ('.&mt('[_1] parts', $resource->countParts()).')'; |
} |
} |
|
|
my $target; |
my $target; |
if ($ENV{'environment.remotenavmap'} eq 'on') { |
if ($env{'environment.remotenavmap'} eq 'on') { |
$target=' target="loncapaclient" '; |
$target=' target="loncapaclient" '; |
} |
} |
if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) { |
if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) { |
$result .= " $curMarkerBegin<a $target href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>"; |
$result .= " $curMarkerBegin<a $target 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 1153 sub render_communication_status {
|
Line 888 sub render_communication_status {
|
my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = ""; |
my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = ""; |
|
|
my $link = $params->{"resourceLink"}; |
my $link = $params->{"resourceLink"}; |
my $linkopen = "<a href='$link'>"; |
my $target; |
|
if ($env{'environment.remotenavmap'} eq 'on') { |
|
$target=' target="loncapaclient" '; |
|
} |
|
my $linkopen = "<a $target href=\"$link\">"; |
my $linkclose = "</a>"; |
my $linkclose = "</a>"; |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); |
if ($resource->hasDiscussion()) { |
if ($resource->hasDiscussion()) { |
$discussionHTML = $linkopen . |
$discussionHTML = $linkopen . |
'<img border="0" src="'.$location.'/chat.gif" />' . |
'<img alt="'.&mt('New Discussion').'" border="0" src="'.$location.'/chat.gif" />' . |
$linkclose; |
$linkclose; |
} |
} |
|
|
if ($resource->getFeedback()) { |
if ($resource->getFeedback()) { |
my $feedback = $resource->getFeedback(); |
my $feedback = $resource->getFeedback(); |
foreach (split(/\,/, $feedback)) { |
foreach my $msgid (split(/\,/, $feedback)) { |
if ($_) { |
if ($msgid) { |
$feedbackHTML .= ' <a href="/adm/email?display=' |
$feedbackHTML .= ' <a '.$target.' href="/adm/email?display=' |
. &Apache::lonnet::escape($_) . '">' |
. &escape($msgid) . '">' |
. '<img src="'.$location.'/feedback.gif" ' |
. '<img alt="'.&mt('New Email').'" src="'.$location.'/feedback.gif" ' |
. 'border="0" /></a>'; |
. 'border="0" /></a>'; |
} |
} |
} |
} |
Line 1177 sub render_communication_status {
|
Line 916 sub render_communication_status {
|
if ($resource->getErrors()) { |
if ($resource->getErrors()) { |
my $errors = $resource->getErrors(); |
my $errors = $resource->getErrors(); |
my $errorcount = 0; |
my $errorcount = 0; |
foreach (split(/,/, $errors)) { |
foreach my $msgid (split(/,/, $errors)) { |
last if ($errorcount>=10); # Only output 10 bombs maximum |
last if ($errorcount>=10); # Only output 10 bombs maximum |
if ($_) { |
if ($msgid) { |
$errorcount++; |
$errorcount++; |
$errorHTML .= ' <a href="/adm/email?display=' |
$errorHTML .= ' <a '.$target.' href="/adm/email?display=' |
. &Apache::lonnet::escape($_) . '">' |
. &escape($msgid) . '">' |
. '<img src="'.$location.'/bomb.gif" ' |
. '<img alt="'.&mt('New Error').'" src="'.$location.'/bomb.gif" ' |
. 'border="0" /></a>'; |
. 'border="0" /></a>'; |
} |
} |
} |
} |
Line 1193 sub render_communication_status {
|
Line 932 sub render_communication_status {
|
$discussionHTML = $feedbackHTML = $errorHTML = ''; |
$discussionHTML = $feedbackHTML = $errorHTML = ''; |
} |
} |
|
|
return "<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML </td>"; |
return "<td width=\"75\" align=\"left\" valign=\"middle\">$discussionHTML$feedbackHTML$errorHTML </td>"; |
|
|
} |
} |
sub render_quick_status { |
sub render_quick_status { |
Line 1203 sub render_quick_status {
|
Line 942 sub render_quick_status {
|
$params->{'multipart'} && $part eq "0"; |
$params->{'multipart'} && $part eq "0"; |
|
|
my $link = $params->{"resourceLink"}; |
my $link = $params->{"resourceLink"}; |
my $linkopen = "<a href='$link'>"; |
my $target; |
|
if ($env{'environment.remotenavmap'} eq 'on') { |
|
$target=' target="loncapaclient" '; |
|
} |
|
my $linkopen = "<a $target href=\"$link\">"; |
my $linkclose = "</a>"; |
my $linkclose = "</a>"; |
|
|
if ($resource->is_problem() && |
if ($resource->is_problem() && |
Line 1214 sub render_quick_status {
|
Line 957 sub render_quick_status {
|
if ($icon) { |
if ($icon) { |
my $location= |
my $location= |
&Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); |
&Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); |
$result .= "<td width='30' valign='center' width='50' align='right'>$linkopen<img width='25' height='25' src='$location' border='0' alt='$alt' />$linkclose</td>\n"; |
$result .= "<td valign='middle' width='50' align='right'>$linkopen<img width='25' height='25' src='$location' border='0' alt='$alt' />$linkclose</td>\n"; |
} else { |
} else { |
$result .= "<td width='30'> </td>\n"; |
$result .= "<td width='30'> </td>\n"; |
} |
} |
Line 1226 sub render_quick_status {
|
Line 969 sub render_quick_status {
|
} |
} |
sub render_long_status { |
sub render_long_status { |
my ($resource, $part, $params) = @_; |
my ($resource, $part, $params) = @_; |
my $result = "<td align='right' valign='center'>\n"; |
my $result = "<td align='right' valign='middle'>\n"; |
my $firstDisplayed = !$params->{'condensed'} && |
my $firstDisplayed = !$params->{'condensed'} && |
$params->{'multipart'} && $part eq "0"; |
$params->{'multipart'} && $part eq "0"; |
|
|
Line 1362 sub render {
|
Line 1105 sub render {
|
# no columns, no nav maps. |
# no columns, no nav maps. |
return ''; |
return ''; |
} |
} |
my $mustCloseNavMap = 0; |
|
my $navmap; |
my $navmap; |
if (defined($args->{'navmap'})) { |
if (defined($args->{'navmap'})) { |
$navmap = $args->{'navmap'}; |
$navmap = $args->{'navmap'}; |
Line 1383 sub render {
|
Line 1125 sub render {
|
# marker |
# marker |
my $filterHash = {}; |
my $filterHash = {}; |
# Figure out what we're not displaying |
# Figure out what we're not displaying |
foreach (split(/\,/, $ENV{"form.filter"})) { |
foreach my $item (split(/\,/, $env{"form.filter"})) { |
if ($_) { |
if ($item) { |
$filterHash->{$_} = "1"; |
$filterHash->{$item} = "1"; |
} |
} |
} |
} |
|
|
Line 1403 sub render {
|
Line 1145 sub render {
|
} |
} |
|
|
my $condition = 0; |
my $condition = 0; |
if ($ENV{'form.condition'}) { |
if ($env{'form.condition'}) { |
$condition = 1; |
$condition = 1; |
} |
} |
|
|
if (!$ENV{'form.folderManip'} && !defined($args->{'iterator'})) { |
if (!$env{'form.folderManip'} && !defined($args->{'iterator'})) { |
# Step 1: Check to see if we have a navmap |
# Step 1: Check to see if we have a navmap |
if (!defined($navmap)) { |
if (!defined($navmap)) { |
$navmap = Apache::lonnavmaps::navmap->new(); |
$navmap = Apache::lonnavmaps::navmap->new(); |
$mustCloseNavMap = 1; |
if (!defined($navmap)) { |
} |
# no londer in course |
|
return '<span class="LC_error">'.&mt('No course selected').'</span><br /> |
|
<a href="/adm/roles">'.&mt('Select a course').'</a><br />'; |
|
} |
|
} |
|
|
# Step two: Locate what kind of here marker is necessary |
# Step two: Locate what kind of here marker is necessary |
# Determine where the "here" marker is and where the screen jumps to. |
# Determine where the "here" marker is and where the screen jumps to. |
|
|
if ($ENV{'form.postsymb'}) { |
if ($env{'form.postsymb'} ne '') { |
$here = $jump = $ENV{'form.postsymb'}; |
$here = $jump = &Apache::lonnet::symbclean($env{'form.postsymb'}); |
} elsif ($ENV{'form.postdata'}) { |
} elsif ($env{'form.postdata'} ne '') { |
# couldn't find a symb, is there a URL? |
# couldn't find a symb, is there a URL? |
my $currenturl = $ENV{'form.postdata'}; |
my $currenturl = $env{'form.postdata'}; |
#$currenturl=~s/^http\:\/\///; |
#$currenturl=~s/^http\:\/\///; |
#$currenturl=~s/^[^\/]+//; |
#$currenturl=~s/^[^\/]+//; |
|
|
$here = $jump = &Apache::lonnet::symbread($currenturl); |
$here = $jump = &Apache::lonnet::symbread($currenturl); |
} |
} |
|
if ($here eq '') { |
|
my $last; |
|
if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
|
&GDBM_READER(),0640)) { |
|
$last=$hash{'last_known'}; |
|
untie(%hash); |
|
} |
|
if ($last) { $here = $jump = $last; } |
|
} |
|
|
# Step three: Ensure the folders are open |
# Step three: Ensure the folders are open |
my $mapIterator = $navmap->getIterator(undef, undef, undef, 1); |
my $mapIterator = $navmap->getIterator(undef, undef, undef, 1); |
Line 1453 sub render {
|
Line 1208 sub render {
|
} |
} |
} |
} |
|
|
if ( !defined($args->{'iterator'}) && $ENV{'form.folderManip'} ) { # we came from a user's manipulation of the nav page |
if ( !defined($args->{'iterator'}) && $env{'form.folderManip'} ) { # we came from a user's manipulation of the nav page |
# If this is a click on a folder or something, we want to preserve the "here" |
# If this is a click on a folder or something, we want to preserve the "here" |
# from the querystring, and get the new "jump" marker |
# from the querystring, and get the new "jump" marker |
$here = $ENV{'form.here'}; |
$here = $env{'form.here'}; |
$jump = $ENV{'form.jump'}; |
$jump = $env{'form.jump'}; |
} |
} |
|
|
my $it = $args->{'iterator'}; |
my $it = $args->{'iterator'}; |
if (!defined($it)) { |
if (!defined($it)) { |
# Construct a default iterator based on $ENV{'form.'} information |
# Construct a default iterator based on $env{'form.'} information |
|
|
# Step 1: Check to see if we have a navmap |
# Step 1: Check to see if we have a navmap |
if (!defined($navmap)) { |
if (!defined($navmap)) { |
$navmap = Apache::lonnavmaps::navmap->new(); |
$navmap = Apache::lonnavmaps::navmap->new(); |
$mustCloseNavMap = 1; |
|
} |
} |
|
|
# See if we're being passed a specific map |
# See if we're being passed a specific map |
Line 1539 sub render {
|
Line 1293 sub render {
|
if ($printCloseAll && !$args->{'resource_no_folder_link'}) { |
if ($printCloseAll && !$args->{'resource_no_folder_link'}) { |
my ($link,$text); |
my ($link,$text); |
if ($condition) { |
if ($condition) { |
$link='"navmaps?condition=0&filter=&'.$queryString. |
$link='"navmaps?condition=0&filter=&'.$queryString. |
'&here='.&Apache::lonnet::escape($here).'"'; |
'&here='.&escape($here).'"'; |
$text='Close All Folders'; |
$text='Close all folders'; |
} else { |
} else { |
$link='"navmaps?condition=1&filter=&'.$queryString. |
$link='"navmaps?condition=1&filter=&'.$queryString. |
'&here='.&Apache::lonnet::escape($here).'"'; |
'&here='.&escape($here).'"'; |
$text='Open All Folders'; |
$text='Open all folders'; |
} |
} |
if ($args->{'caller'} eq 'navmapsdisplay') { |
if ($args->{'caller'} eq 'navmapsdisplay') { |
&add_linkitem($args->{'linkitems'},'changefolder', |
&add_linkitem($args->{'linkitems'},'changefolder', |
Line 1573 END
|
Line 1327 END
|
my @allres=$navmap->retrieveResources(); |
my @allres=$navmap->retrieveResources(); |
foreach my $resource (@allres) { |
foreach my $resource (@allres) { |
if ($resource->hasDiscussion()) { |
if ($resource->hasDiscussion()) { |
my $ressymb; |
$haveDisc .= $resource->wrap_symb().':'; |
if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { |
|
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; |
|
} else { |
|
$ressymb = $resource->symb(); |
|
} |
|
$haveDisc .= $ressymb.':'; |
|
$totdisc ++; |
$totdisc ++; |
} |
} |
} |
} |
if ($totdisc > 0) { |
if ($totdisc > 0) { |
$haveDisc =~ s/:$//; |
$haveDisc =~ s/:$//; |
my $navurl = $ENV{'QUERY_STRING'}; |
|
$result .= (<<END); |
$result .= (<<END); |
<input type="hidden" name="navmaps" value="$haveDisc" /> |
<input type="hidden" name="navmaps" value="$haveDisc" /> |
</form> |
</form> |
Line 1597 END
|
Line 1344 END
|
|
|
if ($args->{'caller'} eq 'navmapsdisplay') { |
if ($args->{'caller'} eq 'navmapsdisplay') { |
$result .= '<table><tr><td>'. |
$result .= '<table><tr><td>'. |
&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT').'</td>'; |
&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').'</td>'; |
if ($ENV{'environment.remotenavmap'} ne 'on') { |
if ($env{'environment.remotenavmap'} ne 'on') { |
$result .= '<td> </td>'; |
$result .= '<td> </td>'; |
} else { |
} else { |
$result .= '</tr><tr>'; |
$result .= '</tr><tr>'; |
} |
} |
$result.=&show_linkitems($args->{'linkitems'}); |
$result.=&show_linkitems($args->{'linkitems'}); |
if ($args->{'sort_html'}) { |
if ($args->{'sort_html'}) { |
if ($ENV{'environment.remotenavmap'} ne 'on') { |
if ($env{'environment.remotenavmap'} ne 'on') { |
$result.='<td> </td><td> </td><td> </td>'. |
$result.='<td> </td><td> </td><td> </td>'. |
'<td align="right">'.$args->{'sort_html'}.'</td></tr>'; |
'<td align="right">'.$args->{'sort_html'}.'</td></tr>'; |
} else { |
} else { |
Line 1642 END
|
Line 1389 END
|
$args->{'condensed'} = 0; |
$args->{'condensed'} = 0; |
my $location= |
my $location= |
&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif"); |
&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif"); |
$args->{'indentString'} = setDefault($args->{'indentString'}, "<img src='$location' width='25' height='1' alt='' border='0' />"); |
$args->{'indentString'} = setDefault($args->{'indentString'}, "<img src='$location' width='25' height='1' alt=' ' border='0' />"); |
$args->{'displayedHereMarker'} = 0; |
$args->{'displayedHereMarker'} = 0; |
|
|
# If we're suppressing empty sequences, look for them here. Use DFS for speed, |
# If we're suppressing empty sequences, look for them here. Use DFS for speed, |
Line 1795 END
|
Line 1542 END
|
$args->{'multipart'} = $curRes->multipart(); |
$args->{'multipart'} = $curRes->multipart(); |
|
|
if ($condenseParts) { # do the condensation |
if ($condenseParts) { # do the condensation |
if (!$curRes->opendate("0")) { |
|
@parts = (); |
|
$args->{'condensed'} = 1; |
|
} |
|
if (!$args->{'condensed'}) { |
if (!$args->{'condensed'}) { |
# Decide whether to condense based on similarity |
# Decide whether to condense based on similarity |
my $status = $curRes->status($parts[0]); |
my $status = $curRes->status($parts[0]); |
Line 1848 END
|
Line 1591 END
|
# Add part 0 so we display it correctly. |
# Add part 0 so we display it correctly. |
unshift @parts, '0'; |
unshift @parts, '0'; |
} |
} |
|
|
|
{ |
|
my ($src,$symb,$anchor,$stack); |
|
if ($args->{'sort'}) { |
|
my $it = $navmap->getIterator(undef, undef, undef, 1); |
|
while ( my $res=$it->next()) { |
|
if (ref($res) && |
|
$res->symb() eq $curRes->symb()) { last; } |
|
} |
|
$stack=$it->getStack(); |
|
} else { |
|
$stack=$it->getStack(); |
|
} |
|
($src,$symb,$anchor)=getLinkForResource($stack); |
|
if (defined($anchor)) { $anchor='#'.$anchor; } |
|
my $srcHasQuestion = $src =~ /\?/; |
|
$args->{"resourceLink"} = $src. |
|
($srcHasQuestion?'&':'?') . |
|
'symb=' . &escape($symb).$anchor; |
|
} |
# Now, we've decided what parts to show. Loop through them and |
# Now, we've decided what parts to show. Loop through them and |
# show them. |
# show them. |
foreach my $part (@parts) { |
foreach my $part (@parts) { |
Line 1859 END
|
Line 1621 END
|
|
|
# Set up some data about the parts that the cols might want |
# Set up some data about the parts that the cols might want |
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
my $src; |
|
if ($args->{'sort'}) { |
|
$src = $curRes->src(); # FIXME this is wrong for .pages |
|
} else { |
|
my $stack = $it->getStack(); |
|
$src=getLinkForResource($stack); |
|
} |
|
my $anchor=''; |
|
if ($src=~s/(\#.*)$//) { |
|
$anchor=$1; |
|
} |
|
my $srcHasQuestion = $src =~ /\?/; |
|
$args->{"resourceLink"} = $src. |
|
($srcHasQuestion?'&':'?') . |
|
'symb=' . &Apache::lonnet::escape($curRes->symb()). |
|
$anchor; |
|
|
|
# Now, display each column. |
# Now, display each column. |
foreach my $col (@$cols) { |
foreach my $col (@$cols) { |
Line 1941 if (location.href.indexOf('#curloc')==-1
|
Line 1687 if (location.href.indexOf('#curloc')==-1
|
$r->rflush(); |
$r->rflush(); |
} |
} |
|
|
if ($mustCloseNavMap) { $navmap->untieHashes(); } |
|
|
|
return $result; |
return $result; |
} |
} |
|
|
Line 1954 sub add_linkitem {
|
Line 1698 sub add_linkitem {
|
|
|
sub show_linkitems { |
sub show_linkitems { |
my ($linkitems)=@_; |
my ($linkitems)=@_; |
my @linkorder = ("launchnav","closenav","firsthomework","everything", |
my @linkorder = ("blank","launchnav","closenav","firsthomework", |
"uncompleted","changefolder","clearbubbles"); |
"everything","uncompleted","changefolder","clearbubbles"); |
|
|
my $result .= (<<ENDBLOCK); |
my $result .= (<<ENDBLOCK); |
<td align="left"> |
<td align="left"> |
Line 2005 In order of increasing complexity and po
|
Line 1749 In order of increasing complexity and po
|
|
|
=over 4 |
=over 4 |
|
|
=item * C<$navmap-E<gt>getByX>, where X is B<Id>, B<Symb>, B<Url> or B<MapPc>. This provides |
=item * C<$navmap-E<gt>getByX>, where X is B<Id>, B<Symb> or B<MapPc> and getResourceByUrl. This provides |
various ways to obtain resource objects, based on various identifiers. |
various ways to obtain resource objects, based on various identifiers. |
Use this when you want to request information about one object or |
Use this when you want to request information about one object or |
a handful of resources you already know the identities of, from some |
a handful of resources you already know the identities of, from some |
other source. For more about Ids, Symbs, and MapPcs, see the |
other source. For more about Ids, Symbs, and MapPcs, see the |
Resource documentation. Note that Url should be a B<last resort>, |
Resource documentation. Note that Url should be a B<last resort>, |
not your first choice; it only works when there is only one |
not your first choice; it only really works when there is only one |
instance of the resource in the course, which only applies to |
instance of the resource in the course, which only applies to |
maps, and even that may change in the future. |
maps, and even that may change in the future (see the B<getResourceByUrl> |
|
documentation for more details.) |
|
|
=item * C<my @resources = $navmap-E<gt>retrieveResources(args)>. This |
=item * C<my @resources = $navmap-E<gt>retrieveResources(args)>. This |
retrieves resources matching some criterion and returns them |
retrieves resources matching some criterion and returns them |
Line 2043 successful, or B<undef> if not.
|
Line 1788 successful, or B<undef> if not.
|
|
|
=back |
=back |
|
|
When you are done with the $navmap object, you I<must> call |
|
$navmap->untieHashes(), or you'll prevent the current user from using that |
|
course until the web server is restarted. (!) |
|
|
|
=head2 Methods |
=head2 Methods |
|
|
=over 4 |
=over 4 |
Line 2059 See iterator documentation below.
|
Line 1800 See iterator documentation below.
|
|
|
use strict; |
use strict; |
use GDBM_File; |
use GDBM_File; |
|
use Apache::lonnet; |
|
use LONCAPA; |
|
|
sub new { |
sub new { |
# magic invocation to create a class instance |
# magic invocation to create a class instance |
Line 2078 sub new {
|
Line 1821 sub new {
|
|
|
my %navmaphash; |
my %navmaphash; |
my %parmhash; |
my %parmhash; |
my $courseFn = $ENV{"request.course.fn"}; |
my $courseFn = $env{"request.course.fn"}; |
if (!(tie(%navmaphash, 'GDBM_File', "${courseFn}.db", |
if (!(tie(%navmaphash, 'GDBM_File', "${courseFn}.db", |
&GDBM_READER(), 0640))) { |
&GDBM_READER(), 0640))) { |
return undef; |
return undef; |
Line 2104 sub generate_course_user_opt {
|
Line 1847 sub generate_course_user_opt {
|
my $self = shift; |
my $self = shift; |
if ($self->{COURSE_USER_OPT_GENERATED}) { return; } |
if ($self->{COURSE_USER_OPT_GENERATED}) { return; } |
|
|
my $uname=$ENV{'user.name'}; |
my $uname=$env{'user.name'}; |
my $udom=$ENV{'user.domain'}; |
my $udom=$env{'user.domain'}; |
my $uhome=$ENV{'user.home'}; |
my $cid=$env{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
my $cdom=$env{'course.'.$cid.'.domain'}; |
my $chome=$ENV{'course.'.$cid.'.home'}; |
my $cnum=$env{'course.'.$cid.'.num'}; |
my ($cdom,$cnum)=split(/\_/,$cid); |
|
|
|
my $userprefix=$uname.'_'.$udom.'_'; |
|
|
|
my %courserdatas; my %useropt; my %courseopt; my %userrdatas; |
|
unless ($uhome eq 'no_host') { |
|
# ------------------------------------------------- Get coursedata (if present) |
# ------------------------------------------------- Get coursedata (if present) |
unless ((time-$courserdatas{$cid.'.last_cache'})<240) { |
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. |
# Check for network failure |
':resourcedata',$chome); |
if (!ref($courseopt)) { |
# Check for network failure |
if ( $courseopt =~ /no.such.host/i || $courseopt =~ /con_lost/i) { |
if ( $reply =~ /no.such.host/i || $reply =~ /con_lost/i) { |
$self->{NETWORK_FAILURE} = 1; |
$self->{NETWORK_FAILURE} = 1; |
|
} elsif ($reply!~/^error\:/) { |
|
$courserdatas{$cid}=$reply; |
|
$courserdatas{$cid.'.last_cache'}=time; |
|
} |
|
} |
|
foreach (split(/\&/,$courserdatas{$cid})) { |
|
my ($name,$value)=split(/\=/,$_); |
|
$courseopt{$userprefix.&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} |
} |
|
undef($courseopt); |
|
} |
|
|
# --------------------------------------------------- Get userdata (if present) |
# --------------------------------------------------- Get userdata (if present) |
unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
|
my $reply=&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); |
my $useropt=&Apache::lonnet::get_userresdata($uname,$udom); |
if ($reply!~/^error\:/) { |
# Check for network failure |
$userrdatas{$uname.'___'.$udom}=$reply; |
if (!ref($useropt)) { |
$userrdatas{$uname.'___'.$udom.'.last_cache'}=time; |
if ( $useropt =~ /no.such.host/i || $useropt =~ /con_lost/i) { |
} |
$self->{NETWORK_FAILURE} = 1; |
# check to see if network failed |
|
elsif ( $reply=~/no.such.host/i || $reply=~/con.*lost/i ) |
|
{ |
|
$self->{NETWORK_FAILURE} = 1; |
|
} |
|
} |
|
foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { |
|
my ($name,$value)=split(/\=/,$_); |
|
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} |
} |
$self->{COURSE_OPT} = \%courseopt; |
undef($useropt); |
$self->{USER_OPT} = \%useropt; |
|
} |
} |
|
|
|
$self->{COURSE_OPT} = $courseopt; |
|
$self->{USER_OPT} = $useropt; |
|
|
$self->{COURSE_USER_OPT_GENERATED} = 1; |
$self->{COURSE_USER_OPT_GENERATED} = 1; |
|
|
return; |
return; |
Line 2164 sub generate_email_discuss_status {
|
Line 1887 sub generate_email_discuss_status {
|
my $symb = 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'}; |
my ($cdom,$cnum)=split(/\_/,$cid); |
my $cdom=$env{'course.'.$cid.'.domain'}; |
|
my $cnum=$env{'course.'.$cid.'.num'}; |
|
|
my %emailstatus = &Apache::lonnet::dump('email_status'); |
my %emailstatus = &Apache::lonnet::dump('email_status'); |
my $logoutTime = $emailstatus{'logout'}; |
my $logoutTime = $emailstatus{'logout'}; |
my $courseLeaveTime = $emailstatus{'logout_'.$ENV{'request.course.id'}}; |
my $courseLeaveTime = $emailstatus{'logout_'.$env{'request.course.id'}}; |
$self->{LAST_CHECK} = (($courseLeaveTime > $logoutTime) ? |
$self->{LAST_CHECK} = (($courseLeaveTime > $logoutTime) ? |
$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', |
my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss', |
$ENV{'user.domain'},$ENV{'user.name'},'lastread'); |
$env{'user.domain'},$env{'user.name'},'lastread'); |
my %lastreadtime = (); |
my %lastreadtime = (); |
foreach (keys %lastread) { |
foreach my $key (keys %lastread) { |
my $key = $_; |
my $shortkey = $key; |
$key =~ s/_lastread$//; |
$shortkey =~ s/_lastread$//; |
$lastreadtime{$key} = $lastread{$_}; |
$lastreadtime{$shortkey} = $lastread{$key}; |
} |
} |
|
|
my %feedback=(); |
my %feedback=(); |
my %error=(); |
my %error=(); |
my $keys = &Apache::lonnet::reply('keys:'. |
my @keys = &Apache::lonnet::getkeys('nohist_email',$env{'user.domain'}, |
$ENV{'user.domain'}.':'. |
$env{'user.name'}); |
$ENV{'user.name'}.':nohist_email', |
|
$ENV{'user.home'}); |
|
|
|
foreach my $msgid (split(/\&/, $keys)) { |
foreach my $msgid (@keys) { |
$msgid=&Apache::lonnet::unescape($msgid); |
|
if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { |
if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { |
my $plain= |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, |
&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); |
$symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); |
if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) { |
&Apache::lonenc::check_decrypt(\$symb); |
my ($what,$url)=($1,$2); |
if (($fromcid ne '') && ($fromcid ne $cid)) { |
if ($what eq 'Error') { |
next; |
$error{$url}.=','.$msgid; |
} |
} else { |
if (defined($symb)) { |
$feedback{$url}.=','.$msgid; |
if (defined($error) && $error == 1) { |
} |
$error{$symb}.=','.$msgid; |
} |
} else { |
|
$feedback{$symb}.=','.$msgid; |
|
} |
|
} else { |
|
my $plain= |
|
&LONCAPA::unescape(&LONCAPA::unescape($msgid)); |
|
if ($plain=~/ \[([^\]]+)\]\:/) { |
|
my $url=$1; |
|
if ($plain=~/\:Error \[/) { |
|
$error{$url}.=','.$msgid; |
|
} else { |
|
$feedback{$url}.=','.$msgid; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
|
|
#url's of resources that have feedbacks |
#symbs of resources that have feedbacks (will be urls pre-2.3) |
$self->{FEEDBACK} = \%feedback; |
$self->{FEEDBACK} = \%feedback; |
#or errors |
#or errors (will be urls pre 2.3) |
$self->{ERROR_MSG} = \%error; |
$self->{ERROR_MSG} = \%error; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{EMAIL_STATUS} = \%emailstatus; |
$self->{EMAIL_STATUS} = \%emailstatus; |
Line 2222 sub get_user_data {
|
Line 1957 sub get_user_data {
|
if ($self->{RETRIEVED_USER_DATA}) { return; } |
if ($self->{RETRIEVED_USER_DATA}) { return; } |
|
|
# Retrieve performance data on problems |
# Retrieve performance data on problems |
my %student_data = Apache::lonnet::currentdump($ENV{'request.course.id'}, |
my %student_data = Apache::lonnet::currentdump($env{'request.course.id'}, |
$ENV{'user.domain'}, |
$env{'user.domain'}, |
$ENV{'user.name'}); |
$env{'user.name'}); |
$self->{STUDENT_DATA} = \%student_data; |
$self->{STUDENT_DATA} = \%student_data; |
|
|
$self->{RETRIEVED_USER_DATA} = 1; |
$self->{RETRIEVED_USER_DATA} = 1; |
} |
} |
|
|
|
sub get_discussion_data { |
|
my $self = shift; |
|
if ($self->{RETRIEVED_DISCUSSION_DATA}) { |
|
return $self->{DISCUSSION_DATA}; |
|
} |
|
|
|
$self->generate_email_discuss_status(); |
|
|
|
my $cid=$env{'request.course.id'}; |
|
my $cdom=$env{'course.'.$cid.'.domain'}; |
|
my $cnum=$env{'course.'.$cid.'.num'}; |
|
# Retrieve discussion data for resources in course |
|
my %discussion_data = &Apache::lonnet::dumpstore($cid,$cdom,$cnum); |
|
|
|
|
|
$self->{DISCUSSION_DATA} = \%discussion_data; |
|
$self->{RETRIEVED_DISCUSSION_DATA} = 1; |
|
return $self->{DISCUSSION_DATA}; |
|
} |
|
|
|
|
# Internal function: Takes a key to look up in the nav hash and implements internal |
# Internal function: Takes a key to look up in the nav hash and implements internal |
# memory caching of that key. |
# memory caching of that key. |
sub navhash { |
sub navhash { |
Line 2249 sub navhash {
|
Line 2005 sub navhash {
|
# Checks to see if coursemap is defined, matching test in old lonnavmaps |
# Checks to see if coursemap is defined, matching test in old lonnavmaps |
sub courseMapDefined { |
sub courseMapDefined { |
my $self = shift; |
my $self = shift; |
my $uri = &Apache::lonnet::clutter($ENV{'request.course.uri'}); |
my $uri = &Apache::lonnet::clutter($env{'request.course.uri'}); |
|
|
my $firstres = $self->navhash("map_start_$uri"); |
my $firstres = $self->navhash("map_start_$uri"); |
my $lastres = $self->navhash("map_finish_$uri"); |
my $lastres = $self->navhash("map_finish_$uri"); |
Line 2259 sub courseMapDefined {
|
Line 2015 sub courseMapDefined {
|
sub getIterator { |
sub getIterator { |
my $self = shift; |
my $self = shift; |
my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift, |
my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift, |
shift, undef, shift); |
shift, undef, shift, |
|
shift, shift); |
return $iterator; |
return $iterator; |
} |
} |
|
|
# unties the hash when done |
|
sub untieHashes { |
|
my $self = shift; |
|
untie %{$self->{NAV_HASH}}; |
|
untie %{$self->{PARM_HASH}}; |
|
} |
|
|
|
# Private method: Does the given resource (as a symb string) have |
# Private method: Does the given resource (as a symb string) have |
# current discussion? Returns 0 if chat/mail data not extracted. |
# current discussion? Returns 0 if chat/mail data not extracted. |
sub hasDiscussion { |
sub hasDiscussion { |
my $self = shift; |
my $self = shift; |
my $symb = shift; |
my $symb = shift; |
|
|
$self->generate_email_discuss_status(); |
$self->generate_email_discuss_status(); |
|
|
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}); |
|
|
# backward compatibility (bulletin boards used to be 'wrapped') |
# backward compatibility (bulletin boards used to be 'wrapped') |
my $ressymb = $symb; |
my $ressymb = $self->wrap_symb($symb); |
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { |
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
|
} |
|
} |
|
|
|
if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) { |
if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) { |
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb}; |
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb}; |
} else { |
} else { |
Line 2298 sub hasDiscussion {
|
Line 2041 sub hasDiscussion {
|
} |
} |
} |
} |
|
|
|
sub last_post_time { |
|
my $self = shift; |
|
my $symb = shift; |
|
my $ressymb = $self->wrap_symb($symb); |
|
return $self->{DISCUSSION_TIME}->{$ressymb}; |
|
} |
|
|
|
sub discussion_info { |
|
my $self = shift; |
|
my $symb = shift; |
|
my $filter = shift; |
|
|
|
$self->get_discussion_data(); |
|
|
|
my $ressymb = $self->wrap_symb($symb); |
|
# keys used to store bulletinboard postings use 'unwrapped' symb. |
|
my $discsymb = &escape($self->unwrap_symb($ressymb)); |
|
my $version = $self->{DISCUSSION_DATA}{'version:'.$discsymb}; |
|
if (!$version) { return; } |
|
|
|
my $prevread = $self->{LAST_READ}{$ressymb}; |
|
|
|
my $count = 0; |
|
my $hiddenflag = 0; |
|
my $deletedflag = 0; |
|
my ($hidden,$deleted,%info); |
|
|
|
for (my $id=$version; $id>0; $id--) { |
|
my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$discsymb}; |
|
my @keys=split(/:/,$vkeys); |
|
if (grep(/^hidden$/ ,@keys)) { |
|
if (!$hiddenflag) { |
|
$hidden = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':hidden'}; |
|
$hiddenflag = 1; |
|
} |
|
} elsif (grep(/^deleted$/,@keys)) { |
|
if (!$deletedflag) { |
|
$deleted = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':deleted'}; |
|
$deletedflag = 1; |
|
} |
|
} else { |
|
if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./)) { |
|
if ($filter eq 'unread') { |
|
if ($prevread >= $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':timestamp'}) { |
|
next; |
|
} |
|
} |
|
$count++; |
|
$info{$count}{'subject'} = |
|
$self->{DISCUSSION_DATA}{$id.':'.$discsymb.':subject'}; |
|
$info{$count}{'id'} = $id; |
|
$info{$count}{'timestamp'} = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':timestamp'}; |
|
} |
|
} |
|
} |
|
if (wantarray) { |
|
return ($count,%info); |
|
} |
|
return $count; |
|
} |
|
|
|
sub wrap_symb { |
|
my $self = shift; |
|
my $symb = shift; |
|
if ($symb =~ m-___(adm/[^/]+/[^/]+/)(\d+)(/bulletinboard)$-) { |
|
unless ($symb =~ m|adm/wrapper/adm|) { |
|
$symb = 'bulletin___'.$2.'___adm/wrapper/'.$1.$2.$3; |
|
} |
|
} |
|
return $symb; |
|
} |
|
|
|
sub unwrap_symb { |
|
my $self = shift; |
|
my $ressymb = shift; |
|
my $discsymb = $ressymb; |
|
if ($ressymb =~ m-^(bulletin___\d+___)adm/wrapper/(adm/[^/]+/[^/]+/\d+/bulletinboard)$-) { |
|
$discsymb = $1.$2; |
|
} |
|
return $discsymb; |
|
} |
|
|
# Private method: Does the given resource (as a symb string) have |
# Private method: Does the given resource (as a symb string) have |
# current feedback? Returns the string in the feedback hash, which |
# current feedback? Returns the string in the feedback hash, which |
# will be false if it does not exist. |
# will be false if it does not exist. |
|
|
sub getFeedback { |
sub getFeedback { |
my $self = shift; |
my $self = shift; |
my $symb = shift; |
my $symb = shift; |
|
my $source = shift; |
|
|
$self->generate_email_discuss_status(); |
$self->generate_email_discuss_status(); |
|
|
if (!defined($self->{FEEDBACK})) { return ""; } |
if (!defined($self->{FEEDBACK})) { return ""; } |
|
|
return $self->{FEEDBACK}->{$symb}; |
my $feedback; |
|
if ($self->{FEEDBACK}->{$symb}) { |
|
$feedback = $self->{FEEDBACK}->{$symb}; |
|
if ($self->{FEEDBACK}->{$source}) { |
|
$feedback .= ','.$self->{FEEDBACK}->{$source}; |
|
} |
|
} else { |
|
if ($self->{FEEDBACK}->{$source}) { |
|
$feedback = $self->{FEEDBACK}->{$source}; |
|
} |
|
} |
|
return $feedback; |
} |
} |
|
|
# Private method: Get the errors for that resource (by source). |
# Private method: Get the errors for that resource (by source). |
sub getErrors { |
sub getErrors { |
my $self = shift; |
my $self = shift; |
|
my $symb = shift; |
my $src = shift; |
my $src = shift; |
|
|
$self->generate_email_discuss_status(); |
$self->generate_email_discuss_status(); |
|
|
if (!defined($self->{ERROR_MSG})) { return ""; } |
if (!defined($self->{ERROR_MSG})) { return ""; } |
return $self->{ERROR_MSG}->{$src}; |
|
|
my $errors; |
|
if ($self->{ERROR_MSG}->{$symb}) { |
|
$errors = $self->{ERROR_MSG}->{$symb}; |
|
if ($self->{ERROR_MSG}->{$src}) { |
|
$errors .= ','.$self->{ERROR_MSG}->{$src}; |
|
} |
|
} else { |
|
if ($self->{ERROR_MSG}->{$src}) { |
|
$errors = $self->{ERROR_MSG}->{$src}; |
|
} |
|
} |
|
return $errors; |
} |
} |
|
|
=pod |
=pod |
Line 2346 the given map. This is one of the proper
|
Line 2197 the given map. This is one of the proper
|
|
|
# The strategy here is to cache the resource objects, and only construct them |
# The strategy here is to cache the resource objects, and only construct them |
# as we use them. The real point is to prevent reading any more from the tied |
# as we use them. The real point is to prevent reading any more from the tied |
# hash then we have to, which should hopefully alleviate speed problems. |
# hash than we have to, which should hopefully alleviate speed problems. |
|
|
sub getById { |
sub getById { |
my $self = shift; |
my $self = shift; |
Line 2396 resource in the navmap.
|
Line 2247 resource in the navmap.
|
sub firstResource { |
sub firstResource { |
my $self = shift; |
my $self = shift; |
my $firstResource = $self->navhash('map_start_' . |
my $firstResource = $self->navhash('map_start_' . |
&Apache::lonnet::clutter($ENV{'request.course.uri'})); |
&Apache::lonnet::clutter($env{'request.course.uri'})); |
return $self->getById($firstResource); |
return $self->getById($firstResource); |
} |
} |
|
|
Line 2412 in the navmap.
|
Line 2263 in the navmap.
|
sub finishResource { |
sub finishResource { |
my $self = shift; |
my $self = shift; |
my $firstResource = $self->navhash('map_finish_' . |
my $firstResource = $self->navhash('map_finish_' . |
&Apache::lonnet::clutter($ENV{'request.course.uri'})); |
&Apache::lonnet::clutter($env{'request.course.uri'})); |
return $self->getById($firstResource); |
return $self->getById($firstResource); |
} |
} |
|
|
Line 2439 sub parmval_real {
|
Line 2290 sub parmval_real {
|
# Make sure the {USER_OPT} and {COURSE_OPT} hashes are populated |
# Make sure the {USER_OPT} and {COURSE_OPT} hashes are populated |
$self->generate_course_user_opt(); |
$self->generate_course_user_opt(); |
|
|
my $cid=$ENV{'request.course.id'}; |
my $cid=$env{'request.course.id'}; |
my $csec=$ENV{'request.course.sec'}; |
my $csec=$env{'request.course.sec'}; |
my $uname=$ENV{'user.name'}; |
my $cgroup=''; |
my $udom=$ENV{'user.domain'}; |
my @cgrps=split(/:/,$env{'request.course.groups'}); |
|
if (@cgrps > 0) { |
|
@cgrps = sort(@cgrps); |
|
$cgroup = $cgrps[0]; |
|
} |
|
my $uname=$env{'user.name'}; |
|
my $udom=$env{'user.domain'}; |
|
|
unless ($symb) { return ''; } |
unless ($symb) { return ''; } |
my $result=''; |
my $result=''; |
|
|
my ($mapname,$id,$fn)=&Apache::lonnet::decode_symb($symb); |
my ($mapname,$id,$fn)=&Apache::lonnet::decode_symb($symb); |
|
$mapname = &Apache::lonnet::deversion($mapname); |
# ----------------------------------------------------- Cascading lookup scheme |
# ----------------------------------------------------- Cascading lookup scheme |
my $rwhat=$what; |
my $rwhat=$what; |
$what=~s/^parameter\_//; |
$what=~s/^parameter\_//; |
Line 2456 sub parmval_real {
|
Line 2313 sub parmval_real {
|
|
|
my $symbparm=$symb.'.'.$what; |
my $symbparm=$symb.'.'.$what; |
my $mapparm=$mapname.'___(all).'.$what; |
my $mapparm=$mapname.'___(all).'.$what; |
my $usercourseprefix=$uname.'_'.$udom.'_'.$cid; |
my $usercourseprefix=$cid; |
|
|
|
my $grplevel=$usercourseprefix.'.['.$cgroup.'].'.$what; |
|
my $grplevelr=$usercourseprefix.'.['.$cgroup.'].'.$symbparm; |
|
my $grplevelm=$usercourseprefix.'.['.$cgroup.'].'.$mapparm; |
|
|
my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; |
my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; |
my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; |
my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; |
Line 2478 sub parmval_real {
|
Line 2339 sub parmval_real {
|
} |
} |
|
|
# ------------------------------------------------------- second, check course |
# ------------------------------------------------------- second, check course |
|
if ($cgroup ne '' and defined($courseopt)) { |
|
if (defined($$courseopt{$grplevelr})) { return $$courseopt{$grplevelr}; } |
|
if (defined($$courseopt{$grplevelm})) { return $$courseopt{$grplevelm}; } |
|
if (defined($$courseopt{$grplevel})) { return $$courseopt{$grplevel}; } |
|
} |
|
|
if ($csec and defined($courseopt)) { |
if ($csec and defined($courseopt)) { |
if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; } |
if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; } |
if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; } |
if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; } |
Line 2486 sub parmval_real {
|
Line 2353 sub parmval_real {
|
|
|
if (defined($courseopt)) { |
if (defined($courseopt)) { |
if (defined($$courseopt{$courselevelr})) { return $$courseopt{$courselevelr}; } |
if (defined($$courseopt{$courselevelr})) { return $$courseopt{$courselevelr}; } |
if (defined($$courseopt{$courselevelm})) { return $$courseopt{$courselevelm}; } |
|
if (defined($$courseopt{$courselevel})) { return $$courseopt{$courselevel}; } |
|
} |
} |
|
|
# ----------------------------------------------------- third, check map parms |
# ----------------------------------------------------- third, check map parms |
Line 2504 sub parmval_real {
|
Line 2369 sub parmval_real {
|
$default=&Apache::lonnet::metadata($fn,'parameter_'.$meta_rwhat); |
$default=&Apache::lonnet::metadata($fn,'parameter_'.$meta_rwhat); |
if (defined($default)) { return $default} |
if (defined($default)) { return $default} |
|
|
# --------------------------------------------------- fifth , cascade up parts |
# --------------------------------------------------- fifth, check more course |
|
if (defined($courseopt)) { |
|
if (defined($$courseopt{$courselevelm})) { return $$courseopt{$courselevelm}; } |
|
if (defined($$courseopt{$courselevel})) { return $$courseopt{$courselevel}; } |
|
} |
|
|
|
# --------------------------------------------------- sixth , cascade up parts |
|
|
my ($space,@qualifier)=split(/\./,$rwhat); |
my ($space,@qualifier)=split(/\./,$rwhat); |
my $qualifier=join('.',@qualifier); |
my $qualifier=join('.',@qualifier); |
Line 2524 sub parmval_real {
|
Line 2395 sub parmval_real {
|
|
|
=pod |
=pod |
|
|
=item * B<getResourceByUrl>(url): |
=item * B<getResourceByUrl>(url,multiple): |
|
|
Retrieves a resource object by URL of the resource. If passed a |
Retrieves a resource object by URL of the resource, unless the optional |
resource object, it will simply return it, so it is safe to use this |
multiple parameter is included in which case an array of resource |
method in code like "$res = $navmap->getResourceByUrl($res)", if |
objects is returned. If passed a resource object, it will simply return |
you're not sure if $res is already an object, or just a URL. If the |
it, so it is safe to use this method in code like |
resource appears multiple times in the course, only the first instance |
"$res = $navmap->getResourceByUrl($res)" |
will be returned. As a result, this is probably useful only for maps. |
if you're not sure if $res is already an object, or just a URL. If the |
|
resource appears multiple times in the course, only the first instance |
|
will be returned (useful for maps), unless the multiple parameter has |
|
been included, in which case all instances are returned in an array. |
|
|
=item * B<retrieveResources>(map, filterFunc, recursive, bailout): |
=item * B<retrieveResources>(map, filterFunc, recursive, bailout, showall): |
|
|
The map is a specification of a map to retreive the resources from, |
The map is a specification of a map to retreive the resources from, |
either as a url or as an object. The filterFunc is a reference to a |
either as a url or as an object. The filterFunc is a reference to a |
Line 2541 function that takes a resource object as
|
Line 2415 function that takes a resource object as
|
true if the resource should be included, or false if it should not |
true if the resource should be included, or false if it should not |
be. If recursive is true, the map will be recursively examined, |
be. If recursive is true, the map will be recursively examined, |
otherwise it will not be. If bailout is true, the function will return |
otherwise it will not be. If bailout is true, the function will return |
as soon as it finds a resource, if false it will finish. By default, |
as soon as it finds a resource, if false it will finish. If showall is |
the map is the top-level map of the course, filterFunc is a function |
true it will not hide maps that contain nothing but one other map. By |
that always returns 1, recursive is true, bailout is false. The |
default, the map is the top-level map of the course, filterFunc is a |
resources will be returned in a list containing the resource objects |
function that always returns 1, recursive is true, bailout is false, |
for the corresponding resources, with B<no structure information> in |
showall is false. The resources will be returned in a list containing |
the list; regardless of branching, recursion, etc., it will be a flat |
the resource objects for the corresponding resources, with B<no |
list. |
structure information> in the list; regardless of branching, |
|
recursion, etc., it will be a flat list. |
|
|
Thus, this is suitable for cases where you don't want the structure, |
Thus, this is suitable for cases where you don't want the structure, |
just a list of all resources. It is also suitable for finding out how |
just a list of all resources. It is also suitable for finding out how |
Line 2556 want to know is if I<any> resources matc
|
Line 2431 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<hasResource>(map, filterFunc, recursive): |
=item * B<hasResource>(map, filterFunc, recursive, showall): |
|
|
Convience method for |
Convenience method for |
|
|
scalar(retrieveResources($map, $filterFunc, $recursive, 1)) > 0 |
scalar(retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0 |
|
|
which will tell whether the map has resources matching the description |
which will tell whether the map has resources matching the description |
in the filter function. |
in the filter function. |
|
|
|
=item * B<usedVersion>(url): |
|
|
|
Retrieves version infomation for a url. Returns the version (a number, or |
|
the string "mostrecent") for resources which have version information in |
|
the big hash. |
|
|
=cut |
=cut |
|
|
|
|
sub getResourceByUrl { |
sub getResourceByUrl { |
my $self = shift; |
my $self = shift; |
my $resUrl = shift; |
my $resUrl = shift; |
|
my $multiple = shift; |
|
|
if (ref($resUrl)) { return $resUrl; } |
if (ref($resUrl)) { return $resUrl; } |
|
|
$resUrl = &Apache::lonnet::clutter($resUrl); |
$resUrl = &Apache::lonnet::clutter($resUrl); |
my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl}; |
my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl}; |
if ($resId =~ /,/) { |
|
$resId = (split (/,/, $resId))[0]; |
|
} |
|
if (!$resId) { return ''; } |
if (!$resId) { return ''; } |
return $self->getById($resId); |
if ($multiple) { |
|
my @resources = (); |
|
my @resIds = split (/,/, $resId); |
|
foreach my $id (@resIds) { |
|
my $resourceId = $self->getById($id); |
|
if ($resourceId) { |
|
push(@resources,$resourceId); |
|
} |
|
} |
|
return @resources; |
|
} else { |
|
if ($resId =~ /,/) { |
|
$resId = (split (/,/, $resId))[0]; |
|
} |
|
return $self->getById($resId); |
|
} |
} |
} |
|
|
sub retrieveResources { |
sub retrieveResources { |
Line 2594 sub retrieveResources {
|
Line 2488 sub retrieveResources {
|
if (!defined($recursive)) { $recursive = 1; } |
if (!defined($recursive)) { $recursive = 1; } |
my $bailout = shift; |
my $bailout = shift; |
if (!defined($bailout)) { $bailout = 0; } |
if (!defined($bailout)) { $bailout = 0; } |
|
my $showall = shift; |
# Create the necessary iterator. |
# Create the necessary iterator. |
if (!ref($map)) { # assume it's a url of a map. |
if (!ref($map)) { # assume it's a url of a map. |
$map = $self->getResourceByUrl($map); |
$map = $self->getResourceByUrl($map); |
Line 2613 sub retrieveResources {
|
Line 2507 sub retrieveResources {
|
|
|
# Get an iterator. |
# Get an iterator. |
my $it = $self->getIterator($map->map_start(), $map->map_finish(), |
my $it = $self->getIterator($map->map_start(), $map->map_finish(), |
undef, $recursive); |
undef, $recursive, $showall); |
|
|
my @resources = (); |
my @resources = (); |
|
|
Line 2643 sub hasResource {
|
Line 2537 sub hasResource {
|
my $map = shift; |
my $map = shift; |
my $filterFunc = shift; |
my $filterFunc = shift; |
my $recursive = shift; |
my $recursive = shift; |
|
my $showall = shift; |
|
|
return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1)) > 0; |
return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0; |
|
} |
|
|
|
sub usedVersion { |
|
my $self = shift; |
|
my $linkurl = shift; |
|
return $self->navhash("version_$linkurl"); |
} |
} |
|
|
1; |
1; |
|
|
package Apache::lonnavmaps::iterator; |
package Apache::lonnavmaps::iterator; |
|
use Scalar::Util qw(weaken); |
|
use Apache::lonnet; |
|
|
=pod |
=pod |
|
|
Line 2764 be the tokens described above.
|
Line 2667 be the tokens described above.
|
|
|
Also note there is some old code floating around that trys to track |
Also note there is some old code floating around that trys to track |
the depth of the iterator to see when it's done; do not copy that |
the depth of the iterator to see when it's done; do not copy that |
code. It is difficult to get right and harder to understand then |
code. It is difficult to get right and harder to understand than |
this. They should be migrated to this new style. |
this. They should be migrated to this new style. |
|
|
=cut |
=cut |
Line 2790 sub new {
|
Line 2693 sub new {
|
my $class = ref($proto) || $proto; |
my $class = ref($proto) || $proto; |
my $self = {}; |
my $self = {}; |
|
|
$self->{NAV_MAP} = shift; |
weaken($self->{NAV_MAP} = shift); |
return undef unless ($self->{NAV_MAP}); |
return undef unless ($self->{NAV_MAP}); |
|
|
# Handle the parameters |
# Handle the parameters |
Line 2910 sub new {
|
Line 2813 sub new {
|
Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, |
Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, |
$finishResource, $self->{FILTER}, |
$finishResource, $self->{FILTER}, |
$self->{ALREADY_SEEN}, |
$self->{ALREADY_SEEN}, |
$self->{CONDITION}, 0); |
$self->{CONDITION}, |
|
$self->{FORCE_TOP}); |
|
|
} |
} |
|
|
Line 3048 sub next {
|
Line 2952 sub next {
|
} |
} |
|
|
# Is this the end of a branch? If so, all of the resources examined above |
# Is this the end of a branch? If so, all of the resources examined above |
# led to lower levels then the one we are currently at, so we push a END_BRANCH |
# led to lower levels than the one we are currently at, so we push a END_BRANCH |
# marker onto the stack so we don't forget. |
# marker onto the stack so we don't forget. |
# Example: For the usual A(BC)(DE)F case, when the iterator goes down the |
# Example: For the usual A(BC)(DE)F case, when the iterator goes down the |
# BC branch and gets to C, it will see F as the only next resource, but it's |
# BC branch and gets to C, it will see F as the only next resource, but it's |
Line 3073 sub next {
|
Line 2977 sub next {
|
$self->{RECURSIVE_ITERATOR} = |
$self->{RECURSIVE_ITERATOR} = |
Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, |
Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, |
$finishResource, $self->{FILTER}, |
$finishResource, $self->{FILTER}, |
$self->{ALREADY_SEEN}, $self->{CONDITION}); |
$self->{ALREADY_SEEN}, |
|
$self->{CONDITION}, |
|
$self->{FORCE_TOP}); |
} |
} |
|
|
# If this is a blank resource, don't actually return it. |
# If this is a blank resource, don't actually return it. |
Line 3126 sub populateStack {
|
Line 3032 sub populateStack {
|
1; |
1; |
|
|
package Apache::lonnavmaps::DFSiterator; |
package Apache::lonnavmaps::DFSiterator; |
|
use Scalar::Util qw(weaken); |
|
use Apache::lonnet; |
|
|
# Not documented in the perldoc: This is a simple iterator that just walks |
# Not documented in the perldoc: This is a simple iterator that just walks |
# through the nav map and presents the resources in a depth-first search |
# through the nav map and presents the resources in a depth-first search |
Line 3154 sub new {
|
Line 3062 sub new {
|
my $class = ref($proto) || $proto; |
my $class = ref($proto) || $proto; |
my $self = {}; |
my $self = {}; |
|
|
$self->{NAV_MAP} = shift; |
weaken($self->{NAV_MAP} = shift); |
return undef unless ($self->{NAV_MAP}); |
return undef unless ($self->{NAV_MAP}); |
|
|
$self->{FIRST_RESOURCE} = shift || $self->{NAV_MAP}->firstResource(); |
$self->{FIRST_RESOURCE} = shift || $self->{NAV_MAP}->firstResource(); |
Line 3253 sub next {
|
Line 3161 sub next {
|
|
|
# filter the next possibilities to remove things we've |
# filter the next possibilities to remove things we've |
# already seen. |
# already seen. |
foreach (@$nextUnfiltered) { |
foreach my $item (@$nextUnfiltered) { |
if (!defined($self->{ALREADY_SEEN}->{$_->{ID}})) { |
if (!defined($self->{ALREADY_SEEN}->{$item->{ID}})) { |
push @$next, $_; |
push @$next, $item; |
} |
} |
} |
} |
|
|
Line 3308 sub populateStack {
|
Line 3216 sub populateStack {
|
1; |
1; |
|
|
package Apache::lonnavmaps::resource; |
package Apache::lonnavmaps::resource; |
|
use Scalar::Util qw(weaken); |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
=pod |
=pod |
Line 3380 X<symb> X<resource, symb>
|
Line 3288 X<symb> X<resource, symb>
|
All resources also have B<symb>s, which uniquely identify a resource |
All resources also have B<symb>s, which uniquely identify a resource |
in a course. Many internal LON-CAPA functions expect a symb. A symb |
in a course. Many internal LON-CAPA functions expect a symb. A symb |
carries along with it the URL of the resource, and the map it appears |
carries along with it the URL of the resource, and the map it appears |
in. Symbs are much larger then resource IDs. |
in. Symbs are much larger than resource IDs. |
|
|
=cut |
=cut |
|
|
Line 3390 sub new {
|
Line 3298 sub new {
|
my $class = ref($proto) || $proto; |
my $class = ref($proto) || $proto; |
my $self = {}; |
my $self = {}; |
|
|
$self->{NAV_MAP} = shift; |
weaken($self->{NAV_MAP} = shift); |
$self->{ID} = shift; |
$self->{ID} = shift; |
|
|
# Store this new resource in the parent nav map's cache. |
# Store this new resource in the parent nav map's cache. |
Line 3478 Returns the title of the resource.
|
Line 3386 Returns the title of the resource.
|
# These info functions can be used directly, as they don't return |
# These info functions can be used directly, as they don't return |
# resource information. |
# resource information. |
sub comesfrom { my $self=shift; return $self->navHash("comesfrom_", 1); } |
sub comesfrom { my $self=shift; return $self->navHash("comesfrom_", 1); } |
|
sub encrypted { my $self=shift; return $self->navHash("encrypted_", 1); } |
sub ext { my $self=shift; return $self->navHash("ext_", 1) eq 'true:'; } |
sub ext { my $self=shift; return $self->navHash("ext_", 1) eq 'true:'; } |
sub from { my $self=shift; return $self->navHash("from_", 1); } |
sub from { my $self=shift; return $self->navHash("from_", 1); } |
# considered private and undocumented |
# considered private and undocumented |
Line 3486 sub kind { my $self=shift; return $self-
|
Line 3395 sub kind { my $self=shift; return $self-
|
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); } |
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); } |
sub randompick { |
sub randompick { |
my $self = shift; |
my $self = shift; |
return $self->{NAV_MAP}->{PARM_HASH}->{$self->symb . |
return $self->parmval('randompick'); |
'.0.parameter_randompick'}; |
} |
|
sub link { |
|
my $self=shift; |
|
if ($self->encrypted()) { return &Apache::lonenc::encrypted($self->src); } |
|
return $self->src; |
} |
} |
sub src { |
sub src { |
my $self=shift; |
my $self=shift; |
return $self->navHash("src_", 1); |
return $self->navHash("src_", 1); |
} |
} |
|
sub shown_symb { |
|
my $self=shift; |
|
if ($self->encrypted()) {return &Apache::lonenc::encrypted($self->symb());} |
|
return $self->symb(); |
|
} |
|
sub id { |
|
my $self=shift; |
|
return $self->{ID}; |
|
} |
|
sub enclosing_map_src { |
|
my $self=shift; |
|
(my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/; |
|
return $self->navHash('map_id_'.$first); |
|
} |
sub symb { |
sub symb { |
my $self=shift; |
my $self=shift; |
(my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/; |
(my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/; |
Line 3501 sub symb {
|
Line 3428 sub symb {
|
. '___' . $second . '___' . $symbSrc; |
. '___' . $second . '___' . $symbSrc; |
return &Apache::lonnet::symbclean($symb); |
return &Apache::lonnet::symbclean($symb); |
} |
} |
|
sub wrap_symb { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->wrap_symb($self->symb()); |
|
} |
sub title { |
sub title { |
my $self=shift; |
my $self=shift; |
if ($self->{ID} eq '0.0') { |
if ($self->{ID} eq '0.0') { |
# If this is the top-level map, return the title of the course |
# If this is the top-level map, return the title of the course |
# since this map can not be titled otherwise. |
# since this map can not be titled otherwise. |
return $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
return $env{'course.'.$env{'request.course.id'}.'.description'}; |
} |
} |
return $self->navHash("title_", 1); } |
return $self->navHash("title_", 1); } |
# considered private and undocumented |
# considered private and undocumented |
sub to { my $self=shift; return $self->navHash("to_", 1); } |
sub to { my $self=shift; return $self->navHash("to_", 1); } |
|
sub condition { |
|
my $self=shift; |
|
my $undercond=$self->navHash("undercond_", 1); |
|
if (!defined($undercond)) { return 1; }; |
|
my $condid=$self->navHash("condid_$undercond"); |
|
if (!defined($condid)) { return 1; }; |
|
my $condition=&Apache::lonnet::directcondval($condid); |
|
return $condition; |
|
} |
|
sub condval { |
|
my $self=shift; |
|
my ($pathname,$filename) = |
|
&Apache::lonnet::split_uri_for_cond($self->src()); |
|
|
|
my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~ |
|
/\&\Q$filename\E\:([\d\|]+)\&/); |
|
if ($match) { |
|
return &Apache::lonnet::condval($1); |
|
} |
|
return 0; |
|
} |
sub compTitle { |
sub compTitle { |
my $self = shift; |
my $self = shift; |
my $title = $self->title(); |
my $title = $self->title(); |
Line 3561 sub retrieveResources {
|
Line 3513 sub retrieveResources {
|
return $self->{NAV_MAP}->retrieveResources(@_); |
return $self->{NAV_MAP}->retrieveResources(@_); |
} |
} |
|
|
|
sub is_exam { |
|
my ($self,$part) = @_; |
|
if ($self->parmval('type',$part) eq 'exam') { |
|
return 1; |
|
} |
|
if ($self->src() =~ /\.(exam)$/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
sub is_html { |
sub is_html { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
Line 3573 sub is_page {
|
Line 3535 sub is_page {
|
return $self->navHash("is_map_", 1) && |
return $self->navHash("is_map_", 1) && |
$self->navHash("map_type_" . $self->map_pc()) eq 'page'; |
$self->navHash("map_type_" . $self->map_pc()) eq 'page'; |
} |
} |
|
sub is_practice { |
|
my $self=shift; |
|
my ($part) = @_; |
|
if ($self->parmval('type',$part) eq 'practice') { |
|
return 1; |
|
} |
|
return 0; |
|
} |
sub is_problem { |
sub is_problem { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library)$/) |
if ($src =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) { |
|
return !($self->is_practice()); |
|
} |
|
return 0; |
} |
} |
sub contains_problem { |
sub contains_problem { |
my $self=shift; |
my $self=shift; |
Line 3588 sub contains_problem {
|
Line 3561 sub contains_problem {
|
} |
} |
sub is_sequence { |
sub is_sequence { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
|
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'; |
} |
} |
Line 3603 sub is_survey {
|
Line 3575 sub is_survey {
|
} |
} |
return 0; |
return 0; |
} |
} |
|
sub is_task { |
|
my $self=shift; |
|
my $src = $self->src(); |
|
return ($src =~ /\.(task)$/) |
|
} |
|
|
sub is_empty_sequence { |
sub is_empty_sequence { |
my $self=shift; |
my $self=shift; |
Line 3658 Returns a string with the type of the ma
|
Line 3635 Returns a string with the type of the ma
|
sub map_finish { |
sub map_finish { |
my $self = shift; |
my $self = shift; |
my $src = $self->src(); |
my $src = $self->src(); |
$src = Apache::lonnet::clutter($src); |
$src = &Apache::lonnet::clutter($src); |
my $res = $self->navHash("map_finish_$src", 0); |
my $res = $self->navHash("map_finish_$src", 0); |
$res = $self->{NAV_MAP}->getById($res); |
$res = $self->{NAV_MAP}->getById($res); |
return $res; |
return $res; |
Line 3671 sub map_pc {
|
Line 3648 sub map_pc {
|
sub map_start { |
sub map_start { |
my $self = shift; |
my $self = shift; |
my $src = $self->src(); |
my $src = $self->src(); |
$src = Apache::lonnet::clutter($src); |
$src = &Apache::lonnet::clutter($src); |
my $res = $self->navHash("map_start_$src", 0); |
my $res = $self->navHash("map_start_$src", 0); |
$res = $self->{NAV_MAP}->getById($res); |
$res = $self->{NAV_MAP}->getById($res); |
return $res; |
return $res; |
Line 3688 sub map_type {
|
Line 3665 sub map_type {
|
|
|
# These functions will be responsible for returning the CORRECT |
# These functions will be responsible for returning the CORRECT |
# VALUE for the parameter, no matter what. So while they may look |
# VALUE for the parameter, no matter what. So while they may look |
# like direct calls to parmval, they can be more then that. |
# like direct calls to parmval, they can be more than that. |
# So, for instance, the duedate function should use the "duedatetype" |
# So, for instance, the duedate function should use the "duedatetype" |
# information, rather then the resource object user. |
# information, rather than the resource object user. |
|
|
=pod |
=pod |
|
|
Line 3783 sub awarded {
|
Line 3760 sub awarded {
|
if (!defined($part)) { $part = '0'; } |
if (!defined($part)) { $part = '0'; } |
return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'}; |
return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'}; |
} |
} |
|
# this should work exactly like the copy in lonhomework.pm |
sub duedate { |
sub duedate { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
|
my $date; |
my $interval=$self->parmval("interval", $part); |
my $interval=$self->parmval("interval", $part); |
if ($interval) { |
my $due_date=$self->parmval("duedate", $part); |
|
if ($interval =~ /\d+/) { |
my $first_access=&Apache::lonnet::get_first_access('map',$self->symb); |
my $first_access=&Apache::lonnet::get_first_access('map',$self->symb); |
if ($first_access) { return ($first_access+$interval); } |
if (defined($first_access)) { |
|
$interval = $first_access+$interval; |
|
$date = ($interval < $due_date)? $interval : $due_date; |
|
} else { |
|
$date = $due_date; |
|
} |
|
} else { |
|
$date = $due_date; |
} |
} |
return $self->parmval("duedate", $part); |
return $date; |
|
} |
|
sub handgrade { |
|
(my $self, my $part) = @_; |
|
return $self->parmval("handgrade", $part); |
} |
} |
sub maxtries { |
sub maxtries { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
Line 3830 sub weight {
|
Line 3821 sub weight {
|
my $self = shift; my $part = shift; |
my $self = shift; my $part = shift; |
if (!defined($part)) { $part = '0'; } |
if (!defined($part)) { $part = '0'; } |
return &Apache::lonnet::EXT('resource.'.$part.'.weight', |
return &Apache::lonnet::EXT('resource.'.$part.'.weight', |
$self->symb(), $ENV{'user.domain'}, |
$self->symb(), $env{'user.domain'}, |
$ENV{'user.name'}, |
$env{'user.name'}, |
$ENV{'request.course.sec'}); |
$env{'request.course.sec'}); |
} |
} |
sub part_display { |
sub part_display { |
my $self= shift(); my $partID = shift(); |
my $self= shift(); my $partID = shift(); |
Line 3883 Returns a false value if there has been
|
Line 3874 Returns a false value if there has been
|
logged in, true if there has. Always returns false if the discussion |
logged in, true if there has. Always returns false if the discussion |
data was not extracted when the nav map was constructed. |
data was not extracted when the nav map was constructed. |
|
|
|
=item * B<last_post_time>: |
|
|
|
Returns a false value if there hasn't been discussion otherwise returns |
|
unix timestamp of last time a discussion posting (or edit) was made. |
|
|
|
=item * B<discussion_info>: |
|
|
|
optional argument is a filter (currently can be 'unread'); |
|
returns in scalar context the count of the number of discussion postings. |
|
|
|
returns in list context both the count of postings and a hash ref |
|
containing information about the postings (subject, id, timestamp) in a hash. |
|
|
|
Default is to return counts for all postings. However if called with a second argument set to 'unread', will return information about only unread postings. |
|
|
=item * B<getFeedback>: |
=item * B<getFeedback>: |
|
|
Gets the feedback for the resource and returns the raw feedback string |
Gets the feedback for the resource and returns the raw feedback string |
Line 3890 for the resource, or the null string if
|
Line 3896 for the resource, or the null string if
|
email data was not extracted when the nav map was constructed. Usually |
email data was not extracted when the nav map was constructed. Usually |
used like this: |
used like this: |
|
|
for (split(/\,/, $res->getFeedback())) { |
for my $url (split(/\,/, $res->getFeedback())) { |
my $link = &Apache::lonnet::escape($_); |
my $link = &escape($url); |
... |
... |
|
|
and use the link as appropriate. |
and use the link as appropriate. |
Line 3903 sub hasDiscussion {
|
Line 3909 sub hasDiscussion {
|
return $self->{NAV_MAP}->hasDiscussion($self->symb()); |
return $self->{NAV_MAP}->hasDiscussion($self->symb()); |
} |
} |
|
|
|
sub last_post_time { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->last_post_time($self->symb()); |
|
} |
|
|
|
sub discussion_info { |
|
my ($self,$filter) = @_; |
|
return $self->{NAV_MAP}->discussion_info($self->symb(),$filter); |
|
} |
|
|
sub getFeedback { |
sub getFeedback { |
my $self = shift; |
my $self = shift; |
my $source = $self->src(); |
my $source = $self->src(); |
|
my $symb = $self->symb(); |
if ($source =~ /^\/res\//) { $source = substr $source, 5; } |
if ($source =~ /^\/res\//) { $source = substr $source, 5; } |
return $self->{NAV_MAP}->getFeedback($source); |
return $self->{NAV_MAP}->getFeedback($symb,$source); |
} |
} |
|
|
sub getErrors { |
sub getErrors { |
my $self = shift; |
my $self = shift; |
my $source = $self->src(); |
my $source = $self->src(); |
|
my $symb = $self->symb(); |
if ($source =~ /^\/res\//) { $source = substr $source, 5; } |
if ($source =~ /^\/res\//) { $source = substr $source, 5; } |
return $self->{NAV_MAP}->getErrors($source); |
return $self->{NAV_MAP}->getErrors($symb,$source); |
} |
} |
|
|
=pod |
=pod |
Line 4000 sub countResponses {
|
Line 4018 sub countResponses {
|
sub responseTypes { |
sub responseTypes { |
my $self = shift; |
my $self = shift; |
my %responses; |
my %responses; |
foreach my $part ($self->parts()) { |
foreach my $part (@{$self->parts()}) { |
foreach my $responsetype ($self->responseType($part)) { |
foreach my $responsetype ($self->responseType($part)) { |
$responses{$responsetype}++ if (defined($responsetype)); |
$responses{$responsetype}++ if (defined($responsetype)); |
} |
} |
Line 4075 sub extractParts {
|
Line 4093 sub extractParts {
|
$self->{PART_TYPE} = {}; |
$self->{PART_TYPE} = {}; |
return; |
return; |
} |
} |
foreach (split(/\,/,$metadata)) { |
foreach my $entry (split(/\,/,$metadata)) { |
if ($_ =~ /^part_(.*)$/) { |
if ($entry =~ /^(?:part|Task)_(.*)$/) { |
my $part = $1; |
my $part = $1; |
# This floods the logs if it blows up |
# This floods the logs if it blows up |
if (defined($parts{$part})) { |
if (defined($parts{$part})) { |
Line 4101 sub extractParts {
|
Line 4119 sub extractParts {
|
|
|
|
|
# Init the responseIdHash |
# Init the responseIdHash |
foreach (@{$self->{PARTS}}) { |
foreach my $part (@{$self->{PARTS}}) { |
$responseIdHash{$_} = []; |
$responseIdHash{$part} = []; |
} |
} |
|
|
# Now, the unfortunate thing about this is that parts, part name, and |
# Now, the unfortunate thing about this is that parts, part name, and |
Line 4111 sub extractParts {
|
Line 4129 sub extractParts {
|
# 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 |
# to construct ambiguous situations. |
# to construct ambiguous situations. |
foreach (split /,/, $metadata) { |
foreach my $data (split /,/, $metadata) { |
if ($_ =~ /^([a-zA-Z]+)response_(.*)/) { |
if ($data =~ /^([a-zA-Z]+)response_(.*)/ |
|
|| $data =~ /^(Task)_(.*)/) { |
my $responseType = $1; |
my $responseType = $1; |
my $partStuff = $2; |
my $partStuff = $2; |
my $partIdSoFar = ''; |
my $partIdSoFar = ''; |
Line 4124 sub extractParts {
|
Line 4143 sub extractParts {
|
if ($parts{$partIdSoFar}) { |
if ($parts{$partIdSoFar}) { |
my @otherChunks = @partChunks[$i+1..$#partChunks]; |
my @otherChunks = @partChunks[$i+1..$#partChunks]; |
my $responseId = join('_', @otherChunks); |
my $responseId = join('_', @otherChunks); |
push @{$responseIdHash{$partIdSoFar}}, $responseId; |
if ($self->is_task()) { |
push @{$responseTypeHash{$partIdSoFar}}, $responseType; |
push(@{$responseIdHash{$partIdSoFar}}, |
|
$partIdSoFar); |
|
} else { |
|
push(@{$responseIdHash{$partIdSoFar}}, |
|
$responseId); |
|
} |
|
push(@{$responseTypeHash{$partIdSoFar}}, |
|
$responseType); |
} |
} |
} |
} |
} |
} |
Line 4174 the completion information.
|
Line 4200 the completion information.
|
Idiomatic usage of these two methods would probably look something |
Idiomatic usage of these two methods would probably look something |
like |
like |
|
|
foreach ($resource->parts()) { |
foreach my $part ($resource->parts()) { |
my $dateStatus = $resource->getDateStatus($_); |
my $dateStatus = $resource->getDateStatus($part); |
my $completionStatus = $resource->getCompletionStatus($_); |
my $completionStatus = $resource->getCompletionStatus($part); |
|
|
or |
or |
|
|
my $status = $resource->status($_); |
my $status = $resource->status($part); |
|
|
... use it here ... |
... use it here ... |
} |
} |
Line 4341 sub ATTEMPTED { return 16; }
|
Line 4367 sub ATTEMPTED { return 16; }
|
|
|
sub getCompletionStatus { |
sub getCompletionStatus { |
my $self = shift; |
my $self = shift; |
|
my $part = shift; |
return $self->NETWORK_FAILURE if ($self->{NAV_MAP}->{NETWORK_FAILURE}); |
return $self->NETWORK_FAILURE if ($self->{NAV_MAP}->{NETWORK_FAILURE}); |
|
|
my $status = $self->queryRestoreHash('solved', shift); |
my $status = $self->queryRestoreHash('solved', $part); |
|
|
# Left as separate 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_scantron') {return $self->CORRECT;} |
if ($status eq 'correct_by_scantron') {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; } |
if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; } |
if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; } |
if ($status eq 'excused') {return $self->EXCUSED; } |
if ($status eq 'excused') {return $self->EXCUSED; } |
Line 4452 An answer has been submitted, but the st
|
Line 4481 An answer has been submitted, but the st
|
|
|
sub TRIES_LEFT { return 20; } |
sub TRIES_LEFT { return 20; } |
sub ANSWER_SUBMITTED { return 21; } |
sub ANSWER_SUBMITTED { return 21; } |
|
sub PARTIALLY_CORRECT{ return 22; } |
|
|
sub status { |
sub status { |
my $self = shift; |
my $self = shift; |
Line 4470 sub status {
|
Line 4500 sub status {
|
my $suppressFeedback = $self->problemstatus($part) eq 'no'; |
my $suppressFeedback = $self->problemstatus($part) eq 'no'; |
# If there's an answer date and we're past it, don't |
# If there's an answer date and we're past it, don't |
# suppress the feedback; student should know |
# suppress the feedback; student should know |
if ($self->answerdate($part) && $self->answerdate($part) < time()) { |
if ($self->duedate($part) && $self->duedate($part) < time() && |
|
$self->answerdate($part) && $self->answerdate($part) < time()) { |
$suppressFeedback = 0; |
$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 || |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
return $suppressFeedback? ANSWER_SUBMITTED : CORRECT; |
if ( $suppressFeedback ) { return ANSWER_SUBMITTED } |
|
my $awarded=$self->awarded($part); |
|
if ($awarded < 1 && $awarded > 0) { |
|
return PARTIALLY_CORRECT; |
|
} elsif ($awarded<1) { |
|
return INCORRECT; |
|
} |
|
return CORRECT; |
|
} |
|
|
|
# If it's WRONG... and not open |
|
if ( ($completionStatus == INCORRECT || |
|
$completionStatus == INCORRECT_BY_OVERRIDE) |
|
&& (!$self->opendate($part) || $self->opendate($part) > time()) ) { |
|
return INCORRECT; |
} |
} |
|
|
if ($completionStatus == ATTEMPTED) { |
if ($completionStatus == ATTEMPTED) { |
Line 4564 my %compositeToSimple =
|
Line 4609 my %compositeToSimple =
|
NETWORK_FAILURE() => ERROR, |
NETWORK_FAILURE() => ERROR, |
NOTHING_SET() => CLOSED, |
NOTHING_SET() => CLOSED, |
CORRECT() => CORRECT, |
CORRECT() => CORRECT, |
|
PARTIALLY_CORRECT() => PARTIALLY_CORRECT, |
EXCUSED() => CORRECT, |
EXCUSED() => CORRECT, |
PAST_DUE_NO_ANSWER() => INCORRECT, |
PAST_DUE_NO_ANSWER() => INCORRECT, |
PAST_DUE_ANSWER_LATER() => INCORRECT, |
PAST_DUE_ANSWER_LATER() => INCORRECT, |
Line 4684 sub getNext {
|
Line 4730 sub getNext {
|
my $to = $self->to(); |
my $to = $self->to(); |
foreach my $branch ( split(/,/, $to) ) { |
foreach my $branch ( split(/,/, $to) ) { |
my $choice = $self->{NAV_MAP}->getById($branch); |
my $choice = $self->{NAV_MAP}->getById($branch); |
|
#if (!$choice->condition()) { next; } |
my $next = $choice->goesto(); |
my $next = $choice->goesto(); |
$next = $self->{NAV_MAP}->getById($next); |
$next = $self->{NAV_MAP}->getById($next); |
|
|
Line 4712 sub browsePriv {
|
Line 4759 sub browsePriv {
|
return $self->{BROWSE_PRIV}; |
return $self->{BROWSE_PRIV}; |
} |
} |
|
|
$self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre', $self->src()); |
$self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre',$self->src(), |
|
$self->symb()); |
} |
} |
|
|
=pod |
=pod |