--- loncom/interface/lonmenu.pm 2023/07/06 19:16:16 1.369.2.83.2.8
+++ loncom/interface/lonmenu.pm 2025/02/21 04:29:26 1.561
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.369.2.83.2.8 2023/07/06 19:16:16 raeburn Exp $
+# $Id: lonmenu.pm,v 1.561 2025/02/21 04:29:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -118,72 +118,51 @@ Same as primary_menu() but operates on @
=item create_submenu()
-Creates XHTML for unordered list of sub-menu items which belong to a
+Creates XHTML for unordered list of sub-menu items which belong to a
particular top-level menu item. Uses hover pseudo class in css to display
-dropdown list when mouse hovers over top-level item. Support for IE6
+dropdown list when mouse hovers over top-level item. Support for IE6
(no hover psuedo class) via LC_hoverable class for
tag for top-
level item, which employs jQuery to handle behavior on mouseover.
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
+ (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
-the menu (e.g. [["link", "title", "condition"]] for a single-item menu).
-create_submenu() supports also the creation of XHTML for nested dropdown
-menus represented by unordered lists. This is done by replacing the
-scalar used for the link with an arrayreference containing the menuitems
-for the nested menu. This can be done recursively so that the next menu
-may also contain nested submenus.
+ 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
+ the menu (e.g. [["link", "title", "condition"]] for a single-item menu).
+ create_submenu() supports also the creation of XHTML for nested dropdown
+ menus represented by unordered lists. This is done by replacing the
+ scalar used for the link with an arrayreference containing the menuitems
+ for the nested menu. This can be done recursively so that the next menu
+ may also contain nested submenus.
Example:
- [ # begin of datastructure
- ["/home/", "Home", "condition1"], # 1st item of the 1st layer menu
- [ # 2nd item of the 1st layer menu
- [ # anon. array for nested menu
- ["/path1", "Path1", undef], # 1st item of the 2nd layer menu
- ["/path2", "Path2", undef], # 2nd item of the 2nd layer menu
- [ # 3rd item of the 2nd layer menu
- [[...], [...], ..., [...]], # containing another menu layer
- "Sub-Sub-Menu", # title for this container
- undef
- ]
- ], # end of array/nested menu
- "Sub-Menu", # title for the container item
- undef
- ] # end of 2nd item of the 1st layer menu
+ [ # begin of datastructure
+ ["/home/", "Home", "condition1"], # 1st item of the 1st layer menu
+ [ # 2nd item of the 1st layer menu
+ [ # anon. array for nested menu
+ ["/path1", "Path1", undef], # 1st item of the 2nd layer menu
+ ["/path2", "Path2", undef], # 2nd item of the 2nd layer menu
+ [ # 3rd item of the 2nd layer menu
+ [[...], [...], ..., [...]], # containing another menu layer
+ "Sub-Sub-Menu", # title for this container
+ undef
+ ]
+ ], # end of array/nested menu
+ "Sub-Menu", # title for the container item
+ undef
+ ] # end of 2nd item of the 1st layer menu
]
-
=item innerregister()
This gets called in order to register a URL in the body of the document
-=item loadevents()
-
-=item unloadevents()
-
-=item startupremote()
-
-=item setflags()
-
-=item maincall()
-
-=item load_remote_msg()
-
-=item get_menu_name()
-
-=item reopenmenu()
-
-=item open()
-
-Open the menu
-
=item clear()
=item switch()
@@ -266,7 +245,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,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target) = @_;
+ my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target,$collapsible) = @_;
my (%menu,%ltiexc,%menuopts);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
@@ -275,6 +254,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);
+ }
my $lti;
if ($env{'request.lti.login'}) {
$lti = 1;
@@ -293,7 +281,7 @@ sub primary_menu {
}
if ($links_target ne '') {
$target = $links_target;
- } else {
+ } else {
my ($ltitarget,$deeplinktarget);
if ($env{'request.lti.login'}) {
$ltitarget = $env{'request.lti.target'};
@@ -324,7 +312,7 @@ sub primary_menu {
&& !$public; # only visible to public
# users
next if $$menuitem[4] eq 'roles' ##show links depending on
- && (&Apache::loncommon::show_course() ##term 'Courses' or
+ && (&Apache::loncommon::show_course() ##term 'Courses' or
|| $lti); ##'Roles' wanted
next if $$menuitem[4] eq 'courses' ##and not LTI access
&& (!&Apache::loncommon::show_course()
@@ -334,6 +322,13 @@ sub primary_menu {
next if $$menuitem[4] eq 'ltiexc'
&& exists($ltiexc{lc($menuitem->[3])});
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';
@@ -365,11 +360,25 @@ sub primary_menu {
my @primsub;
if (ref($primary_submenu{$title}) eq 'ARRAY') {
foreach my $item (@{$primary_submenu{$title}}) {
- next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
- next if ((($item->[2] eq 'portfolio') ||
- ($item->[2] eq 'blog')) &&
+ 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')) &&
(!&Apache::lonnet::usertools_access('','',$item->[2],
undef,'tools')));
+ if (($item->[2] eq 'browsepub') && ($item->[0] eq '/res/')) {
+ if ($env{'request.role'} =~ /^au\./) {
+ $item->[0] .= $env{'request.role.domain'}.'/?launch=1';
+ } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
+ $item->[0] .= $1.'/'.$2.'/?launch=1';
+ } elsif (&Apache::lonnet::allowed('bre',$env{'user.domain'})) {
+ $item->[0] .= $env{'user.domain'}.'/?launch=1';
+ } elsif (&Apache::lonnet::allowed('bro','/res/')) {
+ $item->[0] .= '?launch=1';
+ } else {
+ next;
+ }
+ }
if ($env{'request.course.id'} && $menucoll) {
next if ($item->[3]) && (!$menuopts{$item->[3]});
}
@@ -397,6 +406,7 @@ sub primary_menu {
}
}
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+ next if ($crstype eq 'Placement');
if ($public) {
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
my $defdom = &Apache::lonnet::default_login_domain();
@@ -424,6 +434,10 @@ sub primary_menu {
}
my @output = ('','');
if ($menu{'left'} ne '') {
+ if ($collapsible) {
+ $menu{'left'} = ($listclass?'
':'
').
+ '
'.$menu{'left'};
+ }
$output[0] = "$menu{'left'}";
}
if ($menu{'right'} ne '') {
@@ -439,10 +453,10 @@ sub primary_menu {
#
#TODO this should probably be moved somewhere more central
#since it can be used by different parts of the system
-sub getauthor{
+sub getauthor {
return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
- #co- or assistent author?
+ #co- or assistant author?
my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
? ($1, $2) #domain, username of the parent author
: @env{ ('request.role.domain', 'user.name') }; #own domain, username
@@ -467,29 +481,38 @@ sub secondary_menu {
? "/$env{'request.course.sec'}"
: '');
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
- my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'});
+ my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'});
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
if ($canviewroster eq 'disabled') {
undef($canviewroster);
}
- my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
+ my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec);
my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec);
- my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec);
- my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
+ my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec);
+ my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec);
my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec);
my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec);
my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec);
- my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
+ my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec);
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
+ my ($is_author,$is_coauthor);
+ if ($author) {
+ if ($env{'request.role'} =~ /^au\./) {
+ $is_author = 1;
+ } elsif ($env{'request.role'} =~ /^ca\./) {
+ $is_coauthor = 1;
+ }
+ }
+
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,
$lti,$ltimapres,%ltiexc,%menuopts);
- $grouptools = 0;
+ $grouptools = 0;
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- unless ($canedit || $canvieweditor) {
+ unless ($canedit || $canvieweditor) {
unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) {
if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) ||
($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) ||
@@ -542,15 +565,25 @@ sub secondary_menu {
$linkattr = 'aria-disabled="true"';
}
- my ($canmodifycoauthor);
+ my ($canlistcoauthors,$canmodifycoauthor);
if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
my $extent = "$env{'user.domain'}/$env{'user.name'}";
if ((&Apache::lonnet::allowed('cca',$extent)) ||
(&Apache::lonnet::allowed('caa',$extent))) {
$canmodifycoauthor = 1;
}
+ } elsif ($env{'request.role'} =~ m{^(aa|ca)\./($match_domain/$match_username)$}) {
+ my ($role,$extent) = ($1,$2);
+ if (&Apache::lonnet::allowed('vca',$extent)) {
+ if ($env{"environment.internal.manager./$extent"}) {
+ $canmodifycoauthor = 1;
+ } else {
+ $canlistcoauthors = 1;
+ }
+ } elsif (&Apache::lonnet::allowed('vaa',$extent)) {
+ $canlistcoauthors = 1;
+ }
}
-
my ($roleswitcher_js,$roleswitcher_form);
if ($links_target ne '') {
$target = $links_target;
@@ -572,15 +605,20 @@ sub secondary_menu {
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
- next if $$menuitem[4] ne 'always'
- && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca')
+ next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));
+ next if $$menuitem[4] ne 'always'
+ && $$menuitem[4] ne 'coauthor'
+ && $$menuitem[4] ne 'author'
+ && $$menuitem[4] ne 'authorspace'
+ && $$menuitem[4] ne 'vca'
+ && $$menuitem[4] ne 'mca'
&& !$env{'request.course.id'};
next if $$menuitem[4] =~ /^crsedit/
&& (!$canedit && !$canvieweditor);
next if $$menuitem[4] eq 'crseditCourse'
&& ($crstype eq 'Community');
next if $$menuitem[4] eq 'crseditCommunity'
- && ($crstype eq 'Course');
+ && ($crstype ne 'Community');
next if $$menuitem[4] eq 'nvgr'
&& ($canvgr || $ltiexc{'grades'});
next if $$menuitem[4] eq 'vgr'
@@ -597,7 +635,7 @@ sub secondary_menu {
&& !$canviewwnew;
next if $$menuitem[4] eq 'params'
&& (!$canmodpara && !$canviewpara);
- next if $$menuitem[4] eq 'nvcg'
+ next if $$menuitem[4] eq 'showgroups'
&& ($canviewgrps || !$grouptools);
next if $$menuitem[4] eq 'showsyllabus'
&& !$showsyllabus;
@@ -605,9 +643,17 @@ sub secondary_menu {
&& !$showfeeds;
next if $$menuitem[4] eq 'plc'
&& !$canplc;
- next if $$menuitem[4] eq 'author'
+ next if $$menuitem[4] eq 'authorspace'
&& !$author;
- next if $$menuitem[4] eq 'cca'
+ next if $$menuitem[4] eq 'author'
+ && !$is_author;
+ next if $$menuitem[4] eq 'coauthor'
+ && !$is_coauthor;
+ next if $$menuitem[4] eq 'vca'
+ && (!$canlistcoauthors || $canmodifycoauthor);
+ next if $$menuitem[4] eq 'vaa'
+ && (!$canlistcoauthors || $canmodifycoauthor);
+ next if $$menuitem[4] eq 'mca'
&& !$canmodifycoauthor;
next if $$menuitem[4] eq 'notltimapres'
&& $ltimapres;
@@ -620,9 +666,7 @@ sub secondary_menu {
my $title = $menuitem->[3];
if ($env{'request.course.id'} && $menucoll) {
- if ($$menuitem[5] eq 'main') {
- next if ($menuopts{$$menuitem[5]} eq 'n');
- } elsif ($$menuitem[5] ne 'roles') {
+ unless ($$menuitem[5] eq 'roles') {
next if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]}));
}
}
@@ -645,8 +689,8 @@ sub secondary_menu {
next if ($item->[2] eq 'vcg' && !$canviewgrps);
next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);
next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
- next if ($item->[2] eq 'author' && !$author);
- next if ($item->[2] eq 'cca' && !$canmodifycoauthor);
+ next if ($item->[2] eq 'author' && !$is_author);
+ next if ($item->[2] eq 'vca' && !$canlistcoauthors);
next if ($item->[2] eq 'lti' && !$lti);
if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
my $tool = $1;
@@ -654,7 +698,7 @@ sub secondary_menu {
next if (!&Apache::lonnet::usertools_access('','',$tool,
undef,'tools'));
}
- push(@scndsub,$item);
+ push(@scndsub,$item);
}
}
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'}) {
@@ -676,14 +720,17 @@ sub secondary_menu {
my ($switcher,$has_opa_priv);
($roleswitcher_js,$roleswitcher_form,$switcher,$has_opa_priv) =
&roles_selector(
- $env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost,$target,$menucoll,$menuref
+ $env{'course.' . $env{'request.course.id'} . '.domain'},
+ $env{'course.' . $env{'request.course.id'} . '.num'},
+ $httphost,$target,$menucoll,$menuref
);
if (($$menuitem[5]) && (!$menuopts{$$menuitem[5]})) {
next unless ($has_opa_priv);
}
$menu .= $switcher;
+ } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+ next if ($crstype eq 'Placement');
+ $menu .= '
';
}
} else {
@@ -2077,9 +2003,10 @@ sub switch {
$inlineremote[$idx] =
''.$pic.'';
} else {
+ my $linktext = &mt($top);
$inlineremote[$idx] =
''.$pic.
- ''.$top.' ';
+ ''.$linktext.' '.$form;
}
}
return '';
@@ -2099,27 +2026,20 @@ sub secondlevel {
return $output;
}
-sub openmenu {
- my $menuname = &get_menu_name();
- unless ($env{'environment.remote'} eq 'on') { return ''; }
- my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
- return "window.open(".$nothing.",'".$menuname."');";
-}
-
sub inlinemenu {
undef(@inlineremote);
undef(%category_members);
# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
&rawconfig(1);
- my $output='
';
+ my $output='
'."\n";
for (my $col=1; $col<=2; $col++) {
- $output.='
';
+ $output .= '
'."\n";
for (my $row=1; $row<=8; $row++) {
foreach my $cat (keys(%category_members)) {
if ($category_positions{$cat} ne "$col,$row") { next; }
#$output.='
'.&mt($category_names{$cat}).'
';
$output.='
';
- $output.='
'.&mt($category_names{$cat}).'
';
+ $output.='
'.&mt($category_names{$cat}).'
';
$output.='
';
my %active=();
foreach my $menu_item (split(/\:/,$category_members{$cat})) {
@@ -2134,9 +2054,9 @@ sub inlinemenu {
$output.='';
}
}
- $output.="";
+ $output.="";
}
- $output.="
";
+ $output .= '
'."\n";
return $output;
}
@@ -2148,13 +2068,7 @@ sub rawconfig {
#
my $textualoverride=shift;
my $output='';
- if ($env{'environment.remote'} eq 'on') {
- $output.=
- "window.status='Opening Remote Control';var swmenu=".&openmenu().
-"\nwindow.status='Configuring Remote Control ';";
- } else {
- unless ($textualoverride) { return ''; }
- }
+ return '' unless $textualoverride;
my $uname=$env{'user.name'};
my $udom=$env{'user.domain'};
my $adv=$env{'user.adv'};
@@ -2231,6 +2145,8 @@ sub rawconfig {
} else {
next;
}
+ } elsif ($priv eq 'cca') {
+ next if ($rol eq 'cm');
}
if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
(($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
@@ -2312,6 +2228,24 @@ sub rawconfig {
}
}
}
+ } elsif ($pro eq 'coauthor') {
+ if ($env{'request.role'}=~ m{^(ca|aa)\./($match_domain)/($match_username)$}) {
+ my ($role,$audom,$auname) = ($1,$2,$3);
+ if ((($prt eq 'raa') && ($role eq 'aa')) ||
+ (($prt eq 'rca') && ($role eq 'ca') &&
+ (!$env{"environment.internal.manager./$audom/$auname"}))) {
+ $output.=&switch($auname,$audom,
+ $row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ }
+ } elsif ($pro eq 'coauthorenv_manager') {
+ if ($env{'request.role'}=~ m{^ca\./($match_domain)/($match_username)$}) {
+ my ($audom,$auname) = ($1,$2);
+ if ($env{"environment.internal.manager./$audom/$auname"}) {
+ $output.=&switch($auname,$audom,
+ $row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ }
} elsif ($pro eq 'tools') {
my @tools = ('aboutme','blog','portfolio');
if (grep(/^\Q$prt\E$/,@tools)) {
@@ -2339,18 +2273,12 @@ sub rawconfig {
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
}
- if ($env{'environment.remote'} eq 'on') {
- $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
- if (&Apache::lonmsg::newmail()) {
- $output.='swmenu.setstatus("you have","messages");';
- }
- }
return $output;
}
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'},
@@ -2362,36 +2290,23 @@ sub check_for_rcrs {
if (!$showreqcrs) {
foreach my $type (@reqtypes) {
if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
- $showreqcrs = 1;
- last;
+ my @domains = split(',',$env{'environment.reqcrsotherdom.'.$type});
+ foreach my $entry (@domains) {
+ my ($extdom,$extopt) = split(':',$entry);
+ if (&Apache::lonnet::will_trust('reqcrs',$env{'user.domain'},$extdom)) {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ if ($showreqcrs) {
+ last;
+ }
}
}
}
return $showreqcrs;
}
-# ======================================================================= Close
-
-sub close {
- unless ($env{'environment.remote'} eq 'on') { return ''; }
- my $menuname = &get_menu_name();
- return(<
-//
-
-ENDCLOSE
-}
-
sub dc_popup_js {
my %lt = &Apache::lonlocal::texthash(
more => '(More ...)',
@@ -2439,12 +2354,12 @@ END
}
# This creates a "done button" for timed events. The confirmation box is a jQuery
-# 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,
+# 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.
#
@@ -2455,17 +2370,17 @@ sub done_button_js {
title => 'WARNING!',
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).',
+ resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).',
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',
+ nokey => 'A proctor key is required',
);
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}));
- my $navmap = Apache::lonnavmaps::navmap->new();
+ my $navmap = Apache::lonnavmaps::navmap->new();
my ($missing,$tried) = (0,0);
if (ref($navmap)) {
my @resources=();
@@ -2514,7 +2429,7 @@ sub done_button_js {
if ($height !~ /^\d+$/) {
$height = 400;
if ($missing) {
- $height += 60;
+ $height += 60;
}
}
if ($width !~ /^\d+$/) {
@@ -2558,8 +2473,8 @@ sub done_button_js {
click: function() {
var proctorkey = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
if ((proctorkey == '') || (proctorkey == null)) {
- alert("$lt{'nokey'}");
- } else {
+ alert("$lt{'nokey'}");
+ } else {
\$( '[name="LC_interval_done"]' )[0].value = 'true';
\$( '[name="LC_interval_done_proctorpass"]' )[0].value = proctorkey;
\$( '[name="LCdoneButton"]' )[0].submit();
@@ -2652,6 +2567,126 @@ END
}
}
+sub view_as_js {
+ my ($url,$symb) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ ente => 'Enter a username or a student/employee ID',
+ info => 'Information you entered does not match a valid course user',
+ );
+ &js_escape(\%lt);
+ return <<"END";
+
+function toggleViewAsUser(change) {
+ if (document.getElementById('LC_selectuser')) {
+ var seluserid = document.getElementById('LC_selectuser');
+ var currstyle = seluserid.style.display;
+ if (change == 'off') {
+ document.userview.elements['LC_viewas'].value = '';
+ document.userview.elements['vuname'].value = '';
+ document.userview.elements['vid'].value = '';
+ document.userview.submit();
+ return;
+ }
+ if ((document.getElementById('usexpand')) && (document.getElementById('uscollapse'))) {
+ if (currstyle == 'inline') {
+ seluserid.style.display = 'none';
+ document.getElementById('usexpand').style.display= 'inline';
+ document.getElementById('uscollapse').style.display = 'none';
+ } else {
+ seluserid.style.display = 'inline';
+ toggleIdentifier(document.userview);
+ document.getElementById('usexpand').style.display = 'none';
+ document.getElementById('uscollapse').style.display = 'inline';
+ }
+ }
+ }
+ return;
+}
+
+function validCourseUser(form,change) {
+ var possuname = form.elements['vuname'].value;
+ var possuid = form.elements['vid'].value;
+ var domelem = form.elements['vudom'];
+ var possudom = '';
+ if ((domelem.tagName === 'INPUT') && ((domelem.type === 'text') || (domelem.type === 'hidden'))) {
+ possudom = domelem.value;
+ } else if (domelem.tagName === 'SELECT') {
+ possudom = domelem.options[domelem.selectedIndex].value;
+ }
+ if ((possuname == '') && (possuid == '')) {
+ if (change == 'off') {
+ form.elements['LC_viewas'].value = '';
+ form.submit();
+ } else {
+ alert("$lt{'ente'}");
+ }
+ return;
+ }
+ var http = new XMLHttpRequest();
+ var url = "/adm/courseuser";
+ var params = "uname="+possuname+"&uid="+possuid+"&udom="+possudom;
+ http.open("POST", url, true);
+ http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ http.onreadystatechange = function() {
+ if (http.readyState == 4 && http.status == 200) {
+ var data = JSON.parse(http.responseText);
+ if (Array.isArray(data.match)) {
+ var len = data.match.length;
+ if (len == 2) {
+ if (data.match[0] != '' && data.match[1] != '') {
+ form.elements['LC_viewas'].value = data.match[0]+':'+data.match[1];
+ form.submit();
+ }
+ } else {
+ alert("$lt{'info'}");
+ }
+ }
+ }
+ return;
+ }
+ http.send(params);
+ return false;
+}
+
+function toggleIdentifier(form) {
+ if ((document.getElementById('LC_vuname')) && (document.getElementById('LC_vid'))) {
+ var identifylabel = document.getElementById('LC_vuidentifier');
+ var identifier;
+ var userbyuname;
+ var radioelem = form.elements['vuidentifier'];
+ if (radioelem.length > 0) {
+ var i;
+ for (i=0; i
+
ENDSERVERFORM
}
@@ -2918,7 +2999,7 @@ sub constspaceform {
$target = ' target="_parent"';
$printtarget = ' target="_parent"';
} else {
- unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
+ unless ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) ||
(($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self'))) {
$target = ' target="_top"';
$printtarget = ' target="_top"';
@@ -2937,20 +3018,15 @@ sub constspaceform {
+
ENDCONSTSPACEFORM
}
-sub get_nav_status {
- my $navstatus="swmenu.w_loncapanav_flag=";
- if ($env{'environment.remotenavmap'} eq 'on') {
- $navstatus.="1";
- } else {
- $navstatus.="-1";
- }
- return $navstatus;
-}
-
sub hidden_button_check {
if ( $env{'request.course.id'} eq ''
|| $env{'request.role.adv'} ) {
@@ -2997,7 +3073,7 @@ sub roles_selector {
if (exists($reqprivs->{$destination})) {
if ($reqprivs->{$destination} =~ /,/) {
@{$privref} = split(/,/,$reqprivs->{$destination});
- } else {
+ } else {
$privref = [$reqprivs->{$destination}];
}
}
@@ -3076,17 +3152,18 @@ sub roles_selector {
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,
\%roledesc,$privref,$menucoll,$menuref);
$form =
- ''."\n";
+ $form .= ''."\n".
+ ''."\n";
foreach my $role (@roles_order) {
my $include;
if (defined($courseroles{$role})) {
@@ -3118,7 +3195,7 @@ sub roles_selector {
$include = 1;
}
} else {
- $include = 1;
+ $include = 1;
}
if ($include) {
my $rolename;
@@ -3205,7 +3282,7 @@ sub get_all_courseroles {
push(@{$courseroles->{'st'}},keys(%sections_count));
$seccount->{'st'} = scalar(keys(%sections_count));
}
- $seccount->{'st'} ++; # Increment for a section-less student role.
+ $seccount->{'st'} ++; # Increment for a section-less student role.
my $rolehash = {
'roles' => $courseroles,
'seccount' => $seccount,
@@ -3262,7 +3339,7 @@ sub get_customadhoc_roles {
foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
next if (($role eq '') || ($role =~ /\W/));
$seccount->{"$prefix/$role"} = $numsec;
- $roledesc->{"$prefix/$role"} = $description->{$role};
+ $roledesc->{"$prefix/$role"} = $description->{$role};
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) {
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} =
@@ -3443,7 +3520,6 @@ function adhocRole(newrole) {
fullrole += '/'+secchoice;
}
} else {
- document.rolechooser.elements[roleitem].selectedIndex = 0;
if (secchoice != null) {
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
}
@@ -3569,13 +3645,14 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <
$collapse
-
+
$expand$title
@@ -3585,6 +3662,13 @@ END
return;
}
+sub placement_progress {
+ my ($totalpoints,$incomplete) = &Apache::lonplacementtest::check_completion(undef,undef,1);
+ my $complete = 100 - $incomplete;
+ return ''.
+ &mt('Test is [_1]% complete',$complete).'';
+}
+
sub linkprot_exit {
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) {
my ($deeplink_symb,$deeplink);
@@ -3613,11 +3697,11 @@ sub linkprot_exit {
);
if ($exit) {
my ($show,$text) = split(/:/,$exit);
- unless ($show eq 'no') {
+ unless ($show eq 'no') {
my $height = 250;
my $width = 300;
my $exitbuttontext;
- if ($text eq '') {
+ if ($text eq '') {
$exitbuttontext = &mt('Exit Tool');
} else {
$exitbuttontext = $text;