version 1.278, 2004/08/23 21:05:03
|
version 1.297, 2004/09/21 20:44:16
|
Line 84 my %colormap =
|
Line 84 my %colormap =
|
my $hurryUpColor = "#FF0000"; |
my $hurryUpColor = "#FF0000"; |
|
|
sub launch_win { |
sub launch_win { |
my ($mode,$script)=@_; |
my ($mode,$script,$toplinkitems)=@_; |
my $result; |
my $result; |
if ($script ne 'no') { |
if ($script ne 'no') { |
$result.='<script type="text/javascript">'; |
$result.='<script type="text/javascript">'; |
Line 99 sub launch_win {
|
Line 99 sub launch_win {
|
$result.='</script>'; |
$result.='</script>'; |
} |
} |
if ($mode eq 'link') { |
if ($mode eq 'link') { |
$result.='<a href="javascript:launch_navmapwin();void(0);">' |
&add_linkitem($toplinkitems,'launchnav','launch_navmapwin()', |
.&mt("Launch navigation window")."</a> "; |
"Launch navigation window"); |
} |
} |
return $result; |
return $result; |
} |
} |
Line 127 sub nav_control_js {
|
Line 127 sub nav_control_js {
|
|
|
function gonav(url) { |
function gonav(url) { |
if (w_loncapanav_flag != 1) { |
if (w_loncapanav_flag != 1) { |
go(url); |
gopost(url,''); |
} else { |
} else { |
navwindow=window.open(url, |
navwindow=window.open(url, |
"loncapanav","height=600,width=400,scrollbars=1"); |
"loncapanav","height=600,width=400,scrollbars=1"); |
Line 178 sub real_handler {
|
Line 178 sub real_handler {
|
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
|
|
|
my %toplinkitems=(); |
|
|
if ($ENV{QUERY_STRING} eq 'collapseExternal') { |
if ($ENV{QUERY_STRING} eq 'collapseExternal') { |
&Apache::lonnet::put('environment',{'remotenavmap' => 'off'}); |
&Apache::lonnet::put('environment',{'remotenavmap' => 'off'}); |
&Apache::lonnet::appenv('environment.remotenavmap' => 'off'); |
&Apache::lonnet::appenv('environment.remotenavmap' => 'off'); |
Line 189 sub real_handler {
|
Line 191 sub real_handler {
|
swmenu.clearTimeout(swmenu.menucltim); |
swmenu.clearTimeout(swmenu.menucltim); |
$navstatus |
$navstatus |
MENU |
MENU |
|
} else { |
|
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
|
my $mainwindow='window.open('.$nothing.',"loncapaclient","",false);'; |
|
$menu=(<<MENU) |
|
swmenu=$mainwindow |
|
$navstatus |
|
MENU |
} |
} |
$r->print(<<"ENDSUBM"); |
$r->print(<<"ENDSUBM"); |
<html> |
<html> |
Line 253 ENDSUBM
|
Line 262 ENDSUBM
|
&Apache::loncommon::bodytag('Navigate Course Contents','', |
&Apache::loncommon::bodytag('Navigate Course Contents','', |
$addentries,$body_only,'', |
$addentries,$body_only,'', |
$ENV{'form.register'})); |
$ENV{'form.register'})); |
$r->print('<script>window.focus();</script>'. |
$r->print('<script>window.focus();</script>'); |
&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT')); |
|
|
|
$r->rflush(); |
$r->rflush(); |
|
|
# Check that it's defined |
# Check that it's defined |
if (!($navmap->courseMapDefined())) { |
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>' . |
$r->print('<font size="+2" color="red">Coursemap undefined.</font>' . |
'</body></html>'); |
'</body></html>'); |
return OK; |
return OK; |
Line 301 ENDSUBM
|
Line 310 ENDSUBM
|
} |
} |
|
|
if ($ENV{'environment.remotenavmap'} ne 'on') { |
if ($ENV{'environment.remotenavmap'} ne 'on') { |
$r->print(&launch_win('link','yes')); |
$r->print(&launch_win('link','yes',\%toplinkitems)); |
} |
} |
if ($ENV{'environment.remotenavmap'} eq 'on') { |
if ($ENV{'environment.remotenavmap'} eq 'on') { |
# $r->print("<a href='navmaps?collapseExternal'>" . |
&add_linkitem(\%toplinkitems,'closenav','collapse()', |
$r->print("<a href='javascript:collapse();void(0);'>" . |
"Close navigation window"); |
&mt("Close navigation window"). |
|
"</a> "); |
|
} |
} |
|
|
my $jumpToFirstHomework = 0; |
my $jumpToFirstHomework = 0; |
# Check to see if the student is jumping to next open, do-able problem |
# Check to see if the student is jumping to next open, do-able problem |
if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') { |
if ($ENV{QUERY_STRING} =~ /^jumpToFirstHomework/) { |
$jumpToFirstHomework = 1; |
$jumpToFirstHomework = 1; |
# Find the next homework problem that they can do. |
# Find the next homework problem that they can do. |
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
Line 345 ENDSUBM
|
Line 352 ENDSUBM
|
$r->print("<font size='+2'>All homework assignments have been completed.</font><br /><br />"); |
$r->print("<font size='+2'>All homework assignments have been completed.</font><br /><br />"); |
} |
} |
} else { |
} else { |
$r->print("<a href='navmaps?jumpToFirstHomework'>" . |
&add_linkitem(\%toplinkitems,'firsthomework', |
&mt("Go To My First Homework Problem")."</a> "); |
'location.href="navmaps?jumpToFirstHomework"', |
|
"Show Me My First Homework Problem"); |
} |
} |
|
|
my $suppressEmptySequences = 0; |
my $suppressEmptySequences = 0; |
Line 361 ENDSUBM
|
Line 369 ENDSUBM
|
$filterFunc = sub { my $res = shift; |
$filterFunc = sub { my $res = shift; |
return $res->completable() || $res->is_map(); |
return $res->completable() || $res->is_map(); |
}; |
}; |
$r->print("<a href='navmaps?sort=$ENV{'form.sort'}'>" . |
&add_linkitem(\%toplinkitems,'everything', |
&mt("Show Everything")."</a> "); |
'location.href="navmaps?sort='.$ENV{'form.sort'}.'"', |
|
"Show Everything"); |
$r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>"); |
$r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>"); |
$ENV{'form.filter'} = ''; |
$ENV{'form.filter'} = ''; |
$ENV{'form.condition'} = 1; |
$ENV{'form.condition'} = 1; |
$resource_no_folder_link = 1; |
$resource_no_folder_link = 1; |
} else { |
} else { |
$r->print("<a href='navmaps?sort=$ENV{'form.sort'}&showOnlyHomework=1'>" . |
&add_linkitem(\%toplinkitems,'uncompleted', |
&mt("Show Only Uncompleted Homework")."</a> "); |
'location.href="navmaps?sort='.$ENV{'form.sort'}. |
|
'&showOnlyHomework=1"', |
|
"Show Only Uncompleted Homework"); |
} |
} |
|
|
my %selected=($ENV{'form.sort'} => 'selected=on'); |
my %selected=($ENV{'form.sort'} => 'selected=on'); |
Line 381 ENDSUBM
|
Line 392 ENDSUBM
|
<option value=\"default\" $selected{'default'}>".&mt('Default')."</option> |
<option value=\"default\" $selected{'default'}>".&mt('Default')."</option> |
<option value=\"title\" $selected{'title'} >".&mt('Title')."</option> |
<option value=\"title\" $selected{'title'} >".&mt('Title')."</option> |
<option value=\"duedate\" $selected{'duedate'}>".&mt('Duedate')."</option> |
<option value=\"duedate\" $selected{'duedate'}>".&mt('Duedate')."</option> |
|
<option value=\"discussion\" $selected{'discussion'}>".&mt('Has Discussion')."</option> |
</select> |
</select> |
</nobr> |
</nobr> |
</form>"); |
</form>"); |
# renderer call |
# renderer call |
my $renderArgs = { 'cols' => [0,2,3], |
my $renderArgs = { 'cols' => [0,1,2,3], |
'sort' => $ENV{'form.sort'}, |
'sort' => $ENV{'form.sort'}, |
'url' => '/adm/navmaps', |
'url' => '/adm/navmaps', |
'navmap' => $navmap, |
'navmap' => $navmap, |
Line 394 ENDSUBM
|
Line 406 ENDSUBM
|
'filterFunc' => $filterFunc, |
'filterFunc' => $filterFunc, |
'resource_no_folder_link' => $resource_no_folder_link, |
'resource_no_folder_link' => $resource_no_folder_link, |
'sort_html'=> $sort_html, |
'sort_html'=> $sort_html, |
'r' => $r}; |
'r' => $r, |
|
'caller' => 'navmapsdisplay', |
|
'linkitems' => \%toplinkitems}; |
my $render = render($renderArgs); |
my $render = render($renderArgs); |
$navmap->untieHashes(); |
$navmap->untieHashes(); |
|
|
Line 666 sub timeToHumanString {
|
Line 680 sub timeToHumanString {
|
} |
} |
|
|
# Not this year, so show the year |
# Not this year, so show the year |
my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time)); |
my $timeStr = strftime("on %A, %b %e %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; |
Line 1330 sub setDefault {
|
Line 1344 sub setDefault {
|
return $val; |
return $val; |
} |
} |
|
|
|
sub cmp_title { |
|
my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle)); |
|
$atitle=~s/^\s*//; |
|
$btitle=~s/^\s*//; |
|
return $atitle cmp $btitle; |
|
} |
|
|
sub render { |
sub render { |
my $args = shift; |
my $args = shift; |
&Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING}); |
Line 1415 sub render {
|
Line 1436 sub render {
|
# We only need to do this if we need to open the maps to show the |
# We only need to do this if we need to open the maps to show the |
# current position. This will change the counter so we can't count |
# current position. This will change the counter so we can't count |
# for the jump marker with this loop. |
# for the jump marker with this loop. |
while (($curRes = $mapIterator->next()) && !$found) { |
while ($here && ($curRes = $mapIterator->next()) && !$found) { |
if (ref($curRes) && $curRes->symb() eq $here) { |
if (ref($curRes) && $curRes->symb() eq $here) { |
my $mapStack = $mapIterator->getStack(); |
my $mapStack = $mapIterator->getStack(); |
|
|
Line 1515 sub render {
|
Line 1536 sub render {
|
} |
} |
|
|
if ($printCloseAll && !$args->{'resource_no_folder_link'}) { |
if ($printCloseAll && !$args->{'resource_no_folder_link'}) { |
|
my ($link,$text); |
if ($condition) { |
if ($condition) { |
$result.="<a href=\"navmaps?condition=0&filter=&$queryString" . |
$link='"navmaps?condition=0&filter=&'.$queryString. |
"&here=" . Apache::lonnet::escape($here) . |
'&here='.&Apache::lonnet::escape($here).'"'; |
"\">".&mt('Close All Folders')."</a>"; |
$text='Close All Folders'; |
} else { |
} else { |
$result.="<a href=\"navmaps?condition=1&filter=&$queryString" . |
$link='"navmaps?condition=1&filter=&'.$queryString. |
"&here=" . Apache::lonnet::escape($here) . |
'&here='.&Apache::lonnet::escape($here).'"'; |
"\">".&mt('Open All Folders')."</a>"; |
$text='Open All Folders'; |
} |
} |
|
if ($args->{'caller'} eq 'navmapsdisplay') { |
|
&add_linkitem($args->{'linkitems'},'changefolder', |
|
'location.href='.$link,$text); |
|
} else { |
|
$result.='<a href='.$link.'>'.&mt($text).'</a>'; |
|
} |
$result .= "\n"; |
$result .= "\n"; |
} |
} |
|
|
# Check for any unread discussions in all resources. |
# Check for any unread discussions in all resources. |
if (!$args->{'resource_no_folder_link'}) { |
if ($args->{'caller'} eq 'navmapsdisplay') { |
my $totdisc = 0; |
&add_linkitem($args->{'linkitems'},'clearbubbles', |
my $haveDisc = ''; |
'document.clearbubbles.submit()', |
my @allres=$navmap->retrieveResources(); |
'Mark all posts read'); |
foreach my $resource (@allres) { |
my $time=time; |
if ($resource->hasDiscussion()) { |
$result .= (<<END); |
my $ressymb; |
<form name="clearbubbles" method="post" action="/adm/feedback"> |
if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { |
<input type="hidden" name="navurl" value="$ENV{'QUERY_STRING'}" /> |
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; |
<input type="hidden" name="navtime" value="$time" /> |
} else { |
END |
$ressymb = $resource->symb(); |
if ($args->{'sort'} eq 'discussion') { |
|
my $totdisc = 0; |
|
my $haveDisc = ''; |
|
my @allres=$navmap->retrieveResources(); |
|
foreach my $resource (@allres) { |
|
if ($resource->hasDiscussion()) { |
|
my $ressymb; |
|
if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { |
|
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; |
|
} else { |
|
$ressymb = $resource->symb(); |
|
} |
|
$haveDisc .= $ressymb.':'; |
|
$totdisc ++; |
} |
} |
$haveDisc .= $ressymb.':'; |
|
$totdisc ++; |
|
} |
} |
} |
if ($totdisc > 0) { |
if ($totdisc > 0) { |
$haveDisc =~ s/:$//; |
$haveDisc =~ s/:$//; |
my $navurl = $ENV{'QUERY_STRING'}; |
my %lt = &Apache::lonlocal::texthash( |
$result .= (<<END); |
'mapr' => 'Mark all posts read', |
<input type="hidden" name="navmaps" value="$haveDisc" /> |
); |
</form> |
$result .= (<<END); |
|
<a href="javascript:document.clearbubbles.submit()">$lt{'mapr'}</a> <a href="javascript:void(open('/adm/help/NavMaps_MarkPosts_Read.hlp', 'Help_for_NavMaps_MarkPosts', 'menubar=0,toolbar=1,scrollbars=1,width=350,height=400,resizable=yes'))" title="Online Help"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: NavMaps_MarkPostsLink)" /></a> |
|
<form name="clearbubbles" method="post" action="/adm/feedback"> |
|
<input type="hidden" name="navurl" value="$ENV{'QUERY_STRING'}" /> |
|
<input type="hidden" name="navmaps" value="$haveDisc" /> |
|
</form> |
|
END |
END |
} else { |
} |
$result .= '<br />'; |
|
} |
} |
|
$result.='</form>'; |
} |
} |
|
|
if ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; } |
if ($args->{'caller'} eq 'navmapsdisplay') { |
|
$result .= '<table><tr><td>'. |
|
&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT').'</td>'; |
|
if ($ENV{'environment.remotenavmap'} ne 'on') { |
|
$result .= '<td> </td>'; |
|
} else { |
|
$result .= '</tr><tr>'; |
|
} |
|
$result.=&show_linkitems($args->{'linkitems'}); |
|
if ($args->{'sort_html'}) { |
|
if ($ENV{'environment.remotenavmap'} ne 'on') { |
|
$result.='<td> </td><td> </td><td> </td>'. |
|
'<td align="right">'.$args->{'sort_html'}.'</td></tr>'; |
|
} else { |
|
$result.='</tr><tr><td align="left"><br />'. |
|
$args->{'sort_html'}.'</td></tr>'; |
|
} |
|
} |
|
$result .= '</table>'; |
|
} elsif ($args->{'sort_html'}) { |
|
$result.=$args->{'sort_html'}; |
|
} |
|
|
$result .= "<br />\n"; |
$result .= "<br />\n"; |
if ($r) { |
if ($r) { |
Line 1646 END
|
Line 1700 END
|
return &$oldFilterFunc($res); |
return &$oldFilterFunc($res); |
}; |
}; |
@resources=$navmap->retrieveResources(undef,$filterFunc); |
@resources=$navmap->retrieveResources(undef,$filterFunc); |
@resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources; |
@resources= sort { &cmp_title($a,$b) } @resources; |
} elsif ($args->{'sort'} eq 'duedate') { |
} elsif ($args->{'sort'} eq 'duedate') { |
@resources=$navmap->retrieveResources(undef, |
my $oldFilterFunc = $filterFunc; |
sub { shift->is_problem(); }); |
my $filterFunc= |
@resources= sort |
sub { |
{ |
my ($res)=@_; |
|
if (!$res->is_problem()) { return 0;} |
|
return &$oldFilterFunc($res); |
|
}; |
|
@resources=$navmap->retrieveResources(undef,$filterFunc); |
|
@resources= sort { |
if ($a->duedate ne $b->duedate) { |
if ($a->duedate ne $b->duedate) { |
return $a->duedate cmp $b->duedate; |
return $a->duedate cmp $b->duedate; |
} else { |
|
lc($a->compTitle) cmp lc($b->compTitle) |
|
} |
} |
|
my $value=&cmp_title($a,$b); |
|
return $value; |
} @resources; |
} @resources; |
|
} elsif ($args->{'sort'} eq 'discussion') { |
|
my $oldFilterFunc = $filterFunc; |
|
my $filterFunc= |
|
sub { |
|
my ($res)=@_; |
|
if (!$res->hasDiscussion() && |
|
!$res->getFeedback() && |
|
!$res->getErrors()) { return 0;} |
|
return &$oldFilterFunc($res); |
|
}; |
|
@resources=$navmap->retrieveResources(undef,$filterFunc); |
|
@resources= sort { &cmp_title($a,$b) } @resources; |
} else { |
} else { |
#unknow sort mechanism or default |
#unknow sort mechanism or default |
undef($args->{'sort'}); |
undef($args->{'sort'}); |
Line 1872 if (location.href.indexOf('#curloc')==-1
|
Line 1943 if (location.href.indexOf('#curloc')==-1
|
return $result; |
return $result; |
} |
} |
|
|
|
sub add_linkitem { |
|
my ($linkitems,$name,$cmd,$text)=@_; |
|
$$linkitems{$name}{'cmd'}=$cmd; |
|
$$linkitems{$name}{'text'}=&mt($text); |
|
} |
|
|
|
sub show_linkitems { |
|
my ($linkitems)=@_; |
|
my @linkorder = ("launchnav","closenav","firsthomework","everything", |
|
"uncompleted","changefolder","clearbubbles"); |
|
|
|
my $result .= (<<ENDBLOCK); |
|
<td align="left"> |
|
<script type="text/javascript"> |
|
function changeNavDisplay () { |
|
var navchoice = document.linkitems.toplink[document.linkitems.toplink.selectedIndex].value; |
|
ENDBLOCK |
|
foreach my $link (@linkorder) { |
|
$result.= "if (navchoice == '$link') {". |
|
$linkitems->{$link}{'cmd'}."}\n"; |
|
} |
|
$result.='} |
|
</script> |
|
<form name="linkitems" method="post"> |
|
<nobr><select name="toplink">'."\n"; |
|
foreach my $link (@linkorder) { |
|
if (defined($linkitems->{$link})) { |
|
if ($linkitems->{$link}{'text'} ne '') { |
|
$result .= ' <option value="'.$link.'">'. |
|
$linkitems->{$link}{'text'}."</option>\n"; |
|
} |
|
} |
|
} |
|
$result .= '</select> <input type="button" name="chgnav" |
|
value="Go" onClick="javascript:changeNavDisplay()" /> |
|
</nobr></form></td>'."\n"; |
|
return $result; |
|
} |
|
|
1; |
1; |
|
|
package Apache::lonnavmaps::navmap; |
package Apache::lonnavmaps::navmap; |
Line 2078 sub generate_email_discuss_status {
|
Line 2188 sub generate_email_discuss_status {
|
|
|
foreach my $msgid (split(/\&/, $keys)) { |
foreach my $msgid (split(/\&/, $keys)) { |
$msgid=&Apache::lonnet::unescape($msgid); |
$msgid=&Apache::lonnet::unescape($msgid); |
my $plain=&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); |
if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { |
if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) { |
my $plain= |
my ($what,$url)=($1,$2); |
&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); |
my %status= |
if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) { |
&Apache::lonnet::get('email_status',[$msgid]); |
my ($what,$url)=($1,$2); |
if ($status{$msgid}=~/^error\:/) { |
|
$status{$msgid}=''; |
|
} |
|
|
|
if (($status{$msgid} eq 'new') || |
|
(!$status{$msgid})) { |
|
if ($what eq 'Error') { |
if ($what eq 'Error') { |
$error{$url}.=','.$msgid; |
$error{$url}.=','.$msgid; |
} else { |
} else { |
Line 2098 sub generate_email_discuss_status {
|
Line 2202 sub generate_email_discuss_status {
|
} |
} |
} |
} |
|
|
|
#url's of resources that have feedbacks |
$self->{FEEDBACK} = \%feedback; |
$self->{FEEDBACK} = \%feedback; |
$self->{ERROR_MSG} = \%error; # what is this? JB |
#or errors |
|
$self->{ERROR_MSG} = \%error; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{EMAIL_STATUS} = \%emailstatus; |
$self->{EMAIL_STATUS} = \%emailstatus; |
$self->{LAST_READ} = \%lastreadtime; |
$self->{LAST_READ} = \%lastreadtime; |
Line 3822 Returns the number of parts of the probl
|
Line 3928 Returns the number of parts of the probl
|
for single part problems, returns 1. For multipart, it returns the |
for single part problems, returns 1. For multipart, it returns the |
number of parts in the problem, not including psuedo-part 0. |
number of parts in the problem, not including psuedo-part 0. |
|
|
|
=item * B<countResponses>(): |
|
|
|
Returns the total number of responses in the problem a student can answer. |
|
|
|
=item * B<responseTypes>(): |
|
|
|
Returns a hash whose keys are the response types. The values are the number |
|
of times each response type is used. This is for the I<entire> problem, not |
|
just a single part. |
|
|
=item * B<multipart>(): |
=item * B<multipart>(): |
|
|
Returns true if the problem is multipart, false otherwise. Use this instead |
Returns true if the problem is multipart, false otherwise. Use this instead |
Line 3868 sub countParts {
|
Line 3984 sub countParts {
|
return scalar(@{$parts}); # + $delta; |
return scalar(@{$parts}); # + $delta; |
} |
} |
|
|
|
sub countResponses { |
|
my $self = shift; |
|
my $count; |
|
foreach my $part (@{$self->parts()}) { |
|
$count+= scalar($self->responseIds($part)); |
|
} |
|
return $count; |
|
} |
|
|
|
sub responseTypes { |
|
my $self = shift; |
|
my %responses; |
|
foreach my $part ($self->parts()) { |
|
foreach my $responsetype ($self->responseType($part)) { |
|
$responses{$responsetype}++ if (defined($responsetype)); |
|
} |
|
} |
|
return %responses; |
|
} |
|
|
sub multipart { |
sub multipart { |
my $self = shift; |
my $self = shift; |
return $self->countParts() > 1; |
return $self->countParts() > 1; |
Line 3955 sub extractParts {
|
Line 4091 sub extractParts {
|
} |
} |
|
|
|
|
|
# These hashes probably do not need names that end with "Hash".... |
my %responseIdHash; |
my %responseIdHash; |
my %responseTypeHash; |
my %responseTypeHash; |
|
|
Line 3990 sub extractParts {
|
Line 4127 sub extractParts {
|
} |
} |
} |
} |
my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder'); |
my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder'); |
|
# |
|
# Reorder the arrays in the %responseIdHash and %responseTypeHash |
if ($resorder) { |
if ($resorder) { |
my @resorder=split(/,/,$resorder); |
my @resorder=split(/,/,$resorder); |
foreach my $part (keys(%responseIdHash)) { |
foreach my $part (keys(%responseIdHash)) { |
my %resids = map { ($_,1) } @{ $responseIdHash{$part} }; |
my $i=0; |
|
my %resids = map { ($_,$i++) } @{ $responseIdHash{$part} }; |
my @neworder; |
my @neworder; |
foreach my $possibleid (@resorder) { |
foreach my $possibleid (@resorder) { |
if (exists($resids{$possibleid})) { |
if (exists($resids{$possibleid})) { |
push(@neworder,$possibleid); |
push(@neworder,$resids{$possibleid}); |
} |
} |
} |
} |
$responseIdHash{$part}=\@neworder; |
my @ids; |
|
my @type; |
|
foreach my $element (@neworder) { |
|
push (@ids,$responseIdHash{$part}->[$element]); |
|
push (@type,$responseTypeHash{$part}->[$element]); |
|
} |
|
$responseIdHash{$part}=\@ids; |
|
$responseTypeHash{$part}=\@type; |
} |
} |
} |
} |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_IDS} = \%responseIdHash; |
Line 4196 sub getCompletionStatus {
|
Line 4343 sub getCompletionStatus {
|
|
|
# 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_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; } |