$lt{'preamble'} $lt{$type}
$lt{'miss'}
$lt{'proctor'}
-
@@ -2216,8 +1689,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();
@@ -2267,7 +1740,7 @@ END
@@ -2359,7 +1832,7 @@ function setLCHost() {
' }'."\n".
' }'."\n";
}
-
+
$hostvar .= ' return lcHostname;'."\n".
'}'."\n";
@@ -2542,16 +2015,6 @@ 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'} ) {
@@ -2566,7 +2029,7 @@ sub roles_selector {
my ($cdom,$cnum,$httphost) = @_;
my $crstype = &Apache::loncommon::course_type();
my $now = time;
- my (%courseroles,%seccount,%courseprivs,%roledesc);
+ my (%courseroles,%seccount,%courseprivs);
my $is_cc;
my ($js,$form,$switcher);
my $ccrole;
@@ -2575,7 +2038,7 @@ sub roles_selector {
} else {
$ccrole = 'cc';
}
- my ($privref,$gotsymb,$destsymb);
+ my ($priv,$gotsymb,$destsymb);
my $destinationurl = $ENV{'REQUEST_URI'};
if ($destinationurl =~ /\?symb=/) {
$gotsymb = 1;
@@ -2596,15 +2059,12 @@ sub roles_selector {
my $destination = $destinationurl;
$destination =~ s/(\?.*)$//;
if (exists($reqprivs->{$destination})) {
- if ($reqprivs->{$destination} =~ /,/) {
- @{$privref} = split(/,/,$reqprivs->{$destination});
- } else {
- $privref = [$reqprivs->{$destination}];
- }
+ $priv = $reqprivs->{$destination};
}
}
if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
+
if ((($start) && ($start<0)) ||
(($end) && ($end<$now)) ||
(($start) && ($now<$start))) {
@@ -2614,9 +2074,7 @@ sub roles_selector {
}
}
if ($is_cc) {
- &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs);
- } elsif ($env{'request.role'} =~ m{^\Qcr/$cdom/$cdom-domainconfig/\E(\w+)\.\Q/$cdom/$cnum\E}) {
- &get_customadhoc_roles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,\%roledesc,$privref);
+ &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
} else {
my %gotnosection;
foreach my $item (keys(%env)) {
@@ -2632,7 +2090,7 @@ sub roles_selector {
$gotnosection{$role} = 1;
}
}
- if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0)) {
+ if ($priv ne '') {
my $cnumsec = $cnum;
if ($sec ne '') {
$cnumsec .= "/$sec";
@@ -2670,7 +2128,7 @@ sub roles_selector {
}
if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
my @submenu;
- $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,\%roledesc,$privref);
+ $js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
$form =
''."\n";
foreach my $role (@roles_order) {
@@ -2707,20 +2165,11 @@ sub roles_selector {
$include = 1;
}
} else {
- $include = 1;
+ $include = 1;
}
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'".')',
- $rolename]);
+ &Apache::lonnet::plaintext($role)]);
}
}
}
@@ -2791,7 +2240,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,
@@ -2801,101 +2250,8 @@ sub get_all_courseroles {
return;
}
-sub get_customadhoc_roles {
- my ($cdom,$cnum,$courseroles,$seccount,$courseprivs,$roledesc,$privref) = @_;
- unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
- (ref($courseprivs) eq 'HASH') && (ref($roledesc) eq 'HASH')) {
- return;
- }
- my $is_helpdesk = 0;
- my $now = time;
- foreach my $role ('dh','da') {
- if ($env{"user.role.$role./$cdom/"}) {
- my ($start,$end)=split(/\./,$env{"user.role.$role./$cdom/"});
- if (!($start && ($now<$start)) && !($end && ($now>$end))) {
- $is_helpdesk = 1;
- last;
- }
- }
- }
- if ($is_helpdesk) {
- my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum);
- my %available;
- if (ref($possroles) eq 'ARRAY') {
- map { $available{$_} = 1; } @{$possroles};
- }
- my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
- if (ref($domdefaults{'adhocroles'}) eq 'HASH') {
- if (keys(%{$domdefaults{'adhocroles'}})) {
- my $numsec = 1;
- my @sections;
- my ($allseclist,$cached) =
- &Apache::lonnet::is_cached_new('courseseclist',$cdom.'_'.$cnum);
- if (defined($cached)) {
- if ($allseclist ne '') {
- @sections = split(/,/,$allseclist);
- $numsec += scalar(@sections);
- }
- } else {
- my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
- @sections = sort(keys(%sections_count));
- $numsec += scalar(@sections);
- $allseclist = join(',',@sections);
- &Apache::lonnet::do_cache_new('courseseclist',$cdom.'_'.$cnum,$allseclist);
- }
- my (%adhoc,$gotprivs);
- my $prefix = "cr/$cdom/$cdom".'-domainconfig';
- foreach my $role (keys(%{$domdefaults{'adhocroles'}})) {
- next if (($role eq '') || ($role =~ /\W/));
- $seccount->{"$prefix/$role"} = $numsec;
- $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./"} =
- $env{"user.priv.$prefix/$role./$cdom/$cnum./"};
- $courseprivs->{"$prefix/$role./$cdom/$cnum./$cdom/"} =
- $env{"user.priv.$prefix/$role./$cdom/$cnum./$cdom/"};
- $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;
- }
- ($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;
- }
- }
- }
- }
- }
- return;
-}
-
sub jump_to_role {
- my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$roledesc,$privref) = @_;
+ my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
my %lt = &Apache::lonlocal::texthash(
this => 'This role has section(s) associated with it.',
ente => 'Enter a specific section.',
@@ -2928,26 +2284,29 @@ sub jump_to_role {
}
}
my $checkroles = 0;
- if ((ref($privref) eq 'ARRAY') && (@{$privref} > 0) && (ref($courseprivs) eq 'HASH')) {
- my %disallowed;
+ if ($priv && ref($courseprivs) eq 'HASH') {
+ my (%disallowed,%allowed,@disallow);
foreach my $role (sort(keys(%{$courseprivs}))) {
my $trole;
if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
$trole = $1;
}
if (($trole ne '') && ($trole ne 'cm')) {
- $disallowed{$trole} = 1;
- foreach my $priv (@{$privref}) {
- if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
- delete($disallowed{$trole});
- last;
- }
+ if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
+ $allowed{$trole} = 1;
+ } else {
+ $disallowed{$trole} = 1;
}
}
}
- if (keys(%disallowed) > 0) {
+ foreach my $trole (keys(%disallowed)) {
+ unless ($allowed{$trole}) {
+ push(@disallow,$trole);
+ }
+ }
+ if (@disallow > 0) {
$checkroles = 1;
- $js .= " var disallow = new Array('".join("','",keys(%disallowed))."');\n".
+ $js .= " var disallow = new Array('".join("','",@disallow)."');\n".
" var rolecheck = 1;\n";
}
}
@@ -3011,7 +2370,6 @@ function adhocRole(newrole) {
fullrole += '/'+secchoice;
}
} else {
- document.rolechooser.elements[roleitem].selectedIndex = 0;
if (secchoice != null) {
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
}
@@ -3045,13 +2403,13 @@ END
sub required_privs {
my $privs = {
- '/adm/parmset' => 'opa,vpa',
- '/adm/courseprefs' => 'opa,vpa',
+ '/adm/parmset' => 'opa',
+ '/adm/courseprefs' => 'opa',
'/adm/whatsnew' => 'whn',
- '/adm/populate' => 'cst,vpa,vcl',
+ '/adm/populate' => 'cst',
'/adm/trackstudent' => 'vsa',
- '/adm/statistics' => 'mgr,vgr',
- '/adm/setblock' => 'dcm,vcb',
+ '/adm/statistics' => 'vgr',
+ '/adm/setblock' => 'dcm',
'/adm/coursedocs' => 'mdc',
};
unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
@@ -3087,17 +2445,9 @@ sub countdown_timer {
}
my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
my @interval=&Apache::lonnet::EXT("resource.0.interval");
- my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
+ my ($timelimit,$usesdone,$proctor,$secret);
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);
- }
+ ($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]);
my $first_access=&Apache::lonnet::get_first_access($interval[1]);
if ($first_access > 0) {
if ($first_access+$timelimit > time) {
@@ -3115,7 +2465,7 @@ sub countdown_timer {
$collapse = '► ';
if ((@interval > 1) && ($hastimeleft)) {
if ($usesdone eq 'done') {
- $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
+ $donebutton = &done_button_js($interval[1],'','',$proctor);
}
}
} else {
@@ -3127,6 +2477,7 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <