version 1.438, 2016/01/26 14:30:25
|
version 1.442, 2016/03/17 13:51:28
|
Line 371 sub secondary_menu {
|
Line 371 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'}; |
Line 397 sub secondary_menu {
|
Line 398 sub secondary_menu {
|
$showresv = 1; |
$showresv = 1; |
} |
} |
} |
} |
|
my %groups = &Apache::lonnet::get_active_groups( |
|
$env{'user.domain'}, $env{'user.name'},$cdom,$cnum); |
|
if (%groups) { |
|
foreach my $group (keys(%groups)) { |
|
my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"}); |
|
shift(@privs); |
|
if (@privs) { |
|
$grouptools ++; |
|
} |
|
} |
|
} |
} |
} |
|
|
my ($canmodifycoauthor); |
my ($canmodifycoauthor); |
Line 407 sub secondary_menu {
|
Line 419 sub secondary_menu {
|
$canmodifycoauthor = 1; |
$canmodifycoauthor = 1; |
} |
} |
} |
} |
|
|
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 441 sub secondary_menu {
|
Line 447 sub secondary_menu {
|
&& !$canmodpara; |
&& !$canmodpara; |
next if $$menuitem[4] =~ /showgroups$/ |
next if $$menuitem[4] =~ /showgroups$/ |
&& !$canviewgrps |
&& !$canviewgrps |
&& !%groups; |
&& !$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 1562 END
|
Line 1568 END
|
} |
} |
|
|
# This creates a "done button" for timed events. The confirmation box is a jQuery |
# This creates a "done button" for timed events. The confirmation box is a jQuery |
# dialog widget. Clicking OK will set (LC_interval_done = 'true') which is checked in |
# dialog widget. If the interval parameter requires a proctor key for the timed |
# lonhomework.pm. |
# 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 { |
sub done_button_js { |
my ($type,$height) = @_; |
my ($type,$width,$height,$proctor) = @_; |
if ($height !~ /^\d+$/) { |
return unless (($type eq 'map') || ($type eq 'resource')); |
$height = 320; |
|
} |
|
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
title => 'WARNING!', |
title => 'WARNING!', |
button => 'Done', |
button => 'Done', |
preamble => 'You are trying to end this timed event early.', |
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.', |
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).', |
ok => 'Click "OK" if you are completely finished.', |
okdone => 'Click "OK" if you are completely finished.', |
cancel => 'Click "Cancel" to continue working.', |
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 $confirm; |
my $navmap = Apache::lonnavmaps::navmap->new(); |
if (($type eq 'map') || ($type eq 'resource')) { |
my ($missing,$tried); |
$confirm = $lt{'preamble'}.' '.$lt{$type}.' '.$lt{'ok'}.' '.$lt{'cancel'}; |
if (ref($navmap)) { |
|
$missing=0; |
|
$tried=0; |
|
my @resources=(); |
|
if ($type eq 'map') { |
|
my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'}); |
|
@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 ($res->singlepart()) { |
|
if (!$res->tries()) { |
|
$missing++; |
|
} else { |
|
$tried++; |
|
} |
|
} else { |
|
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>'; |
|
} |
} |
} |
if ($confirm) { |
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">$lt{'button'}</button> |
|
</form> |
|
|
|
<div id="LC_done-confirm" title="$lt{'title'}"> |
|
<p>$lt{'preamble'} $lt{$type}</p> |
|
$lt{'miss'} |
|
<p>$lt{'proctor'}</p> |
|
<form> |
|
<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; |
return <<END; |
|
|
<form method="post" name="LCdoneButton" action=""> |
<form method="post" name="LCdoneButton" action=""> |
Line 1591 sub done_button_js {
|
Line 1744 sub done_button_js {
|
</form> |
</form> |
|
|
<div id="LC_done-confirm" title="$lt{'title'}"> |
<div id="LC_done-confirm" title="$lt{'title'}"> |
<p>$confirm</p> |
<p>$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}</p> |
</div> |
</div> |
|
|
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 1602 sub done_button_js {
|
Line 1755 sub done_button_js {
|
\$( "#LC_done-confirm" ).dialog({ |
\$( "#LC_done-confirm" ).dialog({ |
resizable: false, |
resizable: false, |
height: $height, |
height: $height, |
|
width: $width, |
modal: true, |
modal: true, |
buttons: { |
buttons: [ |
"OK": function() { |
{ |
\$( this ).dialog( "close" ); |
text: "$lt{'ok'}", |
\$( '[name="LC_interval_done"]' )[0].value = 'true'; |
click: function() { |
\$( '[name="LCdoneButton"]' )[0].submit(); |
\$( this ).dialog( "close" ); |
}, |
\$( '[name="LC_interval_done"]' )[0].value = 'true'; |
Cancel: function() { |
\$( '[name="LCdoneButton"]' )[0].submit(); |
\$( this ).dialog( "close" ); |
}, |
} |
}, |
} |
{ |
}) |
text: "$lt{'exit'}", |
|
click: function() { |
|
\$( this ).dialog( "close" ); |
|
}, |
|
}, |
|
], |
|
}); |
}); |
}); |
// ]]> |
// ]]> |
</script> |
</script> |
|
|
END |
END |
} else { |
|
return; |
|
} |
} |
} |
} |
|
|
Line 2287 sub countdown_timer {
|
Line 2445 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); |
my ($timelimit,$usesdone,$proctor,$secret); |
if (@interval > 1) { |
if (@interval > 1) { |
($timelimit,$usesdone) = split(/_/,$interval[0]); |
($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]); |
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+$timelimit > time) { |
if ($first_access+$timelimit > time) { |
Line 2307 sub countdown_timer {
|
Line 2465 sub countdown_timer {
|
$collapse = '► '; |
$collapse = '► '; |
if ((@interval > 1) && ($hastimeleft)) { |
if ((@interval > 1) && ($hastimeleft)) { |
if ($usesdone eq 'done') { |
if ($usesdone eq 'done') { |
$donebutton = &done_button_js($interval[1]); |
$donebutton = &done_button_js($interval[1],'','',$proctor); |
} |
} |
} |
} |
} else { |
} else { |