-//
-
-ENDCLOSE
-}
-
sub dc_popup_js {
my %lt = &Apache::lonlocal::texthash(
more => '(More ...)',
@@ -2194,12 +1624,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.
#
@@ -2210,27 +1640,24 @@ 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 ($missing,$tried) = (0,0);
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my ($missing,$tried);
if (ref($navmap)) {
+ $missing=0;
+ $tried=0;
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() });
- }
+ @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() });
} else {
my $res = $navmap->getBySymb($env{'request.symb'});
if (ref($res)) {
@@ -2240,7 +1667,13 @@ sub done_button_js {
}
}
foreach my $res (@resources) {
- if (ref($res->parts()) eq 'ARRAY') {
+ if ($res->singlepart()) {
+ if (!$res->tries()) {
+ $missing++;
+ } else {
+ $tried++;
+ }
+ } else {
foreach my $part (@{$res->parts()}) {
if (!$res->tries($part)) {
$missing++;
@@ -2264,12 +1697,11 @@ sub done_button_js {
$lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'';
}
}
- $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"');
if ($proctor) {
if ($height !~ /^\d+$/) {
$height = 400;
if ($missing) {
- $height += 60;
+ $height += 60;
}
}
if ($width !~ /^\d+$/) {
@@ -2282,7 +1714,6 @@ sub done_button_js {
@@ -2290,7 +1721,7 @@ sub done_button_js {
$lt{'preamble'} $lt{$type}
$lt{'miss'}
$lt{'proctor'}
-
@@ -2313,8 +1744,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();
@@ -2364,8 +1795,7 @@ END
@@ -2410,18 +1840,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'}.
@@ -2447,10 +1873,6 @@ sub utilityfunctions {
my $countdown = &countdown_toggle_js();
- my $annotateurl = '/adm/annotation';
- if ($httphost) {
- $annotateurl = '/adm/annotations';
- }
my $hostvar = '
function setLCHost() {
var lcHostname="";
@@ -2465,7 +1887,7 @@ function setLCHost() {
' }'."\n".
' }'."\n";
}
-
+
$hostvar .= ' return lcHostname;'."\n".
'}'."\n";
@@ -2579,7 +2001,7 @@ function annotate() {
annotator.document.write(
'$start_page_annotate'
+"'."\n";
foreach my $role (@roles_order) {
@@ -2818,20 +2220,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)]);
}
}
}
@@ -2902,7 +2295,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,
@@ -2912,101 +2305,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.',
@@ -3039,26 +2339,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";
}
}
@@ -3122,7 +2425,6 @@ function adhocRole(newrole) {
fullrole += '/'+secchoice;
}
} else {
- document.rolechooser.elements[roleitem].selectedIndex = 0;
if (secchoice != null) {
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
}
@@ -3156,13 +2458,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') {
@@ -3238,6 +2540,7 @@ sub countdown_timer {
$title = $alttxt.' ';
}
my $desc = &mt('Countdown to due date/time');
+
return <