[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonexttool.pm lonprintout.pm
raeburn
raeburn at source.lon-capa.org
Sat Dec 30 14:51:31 EST 2017
raeburn Sat Dec 30 19:51:31 2017 EDT
Modified files:
/loncom/interface lonexttool.pm lonprintout.pm loncommon.pm
Log:
- Bug 6754 LON-CAPA as LTI Consumer: External Tools in printouts.
- Show name of tool instance in course (with points earned,
if gradable and status is SHOW_ANSWER).
-------------- next part --------------
Index: loncom/interface/lonexttool.pm
diff -u loncom/interface/lonexttool.pm:1.14 loncom/interface/lonexttool.pm:1.15
--- loncom/interface/lonexttool.pm:1.14 Sat Dec 30 14:03:53 2017
+++ loncom/interface/lonexttool.pm Sat Dec 30 19:51:30 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Launch External Tool Provider (LTI)
#
-# $Id: lonexttool.pm,v 1.14 2017/12/30 14:03:53 raeburn Exp $
+# $Id: lonexttool.pm,v 1.15 2017/12/30 19:51:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -127,10 +127,16 @@
return OK;
}
- my ($status,$open,$close,$msg,$donebuttonresult,$donemsg);
+ my ($symb,$status,$open,$close,$msg,$donebuttonresult,$donemsg);
+ if (($target eq 'tex') || ($toolhash{'gradable'})) {
+ ($symb) = &Apache::lonnet::whichuser();
+ }
+ if ($target eq 'tex') {
+ my $title = &Apache::lonnet::gettitle($symb);
+ $r->print(&mt('External Tool: [_1]','\textit{'.$title.'}').'\\\\');
+ }
if ($toolhash{'gradable'}) {
$Apache::lonhomework::browse = &Apache::lonnet::allowed('bre',$r->uri);
- my ($symb) = &Apache::lonnet::whichuser();
if ($env{'form.markaccess'}) {
my @interval=&Apache::lonnet::EXT('resource.0.interval',$symb);
my ($timelimit) = split(/_/,$interval[0]);
@@ -142,20 +148,27 @@
undef($env{'form.LC_interval_done'});
undef($env{'form.LC_interval_done_proctorpass'});
}
- ($status,$msg) = &gradabletool_access_check();
+ ($status,$msg) = &gradabletool_access_check($target);
undef($Apache::lonhomework::browse);
if ($status eq 'SHOW_ANSWER') {
- $r->print(&display_score());
+ $r->print(&display_score($target));
+ if ($target eq 'tex') {
+ $r->print('\end{document}');
+ }
return OK;
} elsif ($status ne 'CAN_ANSWER') {
- $r->print($msg);
+ if ($target eq 'tex') {
+ $r->print('\end{document}');
+ } else {
+ $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'));
+ $r->print(&mt('Not open to be viewed').'\end{document}');
} else {
$r->print($msg);
}
@@ -164,7 +177,7 @@
($status,$msg)=&Apache::lonipcheck::ip_access_check();
if ($status ne 'OPEN') {
if ($target eq 'tex') {
- $r->print(&mt('Not open to be viewed'));
+ $r->print(&mt('Not open to be viewed').'\end{document}');
} else {
$r->print($msg);
}
@@ -174,7 +187,7 @@
}
my $launchok = 1;
if ($target eq 'tex') {
- $r->print(&mt('External Tool'));
+ $r->print('\end{document}');
} else {
my $now = time;
if ($toolhash{'passback'}) {
@@ -448,11 +461,14 @@
}
sub gradabletool_access_check {
+ my ($target) = @_;
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'})) {
+ if ($target) {
+ @targets = ($target);
+ } elsif (defined($env{'form.submitted'}) && defined($env{'form.validate'})) {
@targets = ('grade','web');
} else {
@targets = ('web');
@@ -497,30 +513,42 @@
}
sub display_score {
+ my ($target) = @_;
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 ($target eq 'tex') {
+ $display = '\\\\';
+ }
if (!defined($awarded)) {
- $display = &mt('[_1] possible points.',$weight);
+ $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]',
+ $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>';
+ if ($target eq 'tex') {
+ $comment = '\\\\'.$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>';
+ if ($target eq 'tex') {
+ $gradeinfo = '\\\\'.$gradeinfo;
+ } else {
+ $gradeinfo='<br /><table><tr><td bgcolor="#DDDDFF"><font size="+2">'.$gradeinfo.'</font></td></tr></table>';
+ }
}
return $display.$comment.$gradeinfo;
}
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.659 loncom/interface/lonprintout.pm:1.660
--- loncom/interface/lonprintout.pm:1.659 Sun Nov 12 23:06:10 2017
+++ loncom/interface/lonprintout.pm Sat Dec 30 19:51:30 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.659 2017/11/12 23:06:10 raeburn Exp $
+# $Id: lonprintout.pm,v 1.660 2017/12/30 19:51:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2847,9 +2847,10 @@
$result = &print_latex_header() . $result;
}
# End construction space sequence.
- } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) {
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
+ if ($currentURL=~/\/ext\.tool$/) {$currentURL=~s/^\/adm\/wrapper//;}
$resources_printed .= $currentURL.':';
my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form);
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
@@ -3046,9 +3047,10 @@
}
$result .= $texversion;
$flag_latex_header_remove = 'YES';
- } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) {
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
+ if ($urlp=~/\/ext\.tool$/) {$urlp=~s/^\/adm\/wrapper//;}
$resources_printed .= $urlp.':';
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form);
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
@@ -3721,7 +3723,7 @@
$rendered =~ s/\\end\{document}//;
}
$current_output .= $rendered;
- } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) {
if ($i == 1) {
$syllabus_first = 1;
}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1305 loncom/interface/loncommon.pm:1.1306
--- loncom/interface/loncommon.pm:1.1305 Fri Dec 22 02:00:46 2017
+++ loncom/interface/loncommon.pm Sat Dec 30 19:51:30 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1305 2017/12/22 02:00:46 raeburn Exp $
+# $Id: loncommon.pm,v 1.1306 2017/12/30 19:51:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4692,6 +4692,9 @@
}
if (defined($target)) { $form{'grade_target'} = $target; }
$feedurl=&Apache::lonnet::clutter($feedurl);
+ if (($feedurl =~ /ext\.tool$/) && ($target eq 'tex')) {
+ $feedurl =~ s{^/adm/wrapper}{};
+ }
my ($userview,$response)=&Apache::lonnet::ssi_body($feedurl,%form);
$userview=~s/\<body[^\>]*\>//gi;
$userview=~s/\<\/body\>//gi;
More information about the LON-CAPA-cvs
mailing list