Example #1
0
 /**
  * Ermittelt alle mit der CInstall am Ausgang $name verknüpften Komponenten
  *
  * @param string $name Der Name des Ausgangs, dessen Ziele gesucht ermittelt werden sollen
  * @return link[] Eine Liste der Komponenten an diesem Ausgang
  */
 public static function getLinks($name)
 {
     if (self::$config === null) {
         self::$config = CConfig::loadStaticConfig('', '', dirname(__FILE__), '/../component/cinstall_cconfig.json');
     }
     return CConfig::getLinks(self::$config->getLinks(), $name);
 }
Example #2
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  *
  * @param Component $conf component data
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(LTutor::getPrefix(), dirname(__FILE__));
     // runs the LTutor
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     /**
      *Initialise the Slim-Framework
      */
     $this->app = new \Slim\Slim();
     $this->app->response->headers->set('Content-Type', 'application/json');
     if (file_exists(dirname(__FILE__) . '/config.ini')) {
         $this->config = parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE);
     }
     /**
      *Set the Logiccontroller-URL
      */
     $this->_conf = $conf;
     $this->query = array();
     $this->query = CConfig::getLink($conf->getLinks(), "controller");
     $this->_postTransaction = array(CConfig::getLink($this->_conf->getLinks(), 'postTransaction'));
     $this->_getTransaction = array(CConfig::getLink($this->_conf->getLinks(), 'getTransaction'));
     $this->_postZip = array(CConfig::getLink($this->_conf->getLinks(), 'postZip'));
     $this->_postPdf = array(CConfig::getLink($this->_conf->getLinks(), 'postPdf'));
     $this->_postMarking = array(CConfig::getLink($this->_conf->getLinks(), 'postMarking'));
     $this->_getMarking = array(CConfig::getLink($this->_conf->getLinks(), 'getMarking'));
     $this->_getExercise = array(CConfig::getLink($this->_conf->getLinks(), 'getExercise'));
     $this->_getGroup = array(CConfig::getLink($this->_conf->getLinks(), 'getGroup'));
     $this->_getSubmission = array(CConfig::getLink($this->_conf->getLinks(), 'getSubmission'));
     $this->_postSubmission = array(CConfig::getLink($this->_conf->getLinks(), 'postSubmission'));
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     // POST AddPlatform
     $this->app->post('/platform', array($this, 'addPlatform'));
     // DELETE DeletePlatform
     $this->app->delete('/platform', array($this, 'deletePlatform'));
     // GET GetExistsPlatform
     $this->app->get('/link/exists/platform', array($this, 'getExistsPlatform'));
     // POST PostSubmissionConvert
     $this->app->post('/submission/convert(/timestamp/begin/:begin/end/:end)', array($this, 'postSubmissionConvert'));
     //Set auto allocation by exercise
     $this->app->post('/' . $this->getPrefix() . '/auto/exercise/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'autoAllocateByExercise'));
     //Set auto allocation by group
     $this->app->post('/' . $this->getPrefix() . '/auto/group/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'autoAllocateByGroup'));
     //Get zip
     $this->app->get('/' . $this->getPrefix() . '/user/:userid/exercisesheet/:sheetid(/status/:status)(/)', array($this, 'getZip'));
     //Post zip
     $this->app->post('/' . $this->getPrefix() . '/archive/user/:userid/exercisesheet/:sheetid(/)', array($this, 'postTutorArchive'));
     //Post zip
     $this->app->post('/' . $this->getPrefix() . '/archive/user/:userid/exercisesheet/:sheetid/withnames(/)', array($this, 'postTutorArchiveWithNames'));
     //uploadZip
     $this->app->post('/' . $this->getPrefix() . '/user/:userid/course/:courseid(/)', array($this, 'uploadZip'));
     //run Slim
     $this->app->run();
 }
Example #3
0
 /**
  * Sendet $sql an $linkName und behandelt die Antwort
  *
  * @param string $linkName Der Name des Ausgangs
  * @param string $sql Der zu verwendende SQL Inhalt
  * @param int $positiveStatus Der Status, welcher als erfolgreiche Antwort gesehen wird (Bsp.: 200)
  * @param callable $positiveMethod Im positiven Fall wird diese Methode aufgerufen
  * @param mixed[] $positiveParams Die Werte, welche an die positive Funktion übergeben werden
  * @param callable $negativeMethod Im negativen Fall wird diese Methode aufgerufen
  * @param mixed[] $negativeParams Die Werte, welche an die negative Funktion übergeben werden
  * @param bool $checkSession Ob die Sessiondaten in der Datenbank geprüft werden sollen
  * @return mixed Das Ergebnis der aufgerufenen Resultatfunktion
  */
 public function callSql($linkName, $sql, $positiveStatus, callable $positiveMethod, $positiveParams, callable $negativeMethod, $negativeParams, $checkSession = true)
 {
     $link = CConfig::getLink($this->_conf->getLinks(), $linkName);
     // starts a query, by using given sql statements/statement
     $result = DBRequest::getRoutedSql($link, $sql, $checkSession);
     // checks the correctness of the query
     if ($result['status'] == $positiveStatus) {
         // die Antwort war so, wie wir sie erwartet haben
         $queryResult = Query::decodeQuery($result['content']);
         if (!is_array($queryResult)) {
             $queryResult = array($queryResult);
         }
         // rufe nun die positive Methode auf
         return call_user_func_array($positiveMethod, array_merge(array("input" => $queryResult), $positiveParams));
     }
     // ansonsten rufen wir die negative Methode auf
     return call_user_func_array($negativeMethod, $negativeParams);
 }
Example #4
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  *
  * @param Component $conf component data
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(LExerciseSheet::getPrefix(), dirname(__FILE__));
     // runs the LExerciseSheet
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize slim
     $this->app = new \Slim\Slim();
     $this->app->response->headers->set('Content-Type', 'application/json');
     // initialize component
     $this->_conf = $conf;
     $this->query = CConfig::getLink($conf->getLinks(), "controller");
     $this->_postFile = CConfig::getLinks($this->_conf->getLinks(), 'postFile');
     $this->_deleteFile = CConfig::getLinks($this->_conf->getLinks(), 'deleteFile');
     $this->_postExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'postExerciseSheet');
     $this->_deleteExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'deleteExerciseSheet');
     $this->_getExerciseSheet = CConfig::getLinks($this->_conf->getLinks(), 'getExerciseSheet');
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     // POST AddExerciseSheet
     $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addExerciseSheet'));
     // PUT EditExerciseSheet
     $this->app->put('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'editExerciseSheet'));
     // GET GetExerciseSheetURL
     $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/url(/)', array($this, 'getExerciseSheetURL'));
     // GET GetExerciseSheet
     $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'getExerciseSheet'));
     // GET GetExerciseSheet incl exercises
     $this->app->get('/' . $this->getPrefix() . '/exercisesheet/:sheetid/exercise(/)', array($this, 'getExerciseSheetExercise'));
     // GET GetExerciseSheet from course incl exercises
     $this->app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getExerciseSheetCourse'));
     // GET GetExerciseSheet from course incl exercises
     $this->app->get('/' . $this->getPrefix() . '/course/:courseid/exercise(/)', array($this, 'getExerciseSheetCourseExercise'));
     // DELETE DeleteExerciseSheet
     $this->app->delete('/' . $this->getPrefix() . '/exercisesheet/:sheetid(/)', array($this, 'deleteExerciseSheet'));
     // run Slim
     $this->app->run();
 }
