Exemplo n.º 1
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(LCourse::getPrefix(), dirname(__FILE__));
     // runs the LCourse
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize slim
     $this->app = new \Slim\Slim(array('debug' => true));
     $this->app->response->headers->set('Content-Type', 'application/json');
     // initialize component
     $this->_conf = $conf;
     $this->query = CConfig::getLink($conf->getLinks(), "controller");
     $this->_deleteCourse = CConfig::getLinks($conf->getLinks(), "deleteCourse");
     $this->_postCourse = CConfig::getLinks($conf->getLinks(), "postCourse");
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     //POST AddCourse
     $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'AddCourse'));
     //PUT EditCourse
     $this->app->put('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'editCourse'));
     //DELETE DeleteCourse
     $this->app->delete('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'deleteCourse'));
     //POST AddCourseMember
     $this->app->post('/' . $this->getPrefix() . '/course/:courseid/user/:userid/status/:status(/)', array($this, 'addCourseMember'));
     //GET GetCourseMember
     $this->app->get('/' . $this->getPrefix() . '/course/:courseid/user(/)', array($this, 'getCourseMember'));
     //GET GetCourses
     $this->app->get('/' . $this->getPrefix() . '/user/:userid(/)', array($this, 'getCourses'));
     //run Slim
     $this->app->run();
 }
Exemplo n.º 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(LAttachment::getPrefix(), dirname(__FILE__));
     // runs the LAttachment
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize slim
     $this->app = new \Slim\Slim();
     $this->app->response->setStatus(409);
     $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($conf->getLinks(), "postFile");
     $this->_postAttachment = CConfig::getLinks($conf->getLinks(), "postAttachment");
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     //POST AddAttachment
     $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment'));
     //GET GetAttachment
     $this->app->get('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'getAttachment'));
     //DELETE DeleteAttachment
     $this->app->delete('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'deleteAttachment'));
     //PUT EditAttachment
     $this->app->put('/' . $this->getPrefix() . '/attachment/:attachmentid(/)', array($this, 'editAttachment'));
     //run Slim
     $this->app->run();
 }
Exemplo n.º 3
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(DBAttachment::getPrefix(), dirname(__FILE__));
     // runs the DBAttachment
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize component
     $this->_conf = $conf;
     $this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
     $this->query2 = array(CConfig::getLink($conf->getLinks(), 'out2'));
     // initialize slim
     $this->_app = new \Slim\Slim();
     $this->_app->response->setStatus(409);
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // 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'));
     // PUT EditAttachment
     $this->_app->put('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
     // DELETE DeleteAttachment
     $this->_app->delete('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
     // DELETE DeleteExerciseAttachments
     $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'deleteExerciseAttachment'));
     // DELETE DeleteExerciseFileAttachment
     $this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid/file/:fileid(/)', array($this, 'deleteExerciseFileAttachment'));
     // POST AddAttachment
     $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment'));
     // GET GetAttachment
     $this->_app->get('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
     // GET GetAllAttachments
     $this->_app->get('/' . $this->getPrefix() . '(/attachment)(/)', array($this, 'getAllAttachments'));
     // GET GetExerciseAttachments
     $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
     // GET GetSheetAttachments
     $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
     // run Slim
     $this->_app->run();
 }
Exemplo n.º 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();
 }
Exemplo n.º 5
0
 /**
  * REST actions
  *
  * This function contains the REST actions with the assignments to
  * the functions.
  */
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(DBForm::getPrefix() . ',course,link', dirname(__FILE__));
     // runs the DBForm
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // initialize component
     $this->_conf = $conf;
     $this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
     // initialize slim
     $this->_app = new \Slim\Slim();
     $this->_app->response->headers->set('Content-Type', 'application/json');
     // POST AddCourse
     $this->_app->post('/course(/)', array($this, 'addCourse'));
     // POST DeleteCourse
     $this->_app->delete('/course/:courseid(/)', array($this, 'deleteCourse'));
     // PUT EditForm
     $this->_app->put('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'editForm'));
     // DELETE DeleteForm
     $this->_app->delete('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'deleteForm'));
     // POST AddForm
     $this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addForm'));
     // GET GetForm
     $this->_app->get('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'getForm'));
     // GET GetCourseForms
     $this->_app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseForms'));
     // GET GetExistsCourseForms
     $this->_app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourseForms'));
     // GET GetSheetForms
     $this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetForms'));
     // GET GetExerciseForms
     $this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseForms'));
     // run Slim
     $this->_app->run();
 }
Exemplo n.º 6
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(LExercise::getPrefix(), dirname(__FILE__));
     // runs the LExercise
     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->_postAttachment = CConfig::getLinks($conf->getLinks(), "postAttachment");
     // initialize lURL
     $this->lURL = $this->query->getAddress();
     // POST AddExercise
     $this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'addExercise'));
     // run Slim
     $this->app->run();
 }
Exemplo n.º 7
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'));
 }
Exemplo n.º 8
0
 /**
  * Chooses the destination for a request.
  *
  * Called always when this component receives a
  * HTTP POST, GET, PUT or DELETE
  *
  * @param array $string An array of strings that contains the URL
  * with which the controller has been called.
  */
 public function chooseDestination($string)
 {
     $method = $this->app->request->getMethod();
     $body = $this->app->request->getBody();
     $header = $this->app->request->headers->all();
     // if the prefix is "DB", send the request on the database controller
     if ($string[0] == "DB") {
         unset($string[0]);
         // set the database URL
         $URI = CConfig::getLink($this->query, "database")->getAddress();
         $this->sendNewRequest($string, $method, $URI, $header, $body);
         $this->app->stop();
     } elseif ($string[0] == "FS") {
         // if the prefix is "FS", send the request on the database controller
         unset($string[0]);
         // set the filesystem URL
         $URI = CConfig::getLink($this->query, "filesystem")->getAddress();
         $this->sendNewRequest($string, $method, $URI, $header, $body);
         $this->app->stop();
     } else {
         // if the prefix is another one, send the request on the corresponding logic component
         $arrayOfLinks = $this->query;
         // search for the correct component URL and set it
         foreach ($arrayOfLinks as $linkObj) {
             if ($linkObj->getPrefix() == $string[0]) {
                 $URI = $linkObj->getAddress();
                 $this->sendNewRequest($string, $method, $URI, $header, $body);
                 $this->app->stop();
             }
         }
         $this->app->response->setStatus(412);
         $this->app->response->stop();
     }
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
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'));
 }
Exemplo n.º 11
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();
 }
Exemplo n.º 12
0
 public function __construct()
 {
     // runs the CConfig
     $com = new CConfig(LGetSite::getPrefix(), dirname(__FILE__));
     // runs the LGetSite
     if ($com->used()) {
         return;
     }
     $conf = $com->loadConfig();
     // Initialize Slim
     $this->app = new \Slim\Slim();
     $this->app->response->headers->set('Content-Type', 'application/json');
     // Set the logic controller URL
     $this->_conf = $conf;
     $this->query = CConfig::getLink($conf->getLinks(), "controller");
     $this->_getUser = CConfig::getLink($conf->getLinks(), "getUser");
     $this->_getExercise = CConfig::getLink($conf->getLinks(), "getExercise");
     $this->_getExerciseType = CConfig::getLink($conf->getLinks(), "getExerciseType");
     $this->_getExerciseFileType = CConfig::getLink($conf->getLinks(), "getExerciseFileType");
     $this->_getApprovalCondition = CConfig::getLink($conf->getLinks(), "getApprovalCondition");
     $this->_getMarking = CConfig::getLink($conf->getLinks(), "getMarking");
     $this->_getSelectedSubmission = CConfig::getLink($conf->getLinks(), "getSelectedSubmission");
     $this->_getGroup = CConfig::getLink($conf->getLinks(), "getGroup");
     $this->_getCourseStatus = CConfig::getLink($conf->getLinks(), "getCourseStatus");
     $this->_getSubmission = CConfig::getLink($conf->getLinks(), "getSubmission");
     $this->_getCourse = CConfig::getLink($conf->getLinks(), "getCourse");
     $this->_getInvitation = CConfig::getLink($conf->getLinks(), "getInvitation");
     $this->lURL = $this->query->getAddress();
     //GET TutorAssignmentSiteInfo
     $this->app->get('/tutorassign/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'tutorAssignmentSiteInfo'));
     //GET StudentSiteInfo
     $this->app->get('/student/user/:userid/course/:courseid(/)', array($this, 'studentSiteInfo'));
     //GET AccountSettings
     $this->app->get('/accountsettings/user/:userid(/course/:courseid)(/)', array($this, 'accountsettings'));
     //GET CreateSheet
     $this->app->get('/createsheet/user/:userid/course/:courseid(/)', array($this, 'createSheetInfo'));
     //GET Index
     $this->app->get('/index/user/:userid(/)', array($this, 'userWithAllCourses'));
     //GET CourseManagement
     $this->app->get('/coursemanagement/user/:userid/course/:courseid(/)', array($this, 'courseManagement'));
     //GET MainSettings
     $this->app->get('/mainsettings/user/:userid', array($this, 'mainSettings'));
     //GET Upload
     $this->app->get('/upload/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'upload'));
     //GET TutorUpload
     $this->app->get('/tutorupload/user/:userid/course/:courseid(/)', array($this, 'tutorUpload'));
     //GET MarkingTool
     $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'markingTool'));
     //GET MarkingTool
     $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/tutor/:tutorid', array($this, 'markingToolTutor'));
     //GET MarkingTool
     $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/status/:statusid', array($this, 'markingToolStatus'));
     //GET MarkingTool
     $this->app->get('/markingtool/user/:userid/course/:courseid/exercisesheet/:sheetid/tutor/:tutorid/status/:statusid', array($this, 'markingToolTutorStatus'));
     //GET UploadHistory
     $this->app->get('/uploadhistory/user/:userid/course/:courseid/exercisesheet/:sheetid/uploaduser/:uploaduserid(/)', array($this, 'uploadHistory'));
     //GET UploadHistoryOptions
     $this->app->get('/uploadhistoryoptions/user/:userid/course/:courseid(/)', array($this, 'uploadHistoryOptions'));
     //GET TutorSite
     $this->app->get('/tutor/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin'));
     //GET AdminSite
     $this->app->get('/admin/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin'));
     //GET DozentSite
     $this->app->get('/lecturer/user/:userid/course/:courseid(/)', array($this, 'tutorDozentAdmin'));
     //GET GroupSite
     $this->app->get('/group/user/:userid/course/:courseid/exercisesheet/:sheetid(/)', array($this, 'groupSite'));
     //GET Condition
     $this->app->get('/condition/user/:userid/course/:courseid(/)', array($this, 'checkCondition'));
     //run Slim
     $this->app->run();
 }