$lt{'preamble'} $lt{$type}
$lt{'miss'}
$lt{'proctor'}
-
@@ -2308,8 +1741,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();
@@ -2359,7 +1792,7 @@ END
@@ -2404,18 +1837,14 @@ END
sub utilityfunctions {
my ($httphost) = @_;
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
- if ($currenturl =~ m{^/adm/wrapper/ext/}) {
- if ($env{'request.external.querystring'}) {
+ if ($currenturl =~ m{^/adm/wrapper/ext/}
+ && $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));
+ my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
+
my $dc_popup_cid;
if ($env{'user.adv'} && exists($env{'user.role.dc./'.
$env{'course.'.$env{'request.course.id'}.
@@ -2441,10 +1870,6 @@ sub utilityfunctions {
my $countdown = &countdown_toggle_js();
- my $annotateurl = '/adm/annotation';
- if ($httphost) {
- $annotateurl = '/adm/annotations';
- }
my $hostvar = '
function setLCHost() {
var lcHostname="";
@@ -2459,7 +1884,7 @@ function setLCHost() {
' }'."\n".
' }'."\n";
}
-
+
$hostvar .= ' return lcHostname;'."\n".
'}'."\n";
@@ -2573,7 +1998,7 @@ function annotate() {
annotator.document.write(
'$start_page_annotate'
+"'."\n";
foreach my $role (@roles_order) {
@@ -2812,20 +2217,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)]);
}
}
}
@@ -2896,7 +2292,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,
@@ -2906,101 +2302,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.',
@@ -3033,26 +2336,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";
}
}
@@ -3116,7 +2422,6 @@ function adhocRole(newrole) {
fullrole += '/'+secchoice;
}
} else {
- document.rolechooser.elements[roleitem].selectedIndex = 0;
if (secchoice != null) {
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
}
@@ -3150,13 +2455,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') {
@@ -3192,17 +2497,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) {
@@ -3220,7 +2517,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 {
@@ -3232,6 +2529,7 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <