コード例 #1
0
ファイル: Rrserve.php プロジェクト: vinod-co/centa
 function connect()
 {
     $this->reset_error();
     if (is_null(self::$cnx)) {
         // Connection failed!
         $this->set_error("Can Not Connect");
         return false;
     }
     if (self::$cnx === false) {
         try {
             // if the box isnt on this timeout is ignored and is likely to be different
             if (!isset($this->config['timeout'])) {
                 $timeoutarray = array('seconds' => 5, 'milliseconds' => 1);
             } else {
                 $timeoutarray = array('seconds' => $this->config['timeout'], 'milliseconds' => 1);
             }
             self::$cnx = @new Rserve_Connection($this->config['host'], $this->config['port'], $timeoutarray);
         } catch (exception $except) {
             self::$cnx = null;
             $this->set_error('Can Not Connect');
             return false;
         }
         $this->setup_R();
         return true;
     } else {
         // We are connected
         return true;
     }
 }
コード例 #2
0
ファイル: calc-compare.php プロジェクト: vinod-co/centa
require_once $cfg_web_root . 'classes/authentication.class.php';
require_once $cfg_web_root . 'classes/lang.class.php';
require_once $cfg_web_root . '/classes/moduleutils.class.php';
require_once $cfg_web_root . '/classes/schoolutils.class.php';
require_once $cfg_web_root . '/classes/usernotices.class.php';
global $cfg_web_root;
global $cfg_web_root;
require $cfg_web_root . 'plugins/questions/enhancedcalc/enhancedcalc.class.php';
echo "Start";
$enhancedcalcType = 'phpEval';
// $this->configObj->get('enhancedcalc_type');
require_once $cfg_web_root . '/plugins/questions/enhancedcalc/' . $enhancedcalcType . '.php';
$name = 'enhancedcalc_' . $enhancedcalcType;
$enhancedcalcObj1 = new $name($enhancedcalcType);
require_once $cfg_web_root . '/plugins/questions/enhancedcalc/' . 'Rrserve.php';
$enhancedcalcObj2 = new EnhancedCalc_Rrserve($configObject->getbyref('enhancedcalculation'));
$numbers[] = 0;
$numbers[] = 10;
$numbers[] = 1000;
$numbers[] = 1000000;
$numbers[] = 100000000000.0;
$numbers[] = 1000000000000000.0;
$numbers[] = 0.1;
$numbers[] = 1.0E-5;
$numbers[] = 1.0E-9;
$numbers[] = 1.0E-13;
$numbers[] = 1.0E-18;
$numbers[] = 3;
$numbers[] = 13;
$numbers[] = 13450;
$numbers[] = 13346346;
コード例 #3
0
ファイル: enhancedcalc.class.php プロジェクト: vinod-co/centa
 /**
  * Return the 'distance' of the user's answer from the correct answer as a percentage of the correct answer
  * @return float Distance from the correct answer
  */
 public function get_answer_distance()
 {
     if (!isset($this->useranswer['cans_dist'])) {
         $enhancedcalcType = $this->configObj->get('enhancedcalc_type');
         if (!is_null($enhancedcalcType)) {
             require_once $enhancedcalcType . '.php';
             $name = 'enhancedcalc_' . $enhancedcalcType;
             $enhancedcalcObj = new $name($this->configObj->getbyref($enhancedcalcType));
         } else {
             require_once 'Rrserve.php';
             $enhancedcalcObj = new EnhancedCalc_Rrserve($this->configObj->getbyref('enhancedcalculation'));
         }
         if (isset($this->useranswer['status']['exact']) and $this->useranswer['status']['exact'] === false or !isset($this->useranswer['status']['exact'])) {
             $this->useranswer['cans_dist'] = $enhancedcalcObj->distance_from_correct_answer($this->useranswer['uansnumb'], $this->useranswer['cans']);
         } else {
             $this->useranswer['cans_dist'] = '0';
         }
     }
     $data = false;
     if (isset($this->useranswer['cans_dist']) and $this->useranswer['cans_dist'] !== 'ERROR') {
         $data = $this->useranswer['cans_dist'];
     }
     return $data;
 }
