Question Authors' Forum

Web service type question

Web service type question

by Ping Zhang -
Number of replies: 2

I am teaching a E-commerce module with PHP.

I would like to set up the web-service type question. It means the students' answer would be a web service (PHP file) which can process the GET and POST request.

The testcase would send the GET and POST request and the output would be result in json format.

Some rough idea is as:

In another post, I see with there is an internal webserver with the sandbox like the address "http://localhost/jobe/index.php/restapi/languages". So, if the students' answer has such an address, it would be possible.

Thanks all!

Ping @ Xi'an Jiaotong Liverpool University

In reply to Ping Zhang

Re: Web service type question

by Ping Zhang -
If students' code can be saved to a local file, which path can be used? Then this file can be visited through the URL address.
In reply to Ping Zhang

Re: Web service type question

by Richard Lobb -
I don't think CodeRunner will be able to work in the way you hope. CodeRunner uses a sandbox server called Jobe that provides a service to the Moodle server via a RESTful interface. That URL you quote, http://localhost/jobe/index.php/restapi/languages, is part of that API but it's not accessible to the questions that are being tested.

You ask about where the students' code is saved. Each run is saved in a temporary workspace on the Jobe server, which for security reasons is inaccessible to any other processes on the server except the program itself (i.e. the program consisting of the question author's marking code plus the student code).

A CodeRunner question must consist of the student's code wrapped in author-supplied test code via the question's template. You could possibly have testing code that sets the $_GET and $_POST superglobals to mimic the behaviour of a web service calling their code, and you could then capture and grade their response, but you can't run any web services as part of this process.