示例#1
0
 public function __construct($user = null, $pass = null)
 {
     if ($user == null) {
         $user = get_config('qtype_coderunner', 'ideone_user');
     }
     if ($pass == null) {
         $pass = get_config('qtype_coderunner', 'ideone_password');
     }
     qtype_coderunner_sandbox::__construct($user, $pass);
     // A map from Ideone language names (regular expressions) to their
     // local short name, where appropriate
     $aliases = array('C99 strict.*' => 'c', '.*python *2\\.[789]\\.[0-9].*' => 'python2', 'Python 3.*python-3\\.*' => 'python3', 'Java.*sun-jdk.*' => 'java');
     $this->client = $client = new SoapClient("http://ideone.com/api/1/service.wsdl");
     $this->langmap = array();
     // Construct a map from language name to id
     $response = $this->client->getLanguages($user, $pass);
     $this->langserror = $response['error'];
     if ($this->langserror == self::OK) {
         foreach ($response['languages'] as $id => $lang) {
             $this->langmap[$lang] = $id;
             foreach ($aliases as $pattern => $alias) {
                 if (preg_match('/' . $pattern . '/', $lang)) {
                     $this->langmap[$alias] = $id;
                 }
             }
         }
     } else {
         $this->langmap = array();
     }
 }
示例#2
0
 public function __construct()
 {
     qtype_coderunner_sandbox::__construct();
     list($this->httpcode, $this->response) = $this->http_request('languages', self::HTTP_GET);
     if ($this->httpcode == 200 && is_array($this->response)) {
         $this->languages = array();
         foreach ($this->response as $lang) {
             $this->languages[] = $lang[0];
         }
     } else {
         $this->languages = array();
     }
 }
示例#3
0
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Configuration settings declaration information for the CodeRunner question type.
 *
 * @package    qtype
 * @subpackage coderunner
 * @copyright  2014 Richard Lobb, The University of Canterbury.
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/question/type/coderunner/sandbox/sandboxbase.php';
$sandboxes = qtype_coderunner_sandbox::available_sandboxes();
foreach ($sandboxes as $sandbox => $classname) {
    $settings->add(new admin_setting_configcheckbox("qtype_coderunner/{$sandbox}_enabled", get_string('enable', 'qtype_coderunner') . ' ' . $sandbox, get_string('enable_sandbox_desc', 'qtype_coderunner'), $sandbox === 'jobesandbox'));
}
$settings->add(new admin_setting_configtext("qtype_coderunner/jobe_host", get_string('jobe_host', 'qtype_coderunner'), get_string('jobe_host_desc', 'qtype_coderunner'), 'jobe2.cosc.canterbury.ac.nz'));
$settings->add(new admin_setting_configtext("qtype_coderunner/jobe_apikey", get_string('jobe_apikey', 'qtype_coderunner'), get_string('jobe_apikey_desc', 'qtype_coderunner'), '2AAA7A5415B4A9B394B54BF1D2E9D'));
$settings->add(new admin_setting_configtext("qtype_coderunner/ideone_user", get_string('ideone_user', 'qtype_coderunner'), get_string('ideone_user_desc', 'qtype_coderunner'), ''));
$settings->add(new admin_setting_configtext("qtype_coderunner/ideone_password", get_string('ideone_pass', 'qtype_coderunner'), get_string('ideone_pass_desc', 'qtype_coderunner'), ''));
示例#4
0
 private function make_advanced_customisation_panel(&$mform)
 {
     $mform->addElement('header', 'advancedcustomisationheader', get_string('advanced_customisation', 'qtype_coderunner'));
     $prototypecontrols = array();
     $prototypeselect =& $mform->createElement('select', 'prototypetype', get_string('prototypeQ', 'qtype_coderunner'));
     $prototypeselect->addOption('No', '0');
     $prototypeselect->addOption('Yes (built-in)', '1', array('disabled' => 'disabled'));
     $prototypeselect->addOption('Yes (user defined)', '2');
     $prototypecontrols[] =& $prototypeselect;
     $prototypecontrols[] =& $mform->createElement('text', 'typename', get_string('typename', 'qtype_coderunner'), array('size' => 30));
     $mform->addElement('group', 'prototypecontrols', get_string('prototypecontrols', 'qtype_coderunner'), $prototypecontrols, null, false);
     $mform->setDefault('is_prototype', False);
     $mform->setType('typename', PARAM_RAW);
     $mform->addElement('hidden', 'saved_prototype_type');
     $mform->setType('saved_prototype_type', PARAM_RAW);
     $mform->addHelpButton('prototypecontrols', 'prototypecontrols', 'qtype_coderunner');
     $sandboxcontrols = array();
     $sandboxes = array('DEFAULT' => 'DEFAULT');
     foreach (qtype_coderunner_sandbox::available_sandboxes() as $ext => $class) {
         $sandboxes[$ext] = $ext;
     }
     $sandboxcontrols[] = $mform->createElement('select', 'sandbox', null, $sandboxes);
     $sandboxcontrols[] =& $mform->createElement('text', 'cputimelimitsecs', get_string('cputime', 'qtype_coderunner'), array('size' => 3));
     $sandboxcontrols[] =& $mform->createElement('text', 'memlimitmb', get_string('memorylimit', 'qtype_coderunner'), array('size' => 5));
     $sandboxcontrols[] =& $mform->createElement('text', 'sandboxparams', get_string('sandboxparams', 'qtype_coderunner'), array('size' => 15));
     $mform->addElement('group', 'sandboxcontrols', get_string('sandboxcontrols', 'qtype_coderunner'), $sandboxcontrols, null, false);
     $mform->setType('cputimelimitsecs', PARAM_RAW);
     $mform->setType('memlimitmb', PARAM_RAW);
     $mform->setType('sandboxparams', PARAM_RAW);
     $mform->addHelpButton('sandboxcontrols', 'sandboxcontrols', 'qtype_coderunner');
     $languages = array();
     $languages[] =& $mform->createElement('text', 'language', get_string('language', 'qtype_coderunner'), array('size' => 10));
     $mform->setType('language', PARAM_RAW);
     $languages[] =& $mform->createElement('text', 'acelang', get_string('ace-language', 'qtype_coderunner'), array('size' => 10));
     $mform->setType('acelang', PARAM_RAW);
     $mform->addElement('group', 'languages', get_string('languages', 'qtype_coderunner'), $languages, null, false);
     $mform->addHelpButton('languages', 'languages', 'qtype_coderunner');
     $combinatorcontrols = array();
     $combinatorcontrols[] =& $mform->createElement('advcheckbox', 'enablecombinator', null, get_string('enablecombinator', 'qtype_coderunner'));
     $combinatorcontrols[] =& $mform->createElement('text', 'testsplitterre', get_string('testsplitterre', 'qtype_coderunner'), array('size' => 45));
     $mform->setType('testsplitterre', PARAM_RAW);
     $mform->disabledIf('typename', 'prototypetype', 'neq', '2');
     $combinatorcontrols[] =& $mform->createElement('textarea', 'combinatortemplate', '', array('cols' => 60, 'rows' => 8, 'class' => 'template edit_code', 'name' => 'combinatortemplate'));
     $mform->addElement('group', 'combinatorcontrols', get_string('combinatorcontrols', 'qtype_coderunner'), $combinatorcontrols, null, false);
     $mform->addHelpButton('combinatorcontrols', 'combinatorcontrols', 'qtype_coderunner');
     $mform->setExpanded('customisationheader');
     // Although expanded it's hidden until JavaScript unhides it
 }
示例#5
0
 public function __construct($user = null, $pass = null)
 {
     qtype_coderunner_sandbox::__construct($user, $pass);
 }
示例#6
0
 private function make_error_message($run)
 {
     $err = "***" . qtype_coderunner_sandbox::result_string($run->result) . "***";
     if ($run->result === qtype_coderunner_sandbox::RESULT_RUNTIME_ERROR) {
         $sig = $run->signal;
         if ($sig) {
             $err .= " (signal {$sig})";
         }
     }
     return $this->merge("\n", array($run->cmpinfo, $run->output, $err, $run->stderr));
 }