--- loncom/interface/lonmenu.pm 2015/05/26 13:25:43 1.431.2.3
+++ loncom/interface/lonmenu.pm 2017/10/07 21:07:17 1.481
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.431.2.3 2015/05/26 13:25:43 raeburn Exp $
+# $Id: lonmenu.pm,v 1.481 2017/10/07 21:07:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -124,9 +124,13 @@ dropdown list when mouse hovers over top
(no hover psuedo class) via LC_hoverable class for
tag for top-
level item, which employs jQuery to handle behavior on mouseover.
-Inputs: 4 - (a) link and (b) target for anchor href in top level item,
- (c) title for text wrapped by anchor tag in top level item.
- (d) reference to array of arrays of sub-menu items.
+Inputs: 6 - (a) link and (b) target for anchor href in top level item,
+ (c) title for text wrapped by anchor tag in top level item,
+ (d) reference to array of arrays of sub-menu items,
+ (e) boolean to indicate whether to call &mt() to translate
+ name of menu item,
+ (f) optional class for
element in primary menu, for which
+ sub menu is being generated.
The underlying datastructure used in (d) contains data from mydesk.tab.
It consists of an array which has an array for each item appearing in
@@ -238,6 +242,7 @@ sub prep_menuitem {
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
+ my ($crstype) = @_;
my (%menu);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
@@ -246,6 +251,15 @@ sub primary_menu {
|| (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
$public = 1;
}
+ my $rolecount;
+ if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
+ my $update=$env{'user.update.time'};
+ if (!$update) {
+ $update = $env{'user.login.time'};
+ }
+ my %roles_in_env;
+ $rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
+ }
foreach my $menuitem (@primary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY'; #
@@ -263,8 +277,14 @@ sub primary_menu {
&& &Apache::loncommon::show_course(); ##term 'Courses' or
next if $$menuitem[4] eq 'courses' ##'Roles' wanted
&& !&Apache::loncommon::show_course(); ##
-
my $title = $menuitem->[3];
+ if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
+ if ($menuitem->[4] eq 'courses') {
+ next unless ($rolecount>1);
+ } else {
+ next unless (($title eq 'Personal') || ($title eq 'Logout'));
+ }
+ }
my $position = $menuitem->[5];
if ($position eq '') {
$position = 'right';
@@ -280,6 +300,7 @@ sub primary_menu {
my @primsub;
if (ref($primary_submenu{$title}) eq 'ARRAY') {
foreach my $item (@{$primary_submenu{$title}}) {
+ next if (($crstype eq 'Placement') && (!$env{'request.role.adv'}));
next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
next if ((($item->[2] eq 'portfolio') ||
($item->[2] eq 'blog')) &&
@@ -287,13 +308,19 @@ sub primary_menu {
undef,'tools')));
push(@primsub,$item);
}
+ if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ } else {
+ $title = &mt($title);
+ }
if (@primsub > 0) {
$menu{$position} .= &create_submenu($link,$target,$title,\@primsub,1);
} elsif ($link) {
- $menu{$position} .= '
';
@@ -540,7 +578,7 @@ sub create_submenu {
# see perldoc create_submenu documentation for further information
sub build_submenu {
my ($target, $submenu, $translate, $first_level) = @_;
- if (!defined(@{$submenu})) {
+ unless (@{$submenu}) {
return '';
}
@@ -598,7 +636,7 @@ sub build_submenu {
}
sub innerregister {
- my ($forcereg,$bread_crumbs,$group) = @_;
+ my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_;
my $const_space = ($env{'request.state'} eq 'construct');
my $is_const_dir = 0;
@@ -608,43 +646,71 @@ sub innerregister {
undef(@inlineremote);
- my ($mapurl,$resurl);
+ my ($mapurl,$resurl,$crstype,$navmap);
if ($env{'request.course.id'}) {
+#
+#course_type: Course, Community, or Placement
+#
+ $crstype = &Apache::loncommon::course_type();
if ($env{'request.symb'}) {
- ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
+ my $ignorenull;
+ unless ($env{'request.noversionuri'} eq '/adm/navmaps') {
+ $ignorenull = 1;
+ }
+ my $symb = &Apache::lonnet::symbread('','',$ignorenull);
+ ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb($symb);
my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
my $maptitle = &Apache::lonnet::gettitle($mapurl);
- my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
-
-#SD
-#course_type only Course and Community?
-#
- my @crumbs;
+ my $restitle = &Apache::lonnet::gettitle($symb);
+ my (@crumbs,@mapcrumbs);
+ if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') &&
+ (!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
+ }
+ }
unless (($forcereg) &&
($env{'request.noversionuri'} eq '/adm/navmaps') &&
- ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
- @crumbs = ({text => Apache::loncommon::course_type()
- . ' Contents',
+ ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
+ (($crstype eq 'Placement') && (!$env{'request.role.adv'}))) {
+ @crumbs = ({text => $crstype.' Contents',
href => "Javascript:gopost('/adm/navmaps','')"});
}
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
- push(@crumbs, {text => '...',
- no_mt => 1});
+ if (@mapcrumbs) {
+ push(@crumbs,@mapcrumbs);
+ } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) {
+ push(@crumbs, {text => '...',
+ no_mt => 1});
+ }
}
- push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
- && $maptitle ne 'default.sequence'
- && $maptitle ne $coursetitle);
-
- push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
+ unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) ||
+ (!$maptitle) || ($maptitle eq 'default.sequence') ||
+ ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+ push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl};
+ }
+ if ($restitle && !@mapcrumbs) {
+ push(@crumbs,{text => $restitle, no_mt => 1});
+ }
+ my @tools;
+ if ($env{'request.filename'} =~ /\.page$/) {
+ my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools();
+ if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') {
+ @tools = @{$breadcrumb_tools{'tools'}};
+ }
+ }
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
+ if (@tools) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',@tools);
+ }
} else {
$resurl = $env{'request.noversionuri'};
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
- my $crstype = &Apache::loncommon::course_type();
my $title = &mt('View Resource');
if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
@@ -654,7 +720,7 @@ sub innerregister {
}
my $trail;
if ($env{'form.folderpath'}) {
- &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
($trail) =
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
} else {
@@ -669,10 +735,10 @@ sub innerregister {
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&prepare_functions('/public'.$courseurl."/syllabus",
- $forcereg,$group,undef,undef,1);
+ $forcereg,$group,undef,undef,1,$hostname);
$title = &mt('Syllabus File');
my ($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname);
return $trail;
}
unless ($env{'request.state'} eq 'construct') {
@@ -696,7 +762,7 @@ sub innerregister {
$forceview,$editbutton);
if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
($env{'request.role'} !~/^(aa|ca|au)/)) {
- $editbutton = &prepare_functions($resurl,$forcereg,$group);
+ $editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname);
}
if ($editbutton eq '') {
$editbutton = &clear(6,1);
@@ -709,12 +775,13 @@ sub innerregister {
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ $perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'});
my @privs;
if ($env{'request.symb'} ne '') {
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
push(@privs,('mgr','vgr'));
}
- push(@privs,'opa');
+ push(@privs,('opa','vpa'));
}
foreach my $priv (@privs) {
$perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
@@ -738,7 +805,7 @@ sub innerregister {
'Content Submissions');
}
}
- if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
+ if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) {
&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
"gocmd('/adm/parmset','set')",
'Content Settings');
@@ -748,7 +815,7 @@ sub innerregister {
#
# This applies to items inside a folder/page modifiable in the course.
#
- if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
+ if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) {
my $text = 'Edit Folder';
if (($mapurl =~ /\.page$/) ||
($env{'request.symb'}=~
@@ -776,6 +843,13 @@ sub innerregister {
my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
if ($currdir =~ m-/$-) {
$is_const_dir = 1;
+ if ($thisdisfn eq '') {
+ unless (($env{'request.course.id'}) &&
+ ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
+ ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
+ $is_const_dir = 2;
+ }
+ }
} else {
$currdir =~ s|[^/]+$||;
my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
@@ -803,10 +877,30 @@ ENDMENUITEMS
# We are in a course and looking at a registered URL
# Should probably be in mydesk.tab
#
- $menuitems=(<new();
+ if (ref($navmap)) {
+ if (&Apache::lonplacementtest::is_lastres($env{'request.symb'},$navmap)) {
+ $showforw = 0;
+ }
+ }
+ }
+ if ($showforw) {
+ $menuitems.="
+s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3";
+ }
+ }
+ $menuitems .= (<[0];
+ }
+ $buttonshide = $pagebuttonshide;
+ } else {
+ $countdown = &countdown_timer();
+ $buttonshide = &hidden_button_check();
+ }
&Apache::lonhtmlcommon::clear_breadcrumb_tools();
&Apache::lonhtmlcommon::add_breadcrumb_tool(
'navigation', @inlineremote[21,23]);
- my $countdown = &countdown_timer();
- if (&hidden_button_check() eq 'yes') {
+ if ($buttonshide eq 'yes') {
if ($countdown) {
&Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
}
+ if ($showprogress) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
+ }
} else {
my @tools = @inlineremote[93,91,81,82,83];
if ($countdown) {
@@ -926,20 +1040,33 @@ ENDMENUITEMS
}
&advtools_crumbs(@inlineremote);
}
+ } else {
+ if ($showprogress) {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$showprogress);
+ }
+ }
+ my ($topic_help,$topic_help_text);
+ if ($is_const_dir == 2) {
+ if ((($ENV{'SERVER_PORT'} == 443) ||
+ ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) &&
+ (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {
+ $topic_help = 'Authoring_WebDAV,Authoring_WebDAV_Mac_10v6,Authoring_WebDAV_Mac_10v10,'.
+ 'Authoring_WebDAV_Windows_v7,Authoring_WebDAV_Linux_Centos';
+ $topic_help_text = 'About WebDAV access';
+ }
}
-
return &Apache::lonhtmlcommon::scripttag('', 'start')
- . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
+ . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'','','','',$topic_help,$topic_help_text)
. &Apache::lonhtmlcommon::scripttag('', 'end');
}
sub get_editbutton {
- my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
+ my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg,$hostname) = @_;
my $jscall;
if (($forceview) && ($env{'form.todocs'})) {
- my ($folderpath,$command);
+ my ($folderpath,$command,$navmap);
if ($env{'request.symb'}) {
- $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
+ $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap);
} elsif ($env{'form.folderpath'} =~ /^supplemental/) {
$folderpath = $env{'form.folderpath'};
$command = '&forcesupplement=1';
@@ -947,11 +1074,16 @@ sub get_editbutton {
$folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
$jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
} else {
+ my $suppanchor;
+ if ($env{'form.folderpath'}) {
+ $suppanchor = $env{'form.anchor'};
+ }
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
$forceedit,$forcereg,$env{'request.symb'},
&escape($env{'form.folderpath'}),
- &escape($env{'form.title'}),$env{'form.idx'},
- &escape($env{'form.suppurl'},$env{'form.todocs'}));
+ &escape($env{'form.title'}),$hostname,
+ $env{'form.idx'},&escape($env{'form.suppurl'}),
+ $env{'form.todocs'},$suppanchor);
}
if ($jscall) {
my $icon = 'pcstr.png';
@@ -968,7 +1100,7 @@ sub get_editbutton {
}
sub prepare_functions {
- my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
+ my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$hostname) = @_;
unless ($env{'request.registered'}) {
undef(@inlineremote);
}
@@ -982,8 +1114,9 @@ sub prepare_functions {
}
my $editbutton = '';
+ my $viewsrcbutton = '';
#
-# Determine whether or not to display 'Edit' icon/button
+# Determine whether or not to display 'Edit' or 'View Source' icon/button
#
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
@@ -1014,17 +1147,31 @@ sub prepare_functions {
# This applies in course context
#
if (($perms{'mdc'}) &&
- (($resurl eq "/public/$cdom/$cnum/syllabus") ||
- ($resurl =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}))) {
- $cfile = $resurl;
+ (($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) ||
+ ($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) ||
+ (($resurl =~ m{^/?uploaded/$cdom/$cnum/default_\d+\.sequence$}) && ($env{'form.navmap'})))) {
+ if ($resurl =~ m{^/}) {
+ $cfile = $resurl;
+ } else {
+ $cfile = "/$resurl";
+ }
$home = &Apache::lonnet::homeserver($cnum,$cdom);
if ($env{'form.forceedit'}) {
$forceview = 1;
} else {
$forceedit = 1;
}
- $editbutton = &get_editbutton($cfile,$home,$switchserver,
- $forceedit,$forceview,$forcereg);
+ if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) {
+ my $text = 'Edit Folder';
+ &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
+ "gocmd('/adm/coursedocs','direct')",
+ 'Folder/Page Content');
+ $editbutton = 1;
+ } else {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg,
+ $hostname);
+ }
} elsif (($resurl eq '/adm/extresedit') &&
(($env{'form.symb'}) || ($env{'form.folderpath'}))) {
($cfile,$home,$switchserver,$forceedit,$forceview) =
@@ -1032,8 +1179,7 @@ sub prepare_functions {
$env{'form.symb'});
if ($cfile ne '') {
$editbutton = &get_editbutton($cfile,$home,$switchserver,
- $forceedit,$forceview,$forcereg,
- $env{'form.title'},$env{'form.suppurl'});
+ $forceedit,$forceview,$forcereg);
}
} elsif (($resurl =~ m{^/?adm/viewclasslist$}) &&
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
@@ -1051,7 +1197,31 @@ sub prepare_functions {
&Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
if ($cfile ne '') {
$editbutton = &get_editbutton($cfile,$home,$switchserver,
- $forceedit,$forceview,$forcereg);
+ $forceedit,$forceview,$forcereg,
+ $hostname);
+ }
+ if ((($cfile eq '') || (!$editbutton)) &&
+ ($resurl =~ /$LONCAPA::assess_re/)) {
+ my $showurl = &Apache::lonnet::clutter($resurl);
+ if ((&Apache::lonnet::allowed('cre','/')) &&
+ (&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) {
+ $viewsrcbutton = 1;
+ } elsif (&Apache::lonnet::allowed('vxc',$env{'request.course.id'})) {
+ if ($showurl =~ m{^\Q/res/$cdom/\E($match_username)/}) {
+ my $auname = $1;
+ if (($env{'request.course.adhocsrcaccess'} ne '') &&
+ (grep(/^\Q$auname\E$/,split(/,/,$env{'request.course.adhocsrcaccess'})))) {
+ $viewsrcbutton = 1;
+ } elsif ((&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open') &&
+ (&Apache::lonnet::allowed('bre','/'))) {
+ $viewsrcbutton = 1;
+ }
+ }
+ }
+ if ($viewsrcbutton) {
+ &switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()',
+ 'View source code');
+ }
}
}
}
@@ -1101,16 +1271,25 @@ sub prepare_functions {
if (($env{'form.folderpath'} =~ /^supplemental/) &&
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
(($resurl =~ m{^/adm/wrapper/ext/}) ||
+ ($resurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) ||
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
($resurl eq '/adm/supplemental') ||
($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
my @folders=split('&',$env{'form.folderpath'});
if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
+ my $suppanchor;
+ if ($resurl =~ m{^/adm/wrapper/ext/}) {
+ $suppanchor = $env{'form.anchor'};
+ }
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
+ my $link = '/adm/coursedocs?command=direct&forcesupplement=1&supppath='.
+ "$esc_path&anchor=$suppanchor";
+ if ($env{'request.use_absolute'} ne '') {
+ $link = $env{'request.use_absolute'}.$link;
+ }
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
- "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
- 'Folder/Page Content');
+ "location.href='$link'",'Folder/Page Content');
}
}
}
@@ -1121,7 +1300,7 @@ sub prepare_functions {
&advtools_crumbs(@inlineremote);
return $editbutton;
} elsif ($env{'request.registered'}) {
- return $editbutton;
+ return $editbutton || $viewsrcbutton;
} else {
if (ref($bread_crumbs) eq 'ARRAY') {
if (@inlineremote > 0) {
@@ -1470,7 +1649,7 @@ sub rawconfig {
sub check_for_rcrs {
my $showreqcrs = 0;
- my @reqtypes = ('official','unofficial','community','textbook');
+ my @reqtypes = ('official','unofficial','community','textbook','placement');
foreach my $type (@reqtypes) {
if (&Apache::lonnet::usertools_access($env{'user.name'},
$env{'user.domain'},
@@ -1537,36 +1716,175 @@ END
}
# This creates a "done button" for timed events. The confirmation box is a jQuery
-# dialog widget. Clicking OK will set (LC_interval_done = 'true') which is checked in
-# lonhomework.pm.
+# dialog widget. If the interval parameter requires a proctor key for the timed
+# event to be marked done, there will also be a textbox where that can be entered.
+# Clicking OK will set the value of LC_interval_done to 'true', and, if needed will
+# set the value of LC_interval_done_proctorpass to the text entered in that box,
+# and submit the corresponding form.
+#
+# The &zero_time() routine in lonhomework.pm is called when a page is rendered if
+# LC_interval_done is true.
+#
sub done_button_js {
- my ($type,$height) = @_;
- if ($height !~ /^\d+$/) {
- $height = 320;
- }
+ my ($type,$width,$height,$proctor,$donebuttontext) = @_;
+ return unless (($type eq 'map') || ($type eq 'resource'));
my %lt = &Apache::lonlocal::texthash(
title => 'WARNING!',
- button => 'Done',
preamble => 'You are trying to end this timed event early.',
map => 'Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder.',
resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).',
- ok => 'Click "OK" if you are completely finished.',
+ okdone => 'Click "OK" if you are completely finished.',
cancel => 'Click "Cancel" to continue working.',
+ proctor => 'Ask a proctor to enter the key, then click "OK" if you are completely finished.',
+ ok => 'OK',
+ exit => 'Cancel',
+ key => 'Key:',
+ nokey => 'A proctor key is required',
);
- my $confirm;
- if (($type eq 'map') || ($type eq 'resource')) {
- $confirm = $lt{'preamble'}.' '.$lt{$type}.' '.$lt{'ok'}.' '.$lt{'cancel'};
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my ($missing,$tried) = (0,0);
+ if (ref($navmap)) {
+ my @resources=();
+ if ($type eq 'map') {
+ my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});
+ @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() });
+ } else {
+ my $res = $navmap->getBySymb($env{'request.symb'});
+ if (ref($res)) {
+ if ($res->is_problem()) {
+ push(@resources,$res);
+ }
+ }
+ }
+ foreach my $res (@resources) {
+ if (ref($res->parts()) eq 'ARRAY') {
+ foreach my $part (@{$res->parts()}) {
+ if (!$res->tries($part)) {
+ $missing++;
+ } else {
+ $tried++;
+ }
+ }
+ }
+ }
}
- if ($confirm) {
+ if ($missing) {
+ $lt{'miss'} .= '
';
+ if ($type eq 'map') {
+ $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,question part,question parts] in this folder.',$missing);
+ } else {
+ $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,part] in this question.',$missing);
+ }
+ if ($missing > 1) {
+ $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit answers for them.').'';
+ } else {
+ $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'