/**
  * Helper that sets up the maxima configuration. This allows maxima to be used
  * from test classes that cannot subclass this one, for whatever reason.
  */
 public static function setup_test_maxima_connection()
 {
     global $CFG;
     if (!self::is_test_config_available()) {
         throw new coding_exception('The calling code should call setup_test_maxima_connection ' . 'and skip the test in an appropriate way if it returns false.');
     }
     if (!defined('QTYPE_STACK_EXPECTED_VERSION')) {
         if (!preg_match('~\\[ STACK-Maxima started, library version (\\d{10}) \\]~', file_get_contents($CFG->dirroot . '/question/type/stack/stack/maxima/stackmaxima.mac'), $matches)) {
             throw new coding_exception('Maxima libraries version number not found in stackmaxima.mac.');
         }
         define('QTYPE_STACK_EXPECTED_VERSION', $matches[1]);
     }
     set_config('platform', QTYPE_STACK_TEST_CONFIG_PLATFORM, 'qtype_stack');
     set_config('maximaversion', QTYPE_STACK_TEST_CONFIG_MAXIMAVERSION, 'qtype_stack');
     set_config('castimeout', QTYPE_STACK_TEST_CONFIG_CASTIMEOUT, 'qtype_stack');
     set_config('casresultscache', QTYPE_STACK_TEST_CONFIG_CASRESULTSCACHE, 'qtype_stack');
     set_config('maximacommand', QTYPE_STACK_TEST_CONFIG_MAXIMACOMMAND, 'qtype_stack');
     set_config('plotcommand', QTYPE_STACK_TEST_CONFIG_PLOTCOMMAND, 'qtype_stack');
     set_config('casdebugging', QTYPE_STACK_TEST_CONFIG_CASDEBUGGING, 'qtype_stack');
     set_config('mathsdisplay', 'mathjax', 'qtype_stack');
     set_config('replacedollars', 0, 'qtype_stack');
     set_config('stackmaximaversion', QTYPE_STACK_EXPECTED_VERSION, 'qtype_stack');
     if (QTYPE_STACK_TEST_CONFIG_CASRESULTSCACHE == 'otherdb') {
         set_config('cascachedbtype', QTYPE_STACK_TEST_CONFIG_CASCACHEDBTYPE, 'qtype_stack');
         set_config('cascachedblibrary', QTYPE_STACK_TEST_CONFIG_CASCACHEDBLIBRARY, 'qtype_stack');
         set_config('cascachedbhost', QTYPE_STACK_TEST_CONFIG_CASCACHEDBHOST, 'qtype_stack');
         set_config('cascachedbname', QTYPE_STACK_TEST_CONFIG_CASCACHEDBNAME, 'qtype_stack');
         set_config('cascachedbuser', QTYPE_STACK_TEST_CONFIG_CASCACHEDBUSER, 'qtype_stack');
         set_config('cascachedbpass', QTYPE_STACK_TEST_CONFIG_CASCACHEDBPASS, 'qtype_stack');
         set_config('cascachedbprefix', QTYPE_STACK_TEST_CONFIG_CASCACHEDBPREFIX, 'qtype_stack');
         if (defined('QTYPE_STACK_TEST_CONFIG_CASCACHEDBSOCKET')) {
             set_config('cascachedbsocket', QTYPE_STACK_TEST_CONFIG_CASCACHEDBSOCKET, 'qtype_stack');
         }
     }
     if (defined('QTYPE_STACK_TEST_CONFIG_SERVERUSERPASS')) {
         set_config('serveruserpass', QTYPE_STACK_TEST_CONFIG_SERVERUSERPASS, 'qtype_stack');
     }
     if (stack_cas_configuration::maxima_bat_is_missing()) {
         stack_cas_configuration::create_maximalocal();
     }
     // Create the required directories inside moodledata.
     make_upload_directory('stack');
     make_upload_directory('stack/logs');
     make_upload_directory('stack/plots');
     make_upload_directory('stack/tmp');
 }
Exemplo n.º 2
0
// Check for location of Maxima.
$maximalocation = stack_cas_configuration::confirm_maxima_win_location();
if ('' != $maximalocation) {
    $message = stack_string('healthcheckconfigintro1') . ' ' . html_writer::tag('tt', $maximalocation);
    echo html_writer::tag('p', $message);
    $summary[] = array(null, $message);
}
// Check if the current options for library packaes are permitted (maximalibraries).
list($valid, $message) = stack_cas_configuration::validate_maximalibraries();
if (!$valid) {
    echo html_writer::tag('p', $message);
    $summary[] = array(false, $message);
}
// Try to connect to create maxima local.
echo html_writer::tag('p', stack_string('healthcheckconfigintro2'));
stack_cas_configuration::create_maximalocal();
echo html_writer::tag('textarea', stack_cas_configuration::generate_maximalocal_contents(), array('readonly' => 'readonly', 'wrap' => 'virtual', 'rows' => '32', 'cols' => '100'));
// Maxima config.
if (stack_cas_configuration::maxima_bat_is_missing()) {
    echo $OUTPUT->heading(stack_string('healthcheckmaximabat'), 3);
    $message = stack_string('healthcheckmaximabatinfo', $CFG->dataroot);
    echo html_writer::tag('p', $message);
    $summary[] = array(false, $message);
}
// Test an *uncached* call to the CAS.  I.e. a genuine call to the process.
echo $OUTPUT->heading(stack_string('healthuncached'), 3);
echo html_writer::tag('p', stack_string('healthuncachedintro'));
list($message, $genuinedebug, $result) = stack_connection_helper::stackmaxima_genuine_connect();
$summary[] = array($result, $message);
echo html_writer::tag('p', $message);
echo output_debug(stack_string('debuginfo'), $genuinedebug);