-
$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}
+
+
You are trying to end this timed event early. Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder. Click "OK" if you are completely finished. Click "Cancel" to continue working.
-
END
- }
}
sub utilityfunctions {
@@ -2384,7 +1626,7 @@ function setLCHost() {
' }'."\n".
' }'."\n";
}
-
+
$hostvar .= ' return lcHostname;'."\n".
'}'."\n";
@@ -2567,16 +1809,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'} ) {
@@ -2591,16 +1823,16 @@ 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 ($js,$form,$switcher,$switchtext);
my $ccrole;
if ($crstype eq 'Community') {
$ccrole = 'co';
} else {
$ccrole = 'cc';
}
- my ($privref,$gotsymb,$destsymb);
+ my ($priv,$gotsymb,$destsymb);
my $destinationurl = $ENV{'REQUEST_URI'};
if ($destinationurl =~ /\?symb=/) {
$gotsymb = 1;
@@ -2621,15 +1853,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))) {
@@ -2639,9 +1868,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)) {
@@ -2657,7 +1884,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";
@@ -2686,6 +1913,7 @@ sub roles_selector {
}
}
}
+ $switchtext = 'Switch role'; # do not translate here
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
my $numdiffsec;
if (keys(%seccount) == 1) {
@@ -2695,7 +1923,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) {
@@ -2732,25 +1960,16 @@ 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)]);
}
}
}
if (@submenu > 0) {
- $switcher = &create_submenu('','',&mt('Switch role'),\@submenu);
+ $switcher = &create_submenu('','',$switchtext,\@submenu);
}
}
return ($js,$form,$switcher);
@@ -2816,7 +2035,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,
@@ -2826,101 +2045,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.',
@@ -2953,26 +2079,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";
}
}
@@ -3036,7 +2165,6 @@ function adhocRole(newrole) {
fullrole += '/'+secchoice;
}
} else {
- document.rolechooser.elements[roleitem].selectedIndex = 0;
if (secchoice != null) {
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
}
@@ -3070,13 +2198,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') {
@@ -3112,20 +2240,10 @@ 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);
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]);
if ($first_access > 0) {
- if ($first_access+$timelimit > time) {
+ if ($first_access+$interval[0] > time) {
$hastimeleft = 1;
}
}
@@ -3138,11 +2256,9 @@ sub countdown_timer {
($type eq 'Task' && $slothastime)) {
$currdisp = 'inline';
$collapse = '► ';
- if ((@interval > 1) && ($hastimeleft)) {
- if ($usesdone eq 'done') {
- $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
- }
- }
+ $donebutton = &done_button_js();
+
+
} else {
$currdisp = 'none';
$expand = '◄ ';
@@ -3152,8 +2268,9 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <