[LON-CAPA-users] Using Custom response

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Fri, 19 Oct 2007 15:06:53 -0400

Hi Brew,

Sorry about the negativity of this response, as far as I can tell the
specific thing you want to do is prevented fairly throughly due to
security concerns. (We'd rather not have authors having the ability to
read random files on the filesystem or run arbitrary programs on the
lon-capa servers.) 

> It sounds like the <externalresponse> is what I am looking for. I
> found the help page that describes it. This sounds pretty
> powerful.
> Anyone have an example of using this?

As far as I know it has not yet been used in a real course.

> I assume the
> url that gets called could be a perl or javascript routine published
> within the course, and that routine would have the capability of
> opening the file (presumably the filename is passed into the script
> as a parameter).

It's meant for the URL to be a CGI script on a remote server. So, no.

Additionally currently external response doesn't yet support the file
submission mechanism that essay response does.

> Something like
> <starouttext />This is the problem text<endouttext />
> <externalresponse url="/res/monroe/brew/MyScript.js $filename"
>     answer="OK">
>  <textline readonly="yes" />
> </externalresponse>

No, because MyScript.js isn't a cgi script. And there is no way for an
author to generate a cgi script that is a publishable item in
lon-capa. (It's due to security.)

And even then there isn't a mechanism for an author to read the
contents of a student's file. (Once again security.)

And even then that is incorrect externalresponse code, the url should
be just the url of the cscript that does the grading

so url="http://brews.own.machine/cgi/MyGradingScript.cgi"

The answer field should be the correct answer (I guess "OK" could be the
correct answer, but usually there is some info you might want to send
to at least let it know what problem is was.)

The student's submission would get automatically added to the POSTed
info as the form element LONCAPA_student_response

(Hmm, I think I need to toss more words into the external response
help file...)

What you are asking to do seems reasonable but there isn't currently a
mechanism to do it.

What I propose to add is something like
<startouttext />
  Submit a file.
<endouttext />
  <filesubmission />
  <answer type="loncapa/perl">
     foreach $file (@submitted_files) {
        $contents = &get_submitted_file_contents($file);
        # do something with the contents of $file

(Hmm... as an aside I think if you
1) had your own server to run the cgi scripts on and

2) and had the students
- add the file to their portfolio
- mark the file as public
- submitted an answer that was the url(s) of the portfolio file

You could use the exernalresponse mechanism as it exists right now to
do what you are looking at doing.)

guy@albertelli.com   0-7-0-6-27,137