# The LearningOnline Network with CAPA
# external style responses
#
# $Id: externalresponse.pm,v 1.22 2013/08/22 11:13:43 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package Apache::externalresponse;
use strict;
use HTTP::Request::Common;
use Apache::loncapagrade;
use Apache::lonnet;
use Apache::lonlocal;
use Apache::lonxml();
use Apache::lonhtmlcommon;
use Apache::loncommon;
use Apache::lonnavmaps;
use LONCAPA qw(:DEFAULT :match);
BEGIN {
&Apache::lonxml::register('Apache::externalresponse',('externalresponse'));
}
=pod
=head1 FIXME (start_externalresponse)
send of response params and their current values (form good enough? what parameters to send?)
Need to get returned message displayed
=cut
sub start_externalresponse {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
my $id = &Apache::response::start_response($parstack,$safeeval);
if ($target eq 'edit') {
$result .=&Apache::edit::tag_start($target,$token);
$result .=&Apache::edit::text_arg('URL:','url',$token,60).' ';
$result .=&Apache::edit::text_arg(&mt('Answer:'),'answer',$token);
$result .=&Apache::edit::text_arg(&mt('Form:'),'form',$token).' ';
$result .=&Apache::edit::text_arg(&mt('Answer display:'),'answerdisplay',$token,80);
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag =
&Apache::edit::get_new_args($token,$parstack,$safeeval,
'answerdisplay','answer','form','url');
if ($constructtag) {
$result = &Apache::edit::rebuild_tag($token);
}
} elsif ($target eq 'meta') {
$result=&Apache::response::meta_package_write('externalresponse');
}
elsif ($target eq 'web' &&
$Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $part= $Apache::inputtags::part;
my $ncol= &Apache::lonnet::EXT("resource.$part".'_'."$id.maxcollaborators");
my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
$uploadedfiletypes=~s/[^\w\,]//g;
my $maxfilesize=&Apache::lonnet::EXT("resource.$part".'_'."$id.maxfilesize");
if (!defined($maxfilesize)) {
$maxfilesize = 10.0; #FIXME This should become a domain configuration
}
if($uploadedfiletypes){
my $hiddendraft;
if (($Apache::lonhomework::type eq 'survey') ||
($Apache::lonhomework::type eq 'surveycred') ||
($Apache::lonhomework::type eq 'anonsurvey') ||
($Apache::lonhomework::type eq 'anonsurveycred')) {
$hiddendraft = '';
} else {
my $status_text = &mt('Submission type');
if ($Apache::lonhomework::history{"resource.$part.award"} eq 'DRAFT') {
$status_text .= ' '.&mt('(Currently -- draft)');
}
$result = &Apache::lonhtmlcommon::row_title($status_text);
my $closure;
unless ($ncol || $uploadedfiletypes) {
$closure = 1;
}
$result.=
' '.
''.
&Apache::lonhtmlcommon::row_closure($closure);
}
if ($ncol > 0) {
$result.= &Apache::lonhtmlcommon::row_title(&mt('Collaborators')).
' ';
$result .= &Apache::essayresponse::check_collaborators($ncol,$coll) if ($coll =~ /\w+/);
$result .= &Apache::lonhtmlcommon::row_closure();
}
my $filesfrom = 'both';
my $stuname = &Apache::lonnet::EXT('user.name');
my $studom = &Apache::lonnet::EXT('user.domain');
if (!&Apache::lonnet::usertools_access($stuname,$studom,'portfolio')) {
$filesfrom = 'uploadonly';
}
$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes,
$filesfrom,undef,$maxfilesize);
if ($result) {
$result =
'