当前位置: 首页>>代码示例>>PHP>>正文


PHP Exercise::setCourseId方法代码示例

本文整理汇总了PHP中Exercise::setCourseId方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::setCourseId方法的具体用法?PHP Exercise::setCourseId怎么用?PHP Exercise::setCourseId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exercise的用法示例。


在下文中一共展示了Exercise::setCourseId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addCourse

 /**
  * Adds the component to a course
  *
  * Called when this component receives an HTTP POST request to
  * /course(/).
  */
 public function addCourse()
 {
     Logger::Log('starts POST AddCourse', LogLevel::DEBUG);
     $header = $this->app->request->headers->all();
     $body = $this->app->request->getBody();
     $courses = Course::decodeCourse($body);
     $processes = array();
     if (!is_array($courses)) {
         $courses = array($courses);
     }
     foreach ($courses as $course) {
         $process = new Process();
         $exercise = new Exercise();
         $exercise->setCourseId($course->getId());
         $process->setExercise($exercise);
         $component = new Component();
         $component->setId($this->_conf->getId());
         $process->setTarget($component);
         $processes[] = $process;
     }
     foreach ($this->_postProcess as $_link) {
         $result = Request::routeRequest('POST', '/process', $header, Process::encodeProcess($processes), $_link, 'process');
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $this->app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             /* if ($courses->getId()!==null){
                    $this->deleteCourse($courses->getId());
                }*/
             Logger::Log('POST AddCourse failed', LogLevel::ERROR);
             $this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->app->response->setBody(Course::encodeCourse($courses));
             $this->app->stop();
         }
     }
     $this->app->response->setBody(Course::encodeCourse($courses));
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:46,代码来源:LFormProcessor.php

示例2: addCourse

 /**
  * Adds the component to a course
  *
  * Called when this component receives an HTTP POST request to
  * /course(/).
  */
 public function addCourse()
 {
     Logger::Log('starts POST AddCourse', LogLevel::DEBUG);
     $body = $this->app->request->getBody();
     // die Daten der Veranstaltung kommen über den Aufrufkörper rein
     $courses = Course::decodeCourse($body);
     $processes = array();
     if (!is_array($courses)) {
         $courses = array($courses);
     }
     // wenn die Komponente direkt in mehrere Veranstaltungen eingetragen werden soll,
     // wird das Eintragen für alle vorgenommen
     foreach ($courses as $course) {
         // ab hier wird der neue Eintrag zusammengestellt
         $process = new Process();
         $exercise = new Exercise();
         $exercise->setCourseId($course->getId());
         $process->setExercise($exercise);
         $component = new Component();
         $component->setId($this->_conf->getId());
         $process->setTarget($component);
         // und nun wird gesammelt
         $processes[] = $process;
     }
     // die erstellten Einträge können nun an den Zuständigen geschickt werden
     foreach ($this->_postProcess as $_link) {
         $result = Request::routeRequest('POST', '/process', array(), Process::encodeProcess($processes), $_link, 'process');
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             // wenn der Erstellvorgang erfolgreich war, können wir dies melden
             $this->app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             // der Eintrag konnte nicht erstellt werden
             /* if ($courses->getId()!==null){
                    $this->deleteCourse($courses->getId());
                }*/
             Logger::Log('POST AddCourse failed', LogLevel::ERROR);
             // gibt den Status der "Erstellanfrage" zurück oder eine 409 und zusätzlich
             // das eingehende Veranstaltungsobjekt
             $this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->app->response->setBody(Course::encodeCourse($courses));
             $this->app->stop();
         }
     }
     // die bearbeiteten Veranstaltungen können nun zur Ausgabe hinzugefügt werden
     $this->app->response->setBody(Course::encodeCourse($courses));
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:56,代码来源:LOOP.php


注:本文中的Exercise::setCourseId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。