version 1.369.2.64, 2016/10/31 21:05:59
|
version 1.369.2.79.2.2, 2020/07/19 00:24:36
|
Line 384 sub secondary_menu {
|
Line 384 sub secondary_menu {
|
? "/$env{'request.course.sec'}" |
? "/$env{'request.course.sec'}" |
: ''); |
: ''); |
my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); |
my $canedit = &Apache::lonnet::allowed('mdc', $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'}; |
my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; |
if ($canviewroster eq 'disabled') { |
if ($canviewroster eq 'disabled') { |
undef($canviewroster); |
undef($canviewroster); |
Line 398 sub secondary_menu {
|
Line 399 sub secondary_menu {
|
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); |
my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); |
my $author = &getauthor(); |
my $author = &getauthor(); |
|
|
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv); |
my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools); |
|
$grouptools = 0; |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
unless ($canedit) { |
unless ($canedit || $canvieweditor) { |
unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) { |
unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) { |
if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) || |
if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) || |
($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) || |
($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) || |
Line 415 sub secondary_menu {
|
Line 417 sub secondary_menu {
|
$showfeeds = 1; |
$showfeeds = 1; |
} |
} |
} |
} |
unless (($canmgr) || ($canvgr)) { |
unless ($canmgr || $canvgr) { |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); |
if (keys(%slots) > 0) { |
if (keys(%slots) > 0) { |
$showresv = 1; |
$showresv = 1; |
} |
} |
} |
} |
|
if ($env{'request.course.groups'} ne '') { |
|
foreach my $group (split(/:/,$env{'request.course.groups'})) { |
|
next unless ($group =~ /^\w+$/); |
|
my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"}); |
|
shift(@privs); |
|
if (@privs) { |
|
$grouptools ++; |
|
} |
|
} |
|
} |
} |
} |
|
|
my ($canmodifycoauthor); |
my ($canmodifycoauthor); |
Line 432 sub secondary_menu {
|
Line 444 sub secondary_menu {
|
} |
} |
} |
} |
|
|
my %groups = &Apache::lonnet::get_active_groups( |
|
$env{'user.domain'}, $env{'user.name'}, |
|
$env{'course.' . $env{'request.course.id'} . '.domain'}, |
|
$env{'course.' . $env{'request.course.id'} . '.num'}); |
|
|
|
my ($roleswitcher_js,$roleswitcher_form); |
my ($roleswitcher_js,$roleswitcher_form); |
|
|
foreach my $menuitem (@secondary_menu) { |
foreach my $menuitem (@secondary_menu) { |
Line 445 sub secondary_menu {
|
Line 452 sub secondary_menu {
|
next if $$menuitem[4] ne 'always' |
next if $$menuitem[4] ne 'always' |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') |
&& !$env{'request.course.id'}; |
&& !$env{'request.course.id'}; |
next if $$menuitem[4] =~ /^mdc/ |
next if $$menuitem[4] =~ /^crsedit/ |
&& !$canedit; |
&& (!$canedit && !$canvieweditor); |
next if $$menuitem[4] eq 'mdcCourse' |
next if $$menuitem[4] eq 'crseditCourse' |
&& ($crstype eq 'Community'); |
&& ($crstype eq 'Community'); |
next if $$menuitem[4] eq 'mdcCommunity' |
next if $$menuitem[4] eq 'crseditCommunity' |
&& ($crstype eq 'Course'); |
&& ($crstype eq 'Course'); |
next if $$menuitem[4] eq 'nvgr' |
next if $$menuitem[4] eq 'nvgr' |
&& $canvgr; |
&& $canvgr; |
Line 468 sub secondary_menu {
|
Line 475 sub secondary_menu {
|
next if $$menuitem[4] eq 'params' |
next if $$menuitem[4] eq 'params' |
&& (!$canmodpara && !$canviewpara); |
&& (!$canmodpara && !$canviewpara); |
next if $$menuitem[4] eq 'nvcg' |
next if $$menuitem[4] eq 'nvcg' |
&& ($canviewgrps || !%groups); |
&& ($canviewgrps || !$grouptools); |
next if $$menuitem[4] eq 'showsyllabus' |
next if $$menuitem[4] eq 'showsyllabus' |
&& !$showsyllabus; |
&& !$showsyllabus; |
next if $$menuitem[4] eq 'showfeeds' |
next if $$menuitem[4] eq 'showfeeds' |
Line 497 sub secondary_menu {
|
Line 504 sub secondary_menu {
|
next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers)); |
next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers)); |
next if ($item->[2] eq 'mgr' && !$canmgr); |
next if ($item->[2] eq 'mgr' && !$canmgr); |
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'vcg' && !$canviewgrps); |
next if ($item->[2] eq 'mdc' && !$canedit); |
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); |
push(@scndsub,$item); |
push(@scndsub,$item); |
} |
} |
} |
} |
Line 521 sub secondary_menu {
|
Line 531 sub secondary_menu {
|
my $url = $$menuitem[0]; |
my $url = $$menuitem[0]; |
$url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum}; |
$url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum}; |
if (&Apache::lonnet::is_on_map($url)) { |
if (&Apache::lonnet::is_on_map($url)) { |
unless ($$menuitem[0] =~ /\?register=1/) { |
unless ($$menuitem[0] =~ /(\?|\&)register=1/) { |
$$menuitem[0] .= '?register=1'; |
$$menuitem[0] .= (($$menuitem[0]=~/\?/)? '&' : '?').'register=1'; |
} |
} |
} else { |
} else { |
$$menuitem[0] =~ s{\?register=1}{}; |
$$menuitem[0] =~ s{\&?register=1}{}; |
|
} |
|
if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { |
|
if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) { |
|
unless (&Apache::lonnet::uses_sts()) { |
|
unless ($$menuitem[0] =~ m{^https?://}) { |
|
$$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; |
|
} |
|
unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) { |
|
$$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1'; |
|
} |
|
} |
|
} |
} |
} |
|
$$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); |
} |
} |
$menu .= &prep_menuitem(\@$menuitem); |
$menu .= &prep_menuitem(\@$menuitem); |
} |
} |
Line 545 sub secondary_menu {
|
Line 568 sub secondary_menu {
|
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{}; |
($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{}; |
$escurl = &escape($escurl); |
$escurl = &escape($escurl); |
} |
} |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[url\]/$escurl/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
$menu =~ s/\[symb\]/$escsymb/g; |
} |
} |
Line 634 sub build_submenu {
|
Line 657 sub build_submenu {
|
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); |
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
$href =~ s/\[domain\]/$env{'user.domain'}/g; |
$href =~ s/\[user\]/$env{'user.name'}/g; |
$href =~ s/\[user\]/$env{'user.name'}/g; |
|
} elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) { |
|
my $returnurl = $ENV{'REQUEST_URI'}; |
|
if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) { |
|
$returnurl = $1; |
|
} |
|
if (($returnurl =~ m{^/adm/createuser($|\?action=)}) || |
|
($returnurl =~ m{^/priv/$match_domain/$match_username}) || |
|
($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) { |
|
$returnurl =~ s{\?.*$}{}; |
|
$returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\''); |
|
} else { |
|
undef($returnurl); |
|
} |
|
$href =~ s/\[returnurl\]/$returnurl/; |
} |
} |
unless (($href eq '') || ($href =~ /^\#/)) { |
unless (($href eq '') || ($href =~ /^\#/)) { |
$target = ' target="_top"'; |
$target = ' target="_top"'; |
Line 677 sub registerurl {
|
Line 714 sub registerurl {
|
} |
} |
|
|
sub innerregister { |
sub innerregister { |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide) = @_; |
my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_; |
my $const_space = ($env{'request.state'} eq 'construct'); |
my $const_space = ($env{'request.state'} eq 'construct'); |
my $is_const_dir = 0; |
my $is_const_dir = 0; |
|
|
Line 698 sub innerregister {
|
Line 735 sub innerregister {
|
$newmail= 'swmenu.setstatus("you have","messages");'; |
$newmail= 'swmenu.setstatus("you have","messages");'; |
} |
} |
|
|
my ($mapurl,$resurl); |
my ($mapurl,$resurl,$crstype,$navmap); |
|
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
|
# |
|
#course_type: Course or Community |
|
# |
|
$crstype = &Apache::loncommon::course_type(); |
if ($env{'request.symb'}) { |
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 $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); |
my $restitle = &Apache::lonnet::gettitle($symb); |
|
|
|
|
#SD |
my (@crumbs,@mapcrumbs); |
#course_type only Course and Community? |
if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') && |
# |
($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'})) { |
my @crumbs; |
$navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
@mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); |
|
} |
|
} |
unless (($forcereg) && |
unless (($forcereg) && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($env{'request.noversionuri'} eq '/adm/navmaps') && |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { |
@crumbs = ({text => Apache::loncommon::course_type() |
@crumbs = ({text => $crstype.' Contents', |
. ' Contents', |
|
href => "Javascript:gopost('/adm/navmaps','')"}); |
href => "Javascript:gopost('/adm/navmaps','')"}); |
} |
} |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { |
push(@crumbs, {text => '...', |
if (@mapcrumbs) { |
no_mt => 1}); |
push(@crumbs,@mapcrumbs); |
|
} else { |
|
push(@crumbs, {text => '...', |
|
no_mt => 1}); |
|
} |
} |
} |
|
|
push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle |
unless ((@mapcrumbs) || (!$maptitle) || ($maptitle eq 'default.sequence') || |
&& $maptitle ne 'default.sequence' |
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { |
&& $maptitle ne $coursetitle); |
push @crumbs, {text => $maptitle, no_mt => 1, |
|
href => &Apache::lonnet::clutter($mapurl).'?navmap=1'}; |
push @crumbs, {text => $restitle, no_mt => 1} if $restitle; |
} |
|
if ($restitle && !@mapcrumbs) { |
|
push(@crumbs,{text => $restitle, no_mt => 1}); |
|
} |
my @tools; |
my @tools; |
if ($env{'request.filename'} =~ /\.page$/) { |
if ($env{'request.filename'} =~ /\.page$/) { |
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); |
Line 745 sub innerregister {
|
Line 800 sub innerregister {
|
} else { |
} else { |
$resurl = $env{'request.noversionuri'}; |
$resurl = $env{'request.noversionuri'}; |
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'}); |
my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'}); |
my $crstype = &Apache::loncommon::course_type(); |
|
my $title = &mt('View Resource'); |
my $title = &mt('View Resource'); |
if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) { |
if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']); |
Line 755 sub innerregister {
|
Line 809 sub innerregister {
|
} |
} |
my $trail; |
my $trail; |
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1); |
&prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname); |
($trail) = |
($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
} else { |
} else { |
Line 770 sub innerregister {
|
Line 824 sub innerregister {
|
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) { |
} elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) { |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&prepare_functions('/public'.$courseurl."/syllabus", |
&prepare_functions('/public'.$courseurl."/syllabus", |
$forcereg,$group,undef,undef,1); |
$forcereg,$group,undef,undef,1,$hostname); |
$title = &mt('Syllabus File'); |
$title = &mt('Syllabus File'); |
my ($trail) = |
my ($trail) = |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); |
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,$hostname); |
return $trail; |
return $trail; |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless ($env{'request.state'} eq 'construct') { |
Line 810 sub innerregister {
|
Line 864 sub innerregister {
|
if (($env{'environment.remote'} eq 'on') && ($env{'request.symb'})) { |
if (($env{'environment.remote'} eq 'on') && ($env{'request.symb'})) { |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
} |
} |
$editbutton = &prepare_functions($resurl,$forcereg,$group); |
$editbutton = &prepare_functions($resurl,$forcereg,$group,'','','',$hostname); |
} |
} |
if ($editbutton eq '') { |
if ($editbutton eq '') { |
$editbutton = &clear(6,1); |
$editbutton = &clear(6,1); |
Line 823 sub innerregister {
|
Line 877 sub innerregister {
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
|
$perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'}); |
my @privs; |
my @privs; |
if ($env{'request.symb'} ne '') { |
if ($env{'request.symb'} ne '') { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { |
Line 864 sub innerregister {
|
Line 919 sub innerregister {
|
# |
# |
# This applies to items inside a folder/page modifiable in the course. |
# 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'; |
my $text = 'Edit Folder'; |
if (($mapurl =~ /\.page$/) || |
if (($mapurl =~ /\.page$/) || |
($env{'request.symb'}=~ |
($env{'request.symb'}=~ |
Line 963 if ($env{'browser.mobile'}) {
|
Line 1018 if ($env{'browser.mobile'}) {
|
$is_mobile = 1; |
$is_mobile = 1; |
} |
} |
|
|
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { |
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio|ext\.tool)(\?|$)/) { |
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) { |
if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && |
|
($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)})) { |
$menuitems.=(<<ENDREALRES); |
$menuitems.=(<<ENDREALRES); |
s&6&3&catalog.png&$swtext{'catalog'}&info[_1]&catalog_info('$is_mobile')&Show Metadata |
s&6&3&catalog.png&$swtext{'catalog'}&info[_1]&catalog_info('$is_mobile')&Show Metadata |
ENDREALRES |
ENDREALRES |
} |
} |
unless (($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) || |
unless (($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)}) || |
($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/})) { |
($env{'request.noversionuri'} =~ m{^\Q/adm/wrapper/\E(ext|uploaded)/})) { |
$menuitems.=(<<ENDREALRES); |
$menuitems.=(<<ENDREALRES); |
s&8&1&eval.png&$swtext{'eval'}&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource |
s&8&1&eval.png&$swtext{'eval'}&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource |
Line 1398 ENDOPEN
|
Line 1454 ENDOPEN
|
} |
} |
|
|
sub get_editbutton { |
sub get_editbutton { |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; |
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg,$hostname) = @_; |
my $jscall; |
my $jscall; |
if (($forceview) && ($env{'form.todocs'})) { |
if (($forceview) && ($env{'form.todocs'})) { |
my ($folderpath,$command); |
my ($folderpath,$command,$navmap); |
if ($env{'request.symb'}) { |
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/) { |
} elsif ($env{'form.folderpath'} =~ /^supplemental/) { |
$folderpath = $env{'form.folderpath'}; |
$folderpath = $env{'form.folderpath'}; |
$command = '&forcesupplement=1'; |
$command = '&forcesupplement=1'; |
Line 1418 sub get_editbutton {
|
Line 1474 sub get_editbutton {
|
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, |
$jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, |
$forceedit,$forcereg,$env{'request.symb'}, |
$forceedit,$forcereg,$env{'request.symb'}, |
&escape($env{'form.folderpath'}), |
&escape($env{'form.folderpath'}), |
&escape($env{'form.title'}),$env{'form.idx'}, |
&escape($env{'form.title'}),$hostname, |
&escape($env{'form.suppurl'}),$env{'form.todocs'}, |
$env{'form.idx'},&escape($env{'form.suppurl'}), |
$suppanchor); |
$env{'form.todocs'},$suppanchor); |
} |
} |
if ($jscall) { |
if ($jscall) { |
my $icon = 'pcstr.png'; |
my $icon = 'pcstr.png'; |
Line 1453 sub get_editbutton {
|
Line 1509 sub get_editbutton {
|
} |
} |
|
|
sub prepare_functions { |
sub prepare_functions { |
my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$forbodytag) = @_; |
my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$hostname,$forbodytag) = @_; |
unless ($env{'request.registered'}) { |
unless ($env{'request.registered'}) { |
undef(@inlineremote); |
undef(@inlineremote); |
} |
} |
Line 1467 sub prepare_functions {
|
Line 1523 sub prepare_functions {
|
} |
} |
|
|
my $editbutton = ''; |
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$}) { |
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
Line 1499 sub prepare_functions {
|
Line 1556 sub prepare_functions {
|
# This applies in course context |
# This applies in course context |
# |
# |
if (($perms{'mdc'}) && |
if (($perms{'mdc'}) && |
(($resurl eq "/public/$cdom/$cnum/syllabus") || |
(($resurl =~ m{^/?public/$cdom/$cnum/syllabus}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}))) { |
($resurl =~ m{^/?uploaded/$cdom/$cnum/portfolio/syllabus/}) || |
$cfile = $resurl; |
(($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); |
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
if ($env{'form.forceedit'}) { |
if ($env{'form.forceedit'}) { |
$forceview = 1; |
$forceview = 1; |
} else { |
} else { |
$forceedit = 1; |
$forceedit = 1; |
} |
} |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
if ($cfile =~ m{^/uploaded/$cdom/$cnum/default_\d+\.sequence$}) { |
$forceedit,$forceview,$forcereg); |
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') && |
} elsif (($resurl eq '/adm/extresedit') && |
(($env{'form.symb'}) || ($env{'form.folderpath'}))) { |
(($env{'form.symb'}) || ($env{'form.folderpath'}))) { |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
($cfile,$home,$switchserver,$forceedit,$forceview) = |
Line 1538 sub prepare_functions {
|
Line 1609 sub prepare_functions {
|
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$editbutton = &get_editbutton($cfile,$home,$switchserver, |
$forceedit,$forceview,$forcereg); |
$forceedit,$forceview,$forcereg); |
} |
} |
|
if ((($cfile eq '') || (!$editbutton)) && |
|
($resurl =~ /$LONCAPA::assess_re/)) { |
|
my $showurl = &Apache::lonnet::clutter($resurl); |
|
my $crs_sec = $env{'request.course.id'} . (($env{'request.course.sec'} ne '') |
|
? "/$env{'request.course.sec'}" |
|
: ''); |
|
if ((&Apache::lonnet::allowed('cre','/')) && |
|
(&Apache::lonnet::metadata($resurl,'sourceavail') eq 'open')) { |
|
$viewsrcbutton = 1; |
|
} elsif (&Apache::lonnet::allowed('vxc',$crs_sec)) { |
|
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',$crs_sec))) { |
|
$viewsrcbutton = 1; |
|
} |
|
} |
|
} |
|
if ($viewsrcbutton) { |
|
&switch('','',6,1,'pcstr.png','View Source','resource[_2]','open_source()', |
|
'View source code'); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 1586 sub prepare_functions {
|
Line 1683 sub prepare_functions {
|
if (($env{'form.folderpath'} =~ /^supplemental/) && |
if (($env{'form.folderpath'} =~ /^supplemental/) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && |
(($resurl =~ m{^/adm/wrapper/ext/}) || |
(($resurl =~ m{^/adm/wrapper/ext/}) || |
|
($resurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) || |
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) || |
($resurl eq '/adm/supplemental') || |
($resurl eq '/adm/supplemental') || |
($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) || |
($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) || |
Line 1597 sub prepare_functions {
|
Line 1695 sub prepare_functions {
|
$suppanchor = $env{'form.anchor'}; |
$suppanchor = $env{'form.anchor'}; |
} |
} |
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"')); |
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]', |
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', |
"location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path&anchor=$suppanchor'", |
"location.href='$link'",'Folder/Page Content'); |
'Folder/Page Content','','',1); |
|
} |
} |
} |
} |
} |
} |
Line 1610 sub prepare_functions {
|
Line 1712 sub prepare_functions {
|
&advtools_crumbs(@inlineremote); |
&advtools_crumbs(@inlineremote); |
return $editbutton; |
return $editbutton; |
} elsif (($env{'request.registered'}) && (!ref($forbodytag))) { |
} elsif (($env{'request.registered'}) && (!ref($forbodytag))) { |
return $editbutton; |
return $editbutton || $viewsrcbutton; |
} else { |
} else { |
if (ref($bread_crumbs) eq 'ARRAY') { |
if (ref($bread_crumbs) eq 'ARRAY') { |
if (@inlineremote > 0) { |
if (@inlineremote > 0) { |
Line 2092 function toggleCountdown() {
|
Line 2194 function toggleCountdown() {
|
END |
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, |
|
# 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,$width,$height,$proctor,$donebuttontext) = @_; |
|
return unless (($type eq 'map') || ($type eq 'resource')); |
|
my %lt = &Apache::lonlocal::texthash( |
|
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).', |
|
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 $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'}); |
|
if ($env{'request.symb'} =~ /\.page$/) { |
|
@resources=$navmap->retrieveResources($resurl,sub { $_[0]->is_problem() }); |
|
} else { |
|
@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 ($missing) { |
|
$lt{'miss'} .= '<p class="LC_error">'; |
|
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.').'</span>'; |
|
} else { |
|
$lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'</p>'; |
|
} |
|
} |
|
$donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"'); |
|
if ($proctor) { |
|
if ($height !~ /^\d+$/) { |
|
$height = 400; |
|
if ($missing) { |
|
$height += 60; |
|
} |
|
} |
|
if ($width !~ /^\d+$/) { |
|
$width = 400; |
|
if ($missing) { |
|
$width += 60; |
|
} |
|
} |
|
return <<END; |
|
<form method="post" name="LCdoneButton" action=""> |
|
<input type="hidden" name="LC_interval_done" value="" /> |
|
<input type="hidden" name="LC_interval_done_proctorpass" value="" /> |
|
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
|
</form> |
|
|
|
<div id="LC_done-confirm" title="$lt{'title'}"> |
|
<p>$lt{'preamble'} $lt{$type}</p> |
|
$lt{'miss'} |
|
<p>$lt{'proctor'}</p> |
|
<form name="LCdoneButtonProctor" action=""> |
|
<label>$lt{'key'}<input type="password" name="LC_interval_done_proctorkey" value="" /></label> |
|
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px" /> |
|
</form> |
|
<p>$lt{'cancel'}</p> |
|
</div> |
|
|
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$( "#LC_done-confirm" ).dialog({ autoOpen: false }); |
|
\$( "#LC_done-confirm-opener" ).on("click", function() { |
|
\$( "#LC_done-confirm" ).dialog("open"); |
|
\$( "#LC_done-confirm" ).dialog({ |
|
height: $height, |
|
width: $width, |
|
modal: true, |
|
resizable: false, |
|
buttons: [ |
|
{ |
|
text: "$lt{'ok'}", |
|
click: function() { |
|
var proctorkey = \$( '[name="LC_interval_done_proctorkey"]' )[0].value; |
|
if ((proctorkey == '') || (proctorkey == null)) { |
|
alert("$lt{'nokey'}"); |
|
} else { |
|
\$( '[name="LC_interval_done"]' )[0].value = 'true'; |
|
\$( '[name="LC_interval_done_proctorpass"]' )[0].value = proctorkey; |
|
\$( '[name="LCdoneButton"]' )[0].submit(); |
|
} |
|
}, |
|
}, |
|
{ |
|
text: "$lt{'exit'}", |
|
click: function() { |
|
\$("#LC_done-confirm").dialog( "close" ); |
|
} |
|
} |
|
], |
|
close: function() { |
|
\$( '[name="LC_interval_done_proctorkey"]' )[0].value = ''; |
|
} |
|
}); |
|
\$( "#LC_done-confirm" ).find( "form" ).on( "submit", function( event ) { |
|
event.preventDefault(); |
|
\$( '[name="LC_interval_done"]' )[0].value = 'true'; |
|
\$( '[name="LC_interval_done_proctorpass"]' )[0].value = \$( '[name="LC_interval_done_proctorkey"]' )[0].value; |
|
\$( '[name="LCdoneButton"]' )[0].submit(); |
|
}); |
|
}); |
|
|
|
// ]]> |
|
</script> |
|
|
|
END |
|
} else { |
|
if ($height !~ /^\d+$/) { |
|
$height = 320; |
|
if ($missing) { |
|
$height += 60; |
|
} |
|
} |
|
if ($width !~ /^\d+$/) { |
|
$width = 320; |
|
if ($missing) { |
|
$width += 60; |
|
} |
|
} |
|
if ($missing) { |
|
$lt{'miss'} = '</p>'.$lt{'miss'}.'<p>'; |
|
} |
|
return <<END; |
|
|
|
<form method="post" name="LCdoneButton" action=""> |
|
<input type="hidden" name="LC_interval_done" value="" /> |
|
<button id="LC_done-confirm-opener" type="button">$donebuttontext</button> |
|
</form> |
|
|
|
<div id="LC_done-confirm" title="$lt{'title'}"> |
|
<p>$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}</p> |
|
</div> |
|
|
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
\$( "#LC_done-confirm" ).dialog({ autoOpen: false }); |
|
\$( "#LC_done-confirm-opener" ).click(function() { |
|
\$( "#LC_done-confirm" ).dialog( "open" ); |
|
\$( "#LC_done-confirm" ).dialog({ |
|
resizable: false, |
|
height: $height, |
|
width: $width, |
|
modal: true, |
|
buttons: [ |
|
{ |
|
text: "$lt{'ok'}", |
|
click: function() { |
|
\$( this ).dialog( "close" ); |
|
\$( '[name="LC_interval_done"]' )[0].value = 'true'; |
|
\$( '[name="LCdoneButton"]' )[0].submit(); |
|
}, |
|
}, |
|
{ |
|
text: "$lt{'exit'}", |
|
click: function() { |
|
\$( this ).dialog( "close" ); |
|
}, |
|
}, |
|
], |
|
}); |
|
}); |
|
// ]]> |
|
</script> |
|
|
|
END |
|
} |
|
} |
|
|
sub utilityfunctions { |
sub utilityfunctions { |
my ($httphost) = @_; |
my ($httphost) = @_; |
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); |
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); |
if ($currenturl =~ m{^/adm/wrapper/ext/} |
my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); |
&& $env{'request.external.querystring'} ) { |
if ($currenturl =~ m{^/adm/wrapper/ext/}) { |
|
if ($env{'request.external.querystring'}) { |
$currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; |
$currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; |
|
} |
|
my ($anchor) = ($env{'request.symb'} =~ /(\#[^\#]+)$/); |
|
if (($anchor) && ($currenturl !~ /\Q$anchor\E$/)) { |
|
$currenturl .= $1; |
|
} |
} |
} |
$currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); |
$currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); |
|
|
my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); |
|
|
|
my $dc_popup_cid; |
my $dc_popup_cid; |
if ($env{'user.adv'} && exists($env{'user.role.dc./'. |
if ($env{'user.adv'} && exists($env{'user.role.dc./'. |
$env{'course.'.$env{'request.course.id'}. |
$env{'course.'.$env{'request.course.id'}. |
Line 2128 sub utilityfunctions {
|
Line 2445 sub utilityfunctions {
|
|
|
my $countdown = &countdown_toggle_js(); |
my $countdown = &countdown_toggle_js(); |
|
|
|
my $annotateurl = '/adm/annotation'; |
|
if ($httphost) { |
|
$annotateurl = '/adm/annotations'; |
|
} |
my $hostvar = ' |
my $hostvar = ' |
function setLCHost() { |
function setLCHost() { |
var lcHostname=""; |
var lcHostname=""; |
Line 2154 return (<<ENDUTILITY)
|
Line 2475 return (<<ENDUTILITY)
|
|
|
$dc_popup_cid |
$dc_popup_cid |
|
|
function go(url) { |
|
if (url!='' && url!= null) { |
|
currentURL = null; |
|
currentSymb= null; |
|
var lcHostname = setLCHost(); |
|
window.location.href=lcHostname+url; |
|
} |
|
} |
|
|
|
$jumptores |
$jumptores |
|
|
function gopost(url,postdata) { |
function gopost(url,postdata) { |
Line 2265 function annotate() {
|
Line 2577 function annotate() {
|
annotator.document.write( |
annotator.document.write( |
'$start_page_annotate' |
'$start_page_annotate' |
+"<form name='goannotate' target='Annotator' method='post' " |
+"<form name='goannotate' target='Annotator' method='post' " |
+"action='/adm/annotations'>" |
+"action='$annotateurl'>" |
+"<input type='hidden' name='symbnew' value='"+currentSymb+"' />" |
+"<input type='hidden' name='symbnew' value='"+currentSymb+"' />" |
+"<\\/form>" |
+"<\\/form>" |
+'$end_page_annotate'); |
+'$end_page_annotate'); |
Line 2286 function open_StoredLinks_Import(rat) {
|
Line 2598 function open_StoredLinks_Import(rat) {
|
newWin.focus(); |
newWin.focus(); |
} |
} |
|
|
|
function open_source() { |
|
sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+currentURL,'LONsource', |
|
'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes'); |
|
} |
|
|
(function (\$) { |
(function (\$) { |
\$(document).ready(function () { |
\$(document).ready(function () { |
\$.single=function(a){return function(b){a[0]=b;return a}}(\$([1])); |
\$.single=function(a){return function(b){a[0]=b;return a}}(\$([1])); |
Line 2358 sub roles_selector {
|
Line 2675 sub roles_selector {
|
my ($cdom,$cnum,$httphost) = @_; |
my ($cdom,$cnum,$httphost) = @_; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
my $now = time; |
my $now = time; |
my (%courseroles,%seccount,%courseprivs); |
my (%courseroles,%seccount,%courseprivs,%roledesc); |
my $is_cc; |
my $is_cc; |
my ($js,$form,$switcher); |
my ($js,$form,$switcher); |
my $ccrole; |
my $ccrole; |
Line 2369 sub roles_selector {
|
Line 2686 sub roles_selector {
|
} |
} |
my ($privref,$gotsymb,$destsymb); |
my ($privref,$gotsymb,$destsymb); |
my $destinationurl = $ENV{'REQUEST_URI'}; |
my $destinationurl = $ENV{'REQUEST_URI'}; |
if ($destinationurl =~ /\?symb=/) { |
if ($destinationurl =~ /(\?|\&)symb=/) { |
$gotsymb = 1; |
$gotsymb = 1; |
} elsif ($destinationurl =~ m{^/enc/}) { |
} elsif ($destinationurl =~ m{^/enc/}) { |
my $plainurl = &Apache::lonenc::unencrypted($destinationurl); |
my $plainurl = &Apache::lonenc::unencrypted($destinationurl); |
if ($plainurl =~ /\?symb=/) { |
if ($plainurl =~ /(\?|\&)symb=/) { |
$gotsymb = 1; |
$gotsymb = 1; |
} |
} |
} |
} |
Line 2408 sub roles_selector {
|
Line 2725 sub roles_selector {
|
if ($is_cc) { |
if ($is_cc) { |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs); |
&get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs); |
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) { |
} elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) { |
&get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$privref); |
&get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref); |
} else { |
} else { |
my %gotnosection; |
my %gotnosection; |
foreach my $item (keys(%env)) { |
foreach my $item (keys(%env)) { |
Line 2462 sub roles_selector {
|
Line 2779 sub roles_selector {
|
} |
} |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) { |
my @submenu; |
my @submenu; |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$privref); |
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref); |
$form = |
$form = |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
'<form name="rolechooser" method="post" action="'.$httphost.'/adm/roles">'."\n". |
' <input type="hidden" name="destinationurl" value="'. |
' <input type="hidden" name="destinationurl" value="'. |
Line 2502 sub roles_selector {
|
Line 2819 sub roles_selector {
|
$include = 1; |
$include = 1; |
} |
} |
if ($include) { |
if ($include) { |
|
my $rolename; |
|
if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { |
|
$rolename = $roledesc{$role}; |
|
if ($rolename eq '') { |
|
$rolename = &mt('Helpdesk [_1]',$1); |
|
} |
|
} else { |
|
$rolename = &Apache::lonnet::plaintext($role); |
|
} |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
push(@submenu,['javascript:adhocRole('."'$role'".')', |
&Apache::lonnet::plaintext($role)]); |
$rolename]); |
} |
} |
} |
} |
} |
} |
Line 2585 sub get_all_courseroles {
|
Line 2911 sub get_all_courseroles {
|
} |
} |
|
|
sub get_customadhoc_roles { |
sub get_customadhoc_roles { |
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$privref) = @_; |
my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_; |
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') && |
(ref($courseprivs) eq 'HASH')) { |
(ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) { |
return; |
return; |
} |
} |
if ($env{'environment.adhocroles.'.$cdom} ne '') { |
my $is_helpdesk = 0; |
my @customroles = split(/,/,$env{'environment.adhocroles.'.$cdom}); |
my $now = time; |
if (@customroles > 1) { |
foreach my $role ('dh','da') { |
if ($env{"user.role.dh./$cdom/"}) { |
if ($env{"user.role.$role./$cdom/"}) { |
my ($start,$end)=split(/\./,$env{"user.role.dh./$cdom/"}); |
my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"}); |
my $now = time; |
if (!($start && ($now<$start)) && !($end && ($now>$end))) { |
if (!($start && ($now<$start)) & !($end && ($now>$end))) { |
$is_helpdesk = 1; |
my $numsec = 1; |
last; |
my @sections; |
} |
my ($allseclist,$cached) = |
} |
&Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum); |
} |
if (defined($cached)) { |
if ($is_helpdesk) { |
if ($allseclist ne '') { |
my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum); |
@sections = split(/,/,$allseclist); |
my %available; |
$numsec += scalar(@sections); |
if (ref($possroles) eq 'ARRAY') { |
} |
map { $available{$_} = 1; } @{$possroles}; |
} else { |
} |
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
$numsec += scalar(keys(%sections_count)); |
if (ref($domdefaults{'adhocroles'}) eq 'HASH') { |
$allseclist = join(',',sort(keys(%sections_count))); |
if (keys(%{$domdefaults{'adhocroles'}})) { |
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
my $numsec = 1; |
} |
my @sections; |
my (%adhoc,$gotprivs); |
my ($allseclist,$cached) = |
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
&Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum); |
foreach my $role (@customroles) { |
if (defined($cached)) { |
next if (($role eq '') || ($role =~ /\W/)); |
if ($allseclist ne '') { |
$seccount->{"$prefix/$role"} = $numsec; |
@sections = split(/,/,$allseclist); |
$courseroles->{"$prefix/$role"} = \@sections; |
$numsec += scalar(@sections); |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
} |
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) { |
} else { |
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} = |
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
$env{"user.priv.$prefix/$role./$cdom/$cnum./"}; |
@sections = sort(keys(%sections_count)); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} = |
$numsec += scalar(@sections); |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"}; |
$allseclist = join(',',@sections); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} = |
&Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist); |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"}; |
} |
} else { |
my (%adhoc,$gotprivs); |
unless ($gotprivs) { |
my $prefix = "cr/$cdom/$cdom".'-domainconfig'; |
my ($adhocroles,$privscached) = |
foreach my $role (keys(%{$domdefaults{'adhocroles'}})) { |
&Apache::lonnet::is_cached_new('adhocroles',$cdom); |
next if (($role eq '') || ($role =~ /\W/)); |
if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) { |
$seccount->{"$prefix/$role"} = $numsec; |
%adhoc = %{$adhocroles}; |
$roledesc->{"$prefix/$role"} = $description->{$role}; |
} else { |
if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) { |
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
if (exists($env{"user.priv.$prefix/$role./$cdom/$cnum./"})) { |
my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_'); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./"} = |
foreach my $key (keys(%roledefs)) { |
$env{"user.priv.$prefix/$role./$cdom/$cnum./"}; |
(undef,my $rolename) = split(/_/,$key); |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} = |
if ($rolename ne '') { |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"}; |
$adhoc{$rolename} = $roledefs{$key}; |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"} = |
} |
$env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/$cnum"}; |
|
} else { |
|
unless ($gotprivs) { |
|
my ($adhocroles,$privscached) = |
|
&Apache::lonnet::is_cached_new('adhocroles',$cdom); |
|
if ((defined($privscached)) && (ref($adhocroles) eq 'HASH')) { |
|
%adhoc = %{$adhocroles}; |
|
} else { |
|
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
|
my %roledefs = &Apache::lonnet::dump('roles',$cdom,$confname,'rolesdef_'); |
|
foreach my $key (keys(%roledefs)) { |
|
(undef,my $rolename) = split(/_/,$key); |
|
if ($rolename ne '') { |
|
my ($systempriv,$domainpriv,$coursepriv) = split(/\_/,$roledefs{$key}); |
|
$coursepriv = &Apache::lonnet::course_adhocrole_privs($rolename,$cdom,$cnum,$coursepriv); |
|
$adhoc{$rolename} = join('_',($systempriv,$domainpriv,$coursepriv)); |
} |
} |
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc); |
|
} |
} |
$gotprivs = 1; |
&Apache::lonnet::do_cache_new('adhocroles',$cdom,\%adhoc); |
} |
} |
($courseprivs->{"$prefix/$role./$cdom/$cnum./"}, |
$gotprivs = 1; |
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) = |
|
split(/\_/,$adhoc{$role}); |
|
} |
} |
|
($courseprivs->{"$prefix/$role./$cdom/$cnum./"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"}, |
|
$courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/$cnum"}) = |
|
split(/\_/,$adhoc{$role}); |
} |
} |
} |
} |
|
if ($available{$role}) { |
|
$courseroles->{"$prefix/$role"} = \@sections; |
|
} |
} |
} |
} |
} |
} |
} |
Line 2660 sub get_customadhoc_roles {
|
Line 3004 sub get_customadhoc_roles {
|
} |
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$privref) = @_; |
my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
this => 'This role has section(s) associated with it.', |
this => 'This role has section(s) associated with it.', |
ente => 'Enter a specific section.', |
ente => 'Enter a specific section.', |
Line 2813 sub required_privs {
|
Line 3157 sub required_privs {
|
'/adm/parmset' => 'opa,vpa', |
'/adm/parmset' => 'opa,vpa', |
'/adm/courseprefs' => 'opa,vpa', |
'/adm/courseprefs' => 'opa,vpa', |
'/adm/whatsnew' => 'whn', |
'/adm/whatsnew' => 'whn', |
'/adm/populate' => 'cst', |
'/adm/populate' => 'cst,vpa,vcl', |
'/adm/trackstudent' => 'vsa', |
'/adm/trackstudent' => 'vsa', |
'/adm/statistics' => 'mgr,vgr', |
'/adm/statistics' => 'mgr,vgr', |
'/adm/setblock' => 'dcm,vcb', |
'/adm/setblock' => 'dcm,vcb', |
Line 2852 sub countdown_timer {
|
Line 3196 sub countdown_timer {
|
} |
} |
my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); |
my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); |
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
my @interval=&Apache::lonnet::EXT("resource.0.interval"); |
|
my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret); |
if (@interval > 1) { |
if (@interval > 1) { |
|
($timelimit,my $donesuffix) = split(/_/,$interval[0],2); |
|
if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) { |
|
$usesdone = 'done'; |
|
$donebuttontext = $1; |
|
(undef,$proctor,$secret) = split(/_/,$2); |
|
} elsif ($donesuffix =~ /^done(|_.+)$/) { |
|
$donebuttontext = &mt('Done'); |
|
($usesdone,$proctor,$secret) = split(/_/,$donesuffix); |
|
} |
my $first_access=&Apache::lonnet::get_first_access($interval[1]); |
my $first_access=&Apache::lonnet::get_first_access($interval[1]); |
if ($first_access > 0) { |
if ($first_access > 0) { |
if ($first_access+$interval[0] > time) { |
if ($first_access+$timelimit > time) { |
$hastimeleft = 1; |
$hastimeleft = 1; |
} |
} |
} |
} |
Line 2863 sub countdown_timer {
|
Line 3217 sub countdown_timer {
|
if (($duedate && $duedate > time) || |
if (($duedate && $duedate > time) || |
(!$duedate && $hastimeleft) || |
(!$duedate && $hastimeleft) || |
($slot_name ne '' && $slothastime)) { |
($slot_name ne '' && $slothastime)) { |
my ($collapse,$expand,$alttxt,$title,$currdisp); |
my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton); |
if ((@interval > 1 && $hastimeleft) || |
if ((@interval > 1 && $hastimeleft) || |
($type eq 'Task' && $slothastime)) { |
($type eq 'Task' && $slothastime)) { |
$currdisp = 'inline'; |
$currdisp = 'inline'; |
$collapse = '► '; |
$collapse = '► '; |
|
if ((@interval > 1) && ($hastimeleft)) { |
|
if ($usesdone eq 'done') { |
|
$donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext); |
|
} |
|
} |
} else { |
} else { |
$currdisp = 'none'; |
$currdisp = 'none'; |
$expand = '◄ '; |
$expand = '◄ '; |
Line 2878 sub countdown_timer {
|
Line 3237 sub countdown_timer {
|
} |
} |
my $desc = &mt('Countdown to due date/time'); |
my $desc = &mt('Countdown to due date/time'); |
return <<END; |
return <<END; |
|
$donebutton |
<a href="javascript:toggleCountdown();" class="LC_menubuttons_link"> |
<a href="javascript:toggleCountdown();" class="LC_menubuttons_link"> |
<span id="ddcountcollapse" class="LC_menubuttons_inline_text"> |
<span id="ddcountcollapse" class="LC_menubuttons_inline_text"> |
$collapse |
$collapse |