[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/auth londatecheck.pm lonipcheck.pm loncom/homework bridgetask.pm lonhomework.pm loncom/interface loncommon.pm lonexttool.pm lonmenu.pm slotrequest.pm
raeburn
raeburn at source.lon-capa.org
Thu Dec 21 21:01:02 EST 2017
raeburn Fri Dec 22 02:01:02 2017 EDT
Modified files:
/loncom/homework bridgetask.pm lonhomework.pm
/loncom/interface loncommon.pm lonexttool.pm lonmenu.pm
slotrequest.pm
/loncom/auth londatecheck.pm lonipcheck.pm
/rat lonwrapper.pm
Log:
- Bug 6754 LON-CAPA as LTI Consumer
Support for access control using slots, and also for time interval
for external tools set to be "gradable".
-------------- next part --------------
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.267 loncom/homework/bridgetask.pm:1.268
--- loncom/homework/bridgetask.pm:1.267 Wed Aug 31 19:08:18 2016
+++ loncom/homework/bridgetask.pm Fri Dec 22 02:00:39 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.267 2016/08/31 19:08:18 raeburn Exp $
+# $Id: bridgetask.pm,v 1.268 2017/12/22 02:00:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -131,7 +131,14 @@
foreach my $res (@resources) {
&Apache::lonxml::debug("doing ".$res->src);
&Apache::structuretags::initialize_storage($res->symb);
- my $type = ($res->is_task()) ? 'Task' : 'problem';
+ my $type;
+ if ($res->is_task()) {
+ $type = 'Task';
+ } elsif ($res->is_tool) {
+ $type = 'tool';
+ } else {
+ $type = 'problem';
+ }
my $result = &create_new_version($type,$user,$domain,$slot_name,$res->symb,$ip,$needsiptied);
if ($result eq 'ok') {
&Apache::structuretags::finalize_storage($res->symb);
@@ -187,7 +194,7 @@
$domain = $env{'user.domain'};
}
- } elsif ($type eq 'problem') {
+ } elsif (($type eq 'problem') || ($type eq 'tool')) {
&Apache::lonxml::debug("authed $slot_name");
}
if (!defined($user) || !defined($domain)) {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.368 loncom/homework/lonhomework.pm:1.369
--- loncom/homework/lonhomework.pm:1.368 Mon Apr 3 13:01:43 2017
+++ loncom/homework/lonhomework.pm Fri Dec 22 02:00:39 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.368 2017/04/03 13:01:43 raeburn Exp $
+# $Id: lonhomework.pm,v 1.369 2017/12/22 02:00:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -190,7 +190,7 @@
if ($type eq 'Task') {
my $version=$Apache::lonhomework::history{'resource.0.version'};
$key ="resource.$version.0.checkedin";
- } elsif ($type eq 'problem') {
+ } elsif (($type eq 'problem') || ($type eq 'tool')) {
$key ='resource.0.checkedin';
}
# backward compatability, used to be username at domain,
@@ -205,7 +205,6 @@
return 1;
}
}
-
return 0;
}
@@ -350,7 +349,7 @@
$is_correct =
($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass'
|| $Apache::lonhomework::history{"resource.0.solved"} =~ /^correct_/ );
- } elsif ($type eq 'problem') {
+ } elsif (($type eq 'problem') || ($type eq 'tool')) {
if ((ref($partlist) eq 'ARRAY') && (@{$partlist} > 0)) {
my ($numcorrect,$numgraded) = (0,0);
foreach my $part (@{$partlist}) {
@@ -410,7 +409,7 @@
# used to gain access to it to work on it, until the due date is reached, and the
# problem then becomes CLOSED. Therefore return the slotstatus -
# (which will be one of: NOT_IN_A_SLOT, RESERVABLE, RESERVABLE_LATER, or NOTRESERVABLE).
- if (!defined($slot_name) && $type eq 'problem') {
+ if (!defined($slot_name) && (($type eq 'problem') || ($type eq 'tool'))) {
if ($slotstatus eq 'NOT_IN_A_SLOT') {
if (!$num_usable_slots) {
if ($env{'request.course.id'}) {
@@ -501,7 +500,7 @@
}
if (($is_correct) && ($blockip ne 'answer')) {
- if ($type eq 'problem') {
+ if (($type eq 'problem') || ($type eq 'tool')) {
return ($status);
}
return ('SHOW_ANSWER');
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1304 loncom/interface/loncommon.pm:1.1305
--- loncom/interface/loncommon.pm:1.1304 Mon Dec 18 16:11:18 2017
+++ loncom/interface/loncommon.pm Fri Dec 22 02:00:46 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1304 2017/12/18 16:11:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.1305 2017/12/22 02:00:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4579,9 +4579,15 @@
}
$prevattempts.= &end_data_table_row().&end_data_table();
} else {
+ my $msg;
+ if ($symb =~ /ext\.tool$/) {
+ $msg = &mt('No grade passed back.');
+ } else {
+ $msg = &mt('Nothing submitted - no attempts.');
+ }
$prevattempts=
&start_data_table().&start_data_table_row().
- '<td>'.&mt('Nothing submitted - no attempts.').'</td>'.
+ '<td>'.$msg.'</td>'.
&end_data_table_row().&end_data_table();
}
} else {
Index: loncom/interface/lonexttool.pm
diff -u loncom/interface/lonexttool.pm:1.11 loncom/interface/lonexttool.pm:1.12
--- loncom/interface/lonexttool.pm:1.11 Mon Dec 18 16:11:18 2017
+++ loncom/interface/lonexttool.pm Fri Dec 22 02:00:46 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Launch External Tool Provider (LTI)
#
-# $Id: lonexttool.pm,v 1.11 2017/12/18 16:11:18 raeburn Exp $
+# $Id: lonexttool.pm,v 1.12 2017/12/22 02:00:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -49,6 +49,10 @@
use Apache::lonlocal;
use Apache::lonnet;
use Apache::loncommon;
+use Apache::londatecheck;
+use Apache::lonipcheck;
+use Apache::lonhomework;
+use Apache::structuretags;
use LONCAPA::ltiutils;
sub handler {
@@ -62,6 +66,8 @@
# ------------------------------------------------------------ Print the screen
if ($target eq 'tex') {
$r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
+ } else {
+ $target = 'web';
}
# Is this even in a course?
@@ -90,15 +96,15 @@
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
- my $is_tool;
+ my ($idx,$is_tool,%toolhash,%toolsettings);
if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") {
- my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
+ %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
if ($toolsettings{'id'}) {
- my $idx = $toolsettings{'id'};
+ $idx = $toolsettings{'id'};
my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
if (ref($ltitools{$idx}) eq 'HASH') {
- my %toolhash = %{$ltitools{$idx}};
+ %toolhash = %{$ltitools{$idx}};
$toolhash{'display'} = {
target => $toolsettings{'target'},
width => $toolsettings{'width'},
@@ -107,40 +113,8 @@
$toolhash{'crslabel'} = $toolsettings{'crslabel'};
$toolhash{'crstitle'} = $toolsettings{'crstitle'};
$toolhash{'crsappend'} = $toolsettings{'crsappend'};
+ $toolhash{'gradable'} = $toolsettings{'gradable'};
$is_tool = 1;
- my $launchok = 1;
- if ($target eq 'tex') {
- $r->print(&mt('External Tool'));
- } else {
- my $now = time;
- if ($toolhash{'passback'}) {
- if (&LONCAPA::ltiutils::set_service_secret($cdom,$cnum,$marker,'grade',$now,
- \%toolsettings,\%toolhash) eq 'ok') {
- $toolhash{'gradesecret'} = $toolsettings{'gradesecret'};
- } else {
- undef($launchok);
- }
- }
- if ($toolhash{'roster'}) {
- if (&LONCAPA::ltiutils::set_service_secret($cdom,$cnum,$marker,'roster',$now,
- \%toolsettings,\%toolhash) eq 'ok') {
- $toolhash{'rostersecret'} = $toolsettings{'rostersecret'};
- }
- }
- my $submittext = &mt('Launch [_1]',$toolhash{'title'});
- if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') &&
- ($toolhash{'url'} ne '') && ($launchok)) {
- my %lti = <i_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash);
- my $url = $toolhash{'url'};
- if ($toolhash{'crsappend'} ne '') {
- $url .= $toolhash{'crsappend'};
- }
- $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'},
- $submittext,\%lti));
- } else {
- $r->print('<div>'.&mt('External Tool Unavailable').'</div>');
- }
- }
}
}
}
@@ -150,6 +124,79 @@
} else {
$r->print('\textbf{'.&mt(Invalid Call).'}\end{document}');
}
+ return OK;
+ }
+
+ my ($status,$open,$close,$msg);
+ if ($toolhash{'gradable'}) {
+ $Apache::lonhomework::browse = &Apache::lonnet::allowed('bre',$r->uri);
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ my ($timelimit) = split(/_/,$interval[0]);
+ &Apache::lonnet::set_first_access($interval[1],$timelimit);
+ }
+ ($status,$msg) = &gradabletool_access_check();
+ undef($Apache::lonhomework::browse);
+ if ($status eq 'SHOW_ANSWER') {
+ $r->print(&display_score());
+ return OK;
+ } elsif ($status ne 'CAN_ANSWER') {
+ $r->print($msg);
+ return OK;
+ }
+ } else {
+ my ($status,$open,$close,$msg)=&Apache::londatecheck::content_date_check();
+ if ($status ne 'OPEN') {
+ if ($target eq 'tex') {
+ $r->print(&mt('Not open to be viewed'));
+ } else {
+ $r->print($msg);
+ }
+ return OK;
+ } else {
+ ($status,$msg)=&Apache::lonipcheck::ip_access_check();
+ if ($status ne 'OPEN') {
+ if ($target eq 'tex') {
+ $r->print(&mt('Not open to be viewed'));
+ } else {
+ $r->print($msg);
+ }
+ return OK;
+ }
+ }
+ }
+ my $launchok = 1;
+ if ($target eq 'tex') {
+ $r->print(&mt('External Tool'));
+ } else {
+ my $now = time;
+ if ($toolhash{'passback'}) {
+ if (&LONCAPA::ltiutils::set_service_secret($cdom,$cnum,$marker,'grade',$now,
+ \%toolsettings,\%toolhash) eq 'ok') {
+ $toolhash{'gradesecret'} = $toolsettings{'gradesecret'};
+ } else {
+ undef($launchok);
+ }
+ }
+ if ($toolhash{'roster'}) {
+ if (&LONCAPA::ltiutils::set_service_secret($cdom,$cnum,$marker,'roster',$now,
+ \%toolsettings,\%toolhash) eq 'ok') {
+ $toolhash{'rostersecret'} = $toolsettings{'rostersecret'};
+ }
+ }
+ my $submittext = &mt('Launch [_1]',$toolhash{'title'});
+ if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') &&
+ ($toolhash{'url'} ne '') && ($launchok)) {
+ my %lti = <i_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash);
+ my $url = $toolhash{'url'};
+ if ($toolhash{'crsappend'} ne '') {
+ $url .= $toolhash{'crsappend'};
+ }
+ $r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'},
+ $submittext,\%lti));
+ } else {
+ $r->print('<div>'.&mt('External Tool Unavailable').'</div>');
+ }
}
return OK;
}
@@ -393,4 +440,82 @@
return $form;
}
+sub gradabletool_access_check {
+ my ($result,$resource_due);
+ my $status;
+ my ($symb,$courseid,$udom,$uname) = &Apache::lonnet::whichuser();
+ my @targets;
+ if (defined($env{'form.submitted'}) && defined($env{'form.validate'})) {
+ @targets = ('grade','web');
+ } else {
+ @targets = ('web');
+ }
+ foreach my $target (@targets) {
+ undef(%Apache::lonhomework::results);
+ undef(%Apache::lonhomework::history);
+ %Apache::lonhomework::history =
+ &Apache::lonnet::restore($symb,$courseid,$udom,$uname);
+ &Apache::lonhomework::set_show_problem_status(&Apache::lonnet::EXT('resource.0.problemstatus'));
+ my ($accessmsg,$slot_name,$slot,$ipused);
+ ($status,$accessmsg,$slot_name,$slot,$ipused) =
+ &Apache::lonhomework::check_slot_access('0','tool',$symb);
+ if (( $status eq 'CLOSED' ) ||
+ ( $status eq 'UNCHECKEDOUT') ||
+ ( $status eq 'NOT_YET_VIEWED') ||
+ ( $status eq 'BANNED') ||
+ ( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NOTRESERVABLE') ||
+ ( $status eq 'RESERVABLE') ||
+ ( $status eq 'RESERVABLE_LATER') ||
+ ( $status eq 'INVALID_ACCESS') ||
+ ( $status eq 'NEED_DIFFERENT_IP') ||
+ ( $status eq 'WAITING_FOR_GRADE')) {
+ $result = &Apache::structuretags::access_status_msg('tool',$status,$symb,
+ $target,$ipused,$accessmsg);
+ } elsif ($status eq 'NEEDS_CHECKIN') {
+ $result = &Apache::structuretags::checkin_prompt($target,$slot_name,$slot,'tool');
+ } elsif ($target eq 'web') {
+ if ($status eq 'CAN_ANSWER') {
+ $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
+ if ($slot_name ne '') {
+ $resource_due = &Apache::structuretags::selfcheckin_resource($resource_due,
+ $slot_name,$slot,
+ $env{'request.symb'});
+ }
+ }
+ }
+ }
+ return ($status,$result,$resource_due);
+}
+
+sub display_score {
+ my $weight = &Apache::lonnet::EXT('resource.0.weight');
+ if ((!defined($weight)) || ($weight eq '')) { $weight=1; }
+ my $awarded = $Apache::lonhomework::history{'resource.0.awarded'};
+ if (!defined($awarded)) { $awarded=0; }
+ my $display='';
+ if (!defined($awarded)) {
+ $display = &mt('[_1] possible points.',$weight);
+ } else {
+ my $points = $awarded*$weight;
+ my $result = sprintf('%.2f',$points);
+ $display = &mt('You have [_1] out of [quant,_2,possible point]',
+ $result,$weight);
+ }
+ my $comment = $Apache::lonhomework::history{'resource.0.comment'};
+ if (!defined($comment) || $comment!~/\w/) {
+ $comment='';
+ } else {
+ $comment='<br /><table><tr><td bgcolor="#FFFFDD">'.$comment.'</td></tr></table>';
+ }
+ my $gradeinfo = $Apache::lonhomework::history{'resource.0.gradeinfo'};
+ if (!defined($gradeinfo) || $gradeinfo!~/\w/) {
+ $gradeinfo='';
+ } else {
+ $gradeinfo='<br /><table><tr><td bgcolor="#DDDDFF"><font size="+2">'.$gradeinfo.'</font></td></tr></table>';
+ }
+ return $display.$comment.$gradeinfo;
+}
+
1;
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.484 loncom/interface/lonmenu.pm:1.485
--- loncom/interface/lonmenu.pm:1.484 Mon Dec 18 23:20:48 2017
+++ loncom/interface/lonmenu.pm Fri Dec 22 02:00:46 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.484 2017/12/18 23:20:48 raeburn Exp $
+# $Id: lonmenu.pm,v 1.485 2017/12/22 02:00:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2714,11 +2714,19 @@
my $now = time;
if ($env{'request.filename'} =~ /\.task$/) {
$type = 'Task';
+ } elsif ($env{'request.symb'} =~ /ext\.tool$/) {
+ $type = 'tool';
} else {
$type = 'problem';
}
- my ($status,$accessmsg,$slot_name,$slot) =
- &Apache::lonhomework::check_slot_access('0',$type);
+ my ($status,$accessmsg,$slot_name,$slot);
+ if ($type eq 'tool') {
+ ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0',$type,$env{'request.symb'},['0']);
+ } else {
+ ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0',$type);
+ }
if ($slot_name ne '') {
if (ref($slot) eq 'HASH') {
if (($slot->{'starttime'} < $now) &&
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.135 loncom/interface/slotrequest.pm:1.136
--- loncom/interface/slotrequest.pm:1.135 Fri Aug 11 18:58:16 2017
+++ loncom/interface/slotrequest.pm Fri Dec 22 02:00:46 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for requesting to have slots added to a students record
#
-# $Id: slotrequest.pm,v 1.135 2017/08/11 18:58:16 raeburn Exp $
+# $Id: slotrequest.pm,v 1.136 2017/12/22 02:00:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -465,7 +465,7 @@
return 'error: Unable to determine current status';
}
my @problems = $navmap->retrieveResources(undef,
- sub { $_[0]->is_problem() },1,0);
+ sub { $_[0]->is_gradable() },1,0);
my %used_slots;
foreach my $problem (@problems) {
my $symb = $problem->symb();
@@ -805,7 +805,7 @@
if ($passed_resource->is_map()) {
my ($a_resource) =
$navmap->retrieveResources($passed_resource,
- sub {$_[0]->is_problem()},0,1);
+ sub {$_[0]->is_gradable()},0,1);
$symb = $a_resource->symb();
}
} else {
@@ -2028,7 +2028,7 @@
if (ref($resource)) {
my $symb = $resource->symb();
$contents{$lastcontainer} ++;
- next if (!$resource->is_problem() && !$resource->is_sequence() &&
+ next if (!$resource->is_gradable() && !$resource->is_sequence() &&
!$resource->is_page());
$count ++;
if (($resource->is_sequence()) || ($resource->is_page())) {
@@ -2036,7 +2036,7 @@
$container{$lastcontainer} = $resource;
$container_title{$lastcontainer} = $resource->compTitle();
}
- if ($resource->is_problem()) {
+ if ($resource->is_gradable()) {
my ($useslots) = $resource->slot_control();
next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i));
push(@ordered,$symb);
Index: loncom/auth/londatecheck.pm
diff -u loncom/auth/londatecheck.pm:1.13 loncom/auth/londatecheck.pm:1.14
--- loncom/auth/londatecheck.pm:1.13 Wed Apr 11 11:40:07 2012
+++ loncom/auth/londatecheck.pm Fri Dec 22 02:00:53 2017
@@ -1,5 +1,5 @@
# Checks contentopen/close settings disable subsequent PerlHandlers if not open
-# $Id: londatecheck.pm,v 1.13 2012/04/11 11:40:07 goltermann Exp $
+# $Id: londatecheck.pm,v 1.14 2017/12/22 02:00:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -55,6 +55,10 @@
if (&Apache::lonnet::allowed('bre',$r->uri) eq 'F') {
return DECLINED;
}
+ if (($r->uri =~ /ext\.tool$/) &&
+ (&Apache::lonnet::EXT('resource.0.gradable',$env{'request.symb'}) =~ /^yes$/i)) {
+ return DECLINED;
+ }
my ($status,$open,$close,$msg)=&content_date_check();
if ($status ne 'OPEN') {
$r->set_handlers('PerlHandler'=>undef);
Index: loncom/auth/lonipcheck.pm
diff -u loncom/auth/lonipcheck.pm:1.1 loncom/auth/lonipcheck.pm:1.2
--- loncom/auth/lonipcheck.pm:1.1 Fri Sep 5 17:43:31 2008
+++ loncom/auth/lonipcheck.pm Fri Dec 22 02:00:53 2017
@@ -1,5 +1,5 @@
# Checks IP access settings - disable subsequent PerlHandlers if client IP blocked
-# $Id: lonipcheck.pm,v 1.1 2008/09/05 17:43:31 raeburn Exp $
+# $Id: lonipcheck.pm,v 1.2 2017/12/22 02:00:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,6 +51,10 @@
if (&Apache::lonnet::allowed('bre',$r->uri) eq 'F') {
return DECLINED;
}
+ if (($r->uri =~ /ext\.tool$/) &&
+ (&Apache::lonnet::EXT('resource.0.gradable',$env{'request.symb'}) =~ /^yes$/i)) {
+ return DECLINED;
+ }
my ($status,$msg)=&ip_access_check();
if ($status ne 'OPEN') {
$r->set_handlers('PerlHandler'=>undef);
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.66 rat/lonwrapper.pm:1.67
--- rat/lonwrapper.pm:1.66 Mon Dec 18 23:23:14 2017
+++ rat/lonwrapper.pm Fri Dec 22 02:01:01 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.66 2017/12/18 23:23:14 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.67 2017/12/22 02:01:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -82,25 +82,45 @@
$args->{'only_body'} = $env{'form.only_body'};
}
- my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);
- my $endpage = &Apache::loncommon::end_page();
-
- if (($exttool) && (&Apache::lonnet::EXT('resource.0.gradable'))) {
- my $resource_due = &Apache::lonhomework::due_date(0, $env{'request.symb'});
- if ($resource_due) {
- my $time_left = $resource_due - time();
- if ($resource_due && ($time_left > 0)) {
- $startpage .='
+ my $countdown;
+ if (($exttool) && (&Apache::lonnet::EXT('resource.0.gradable') =~ /^yes$/i)) {
+ $Apache::lonhomework::browse = &Apache::lonnet::allowed('bre',$url);
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ my ($timelimit) = split(/_/,$interval[0]);
+ &Apache::lonnet::set_first_access($interval[1],$timelimit);
+ delete($env{'form.markaccess'});
+ }
+ my ($status,$result,$resource_due) =
+ &Apache::lonexttool::gradabletool_access_check();
+ undef($Apache::lonhomework::browse);
+ if ($status eq 'CAN_ANSWER') {
+ if ($resource_due) {
+ my $time_left = $resource_due - time();
+ if ($resource_due && ($time_left > 0)) {
+ $countdown ='
<script type="text/javascript">
// <![CDATA['."\n".
&Apache::lonhtmlcommon::countdown().'
// ]]>
</script>'."\n".
- &Apache::lonhtmlcommon::set_due_date($resource_due);
+ &Apache::lonhtmlcommon::set_due_date($resource_due);
+ }
}
+ } else {
+ if ($status eq 'SHOW_ANSWER') {
+ $result = &Apache::lonexttool::display_score().
+ &Apache::lonfeedback::list_discussion('tool','OPEN');
+ }
+ return &Apache::loncommon::start_page('Menu',undef,$args).
+ $result.
+ &Apache::loncommon::end_page();
}
}
+ my $startpage = &Apache::loncommon::start_page('Menu',undef,$args).$countdown;
+ my $endpage = &Apache::loncommon::end_page();
+
if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) {
my $output = $startpage;
if ($is_pdf) {
More information about the LON-CAPA-cvs
mailing list