Example #1
0
 /**
  * Adds a course status to a user in a specific course.
  *
  * Called when this component receives an HTTP POST request to
  * /coursestatus(/).
  * The request body should contain a JSON object representing the user's
  * course status.
  */
 public function addCourseMember($callName, $input, $params = array())
 {
     $positive = function ($input) {
         // sets the new auto-increment id
         //$obj = new User( );
         //$obj->setId( $input[0]->getInsertId( ) );
         return Model::isCreated();
     };
     return $this->_component->callSqlTemplate('out', dirname(__FILE__) . '/Sql/AddCourseMember.sql', array('values' => $input->getCourseStatusInsertData()), 201, $positive, array(), 'Model::isProblem', array(new User()));
 }
Example #2
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform($callName, $input, $params = array())
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     $file = dirname(__FILE__) . '/config.ini';
     $text = "[DIR]\n" . "temp = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $input->getTempDirectory())) . "\"\n" . "files = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), str_replace("\\", "/", $input->getFilesDirectory())) . "\"\n";
     if (!@file_put_contents($file, $text)) {
         Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
         return Model::isProblem();
     }
     $platform = new Platform();
     $platform->setStatus(201);
     return Model::isCreated($platform);
 }
Example #3
0
 public function postSamples($callName, $input, $params = array())
 {
     set_time_limit(0);
     $sql = array();
     for ($i = 1; $i <= $params['amount']; $i++) {
         $rr = md5($i);
         $obj = ExerciseType::createExerciseType($i, $rr);
         $sql[] = "insert ignore into ExerciseType SET " . $obj->getInsertData() . ";";
         if ($i % 1000 == 0) {
             $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
             $sql = array();
         }
     }
     $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
     return Model::isCreated();
 }
Example #4
0
 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform($callName, $input, $params = array())
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     //$this->loadConfig($name);
     // decode the received course data, as an object
     $insert = $input;
     $result = Model::isOK();
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $file = dirname(__FILE__) . '/config.ini';
         $text = "[DB]\n" . "db_path = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseUrl()) . "\"\n" . "db_user = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorUser()) . "\"\n" . "db_passwd = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorPassword()) . "\"\n" . "db_name = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseName()) . "\"\n" . "[PL]\n" . "urlExtern = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getExternalUrl()) . "\"\n" . "url = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getBaseUrl()) . "\"";
         if (!@file_put_contents($file, $text)) {
             Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
             $result = Model::isProblem();
         }
         $platform = new Platform();
         $platform->setStatus(201);
         $res[] = $platform;
         $result = Model::isCreated();
     }
     $return['content'] = $res;
     return $return;
 }
 public function postSamples($callName, $input, $params = array())
 {
     set_time_limit(0);
     $sql = array();
     for ($i = 1; $i <= $params['amount']; $i++) {
         for ($b = 0; $b < 3; $b++) {
             $obj = ApprovalCondition::createApprovalCondition($i * 3 + $b, $i, ($i * 3 + $b) % 1000 + 1, '0.5');
             $sql[] = "insert ignore into ApprovalCondition SET " . $obj->getInsertData() . ";";
         }
         if ($i % 1000 == 0) {
             $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
             $sql = array();
         }
     }
     $this->_component->callSql('out2', implode('', $sql), 201, 'Model::isCreated', array(), 'Model::isProblem', array(new File()));
     return Model::isCreated();
 }