Example #5
0
 /**
  * Loads the configuration data for the component from CConfig.json file
  *
  * @param int $pre A optional prefix for the Setting table.
  *
  * @return an component object, which represents the configuration
  */
 public function loadConfig($pre = '')
 {
     // initialize component
     $this->_conf = $this->_conf->loadConfig($pre);
     $this->query = array(CConfig::getLink($this->_conf->getLinks(), 'out'));
 }
Example #6
0
 /**
  * Loads the configuration data for the component from CConfig.json file
  *
  * @param int $preChoice A optional prefix for the Choice table.
  * @param int $preForm A optional prefix for the Form table.
  * @param int $preExercise A optional prefix for the Exercise table.
  *
  * @return an component object, which represents the configuration
  */
 public function loadConfig($preChoice = '', $preForm = '', $preExercise = '')
 {
     // initialize component
     $this->_conf = $this->_conf->loadConfig($preChoice, $preForm, $preExercise);
     $this->query = array(CConfig::getLink($this->_conf->getLinks(), 'out'));
 }
Example #7
-1
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(LFile::$_baseDir, dirname(__FILE__));
     // runs the LFile
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     $this->_conf = $conf;
     $this->_fs = CConfig::getLinks($this->_conf->getLinks(), 'file');
     $this->_db = CConfig::getLinks($this->_conf->getLinks(), 'fileDb');
     $this->_app = new \Slim\Slim(array('debug' => true));
     $this->_app->response->setStatus(404);
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST File
     $this->_app->post('/' . LFile::$_baseDir . '(/)', array($this, 'postFile'));
     /*// POST PathFile
       $this->_app->post( 
                         '/' . LFile::$_baseDir . '/:path(/)',
                         array( 
                               $this,
                               'postPathFile'
                               )
                         );*/
     // DELETE File
     $this->_app->delete('/' . LFile::$_baseDir . '/:fileid', array($this, 'deleteFile'));
     // run Slim
     $this->_app->run();
 }