require_once $cfg_web_root . 'classes/stringutils.class.php';
$mysqli->autocommit(false);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
if (!$updater_utils->has_updated('convert_calc_ans_done')) {
    //if (!file_exists("./stopfile_convert_calc_ans_done.txt")) {
    $configObj = Config::get_instance();
    $root = $configObj->get('root');
    $enhancedcalcType = $configObj->get('enhancedcalc_type');
    if (!is_null($enhancedcalcType)) {
        require_once $root . '/plugins/questions/enhancedcalc/' . $enhancedcalcType . '.php';
        $name = 'enhancedcalc_' . $enhancedcalcType;
        $enhancedcalcObj = new $name($configObj->getbyref('enhancedcalculation'));
    } else {
        require_once $root . '/plugins/questions/enhancedcalc/Rrserve.php';
        $enhancedcalcObj = new EnhancedCalc_Rrserve($configObj->getbyref('enhancedcalculation'));
    }
    echo "<li>Converting Calculation answers to enhanced calculation answers</li>";
    set_time_limit(0);
    $LOG = '0';
    $logarray = array('0', '1', '2', '3', '0_deleted', '1_deleted', '_late');
    foreach ($logarray as $LOG) {
        $loop = 0;
        $sql = "select questions.q_id,id,user_answer,settings from questions,log{$LOG} where q_type='enhancedcalc' and questions.q_id=log{$LOG}.q_id;";
        $result = $mysqli->prepare("{$sql}");
        $result->execute();
        $result->store_result();
        $result->bind_result($qid, $uid, $user_answer, $settings);
        $vars = array('$A', '$B', '$C', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', '$L');
        //perpair the update once!
        $sql = "UPDATE log{$LOG} set user_answer=? where id=?";
コード例 #5
0
ファイル: checkenhancedcalc.php プロジェクト: vinod-co/centa
require_once $cfg_web_root . '/classes/usernotices.class.php';
global $cfg_web_root;
global $cfg_web_root;
require $cfg_web_root . 'plugins/questions/enhancedcalc/enhancedcalc.class.php';
error_reporting(E_ALL);
echo "<html>";
echo "Starting<br><br>";
$enhancedcalcType = $configObject->get('enhancedcalc_type');
$root = $configObject->getbyref('root');
if (!is_null($enhancedcalcType)) {
    require_once $root . 'plugins/questions/enhancedcalc/' . $enhancedcalcType . '.php';
    $name = 'enhancedcalc_' . $enhancedcalcType;
    $enhancedcalcObj1 = new $name($configObject->getbyref('enhancedcalculation'));
} else {
    require_once $root . 'plugins/questions/enhancedcalc/' . 'Rrserve.php';
    $enhancedcalcObj1 = new EnhancedCalc_Rrserve($configObject->getbyref('enhancedcalculation'));
}
if ($enhancedcalcType == '') {
    $enhancedcalcType = 'BLANK or MISSING setting that means it defaults to Rserve';
}
$sets = var_export($configObject->getbyRef('enhancedcalculation'), true);
echo "<li>Enhanced Calc is set to <b>{$enhancedcalcType}</b></li>";
echo "<li>Settings are {$sets}</li>";
$data = array();
$data[] = array(array('$A' => 2, '$B' => 2), '$A+$B', '4');
$data[] = array(array('$A' => 2, '$B' => 2), '$A*$B', '4');
$data[] = array(array('$A' => 3, '$B' => 3), '$A+$B', '6');
$data[] = array(array('$A' => 3, '$B' => 3), '$A*$B', '9');
$data[] = array(array('$A' => 4, '$B' => 4), '$A+$B', '8');
$data[] = array(array('$A' => 4, '$B' => 4), '$A*$B', '16');
$data[] = array(array('$A' => 8, '$B' => 2), '$A/$B', '4');