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


PHP Exercise::decodeExercise方法代码示例

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


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

示例1: addExercise

 /**
  * Adds an exercise.
  *
  * Called when this component receives an HTTP POST request to
  * /exercise(/).
  * The request body should contain a JSON object representing an array of exercises
  */
 public function addExercise()
 {
     $header = $this->app->request->headers->all();
     $body = json_decode($this->app->request->getBody(), true);
     $allright = true;
     $result = array();
     if (isset($body) == true && empty($body) == false) {
         foreach ($body as $subexercise) {
             // create exercise in DB
             $FileTypesArrayTemp = null;
             if (isset($subexercise['fileTypes'])) {
                 $FileTypesArrayTemp = $subexercise['fileTypes'];
                 unset($subexercise['fileTypes']);
             }
             $subexerciseJSON = json_encode($subexercise);
             $URL = $this->lURL . '/DB/exercise';
             $method = 'POST';
             if (isset($subexercise['id']) && $subexercise['id'] !== null) {
                 $method = 'PUT';
                 $URL = $this->lURL . '/DB/exercise/' . $subexercise['id'];
             }
             $subexerciseAnswer = Request::custom($method, $URL, $header, $subexerciseJSON);
             if ($subexerciseAnswer['status'] == 201) {
                 $subexerciseOutput = json_decode($subexerciseAnswer['content'], true);
                 if (isset($subexercise['id'])) {
                     $result[] = $subexercise;
                     $subexerciseOutput = $subexercise;
                 } else {
                     $result[] = Exercise::decodeExercise($subexerciseAnswer['content']);
                 }
                 if (isset($subexerciseOutput['id'])) {
                     $linkid = $subexerciseOutput['id'];
                 }
                 // create attachement in DB and FS
                 if (isset($subexercise['attachments']) && !empty($subexercise['attachments'])) {
                     foreach ($subexercise['attachments'] as &$attachment) {
                         $attachment['exerciseId'] = $linkid;
                     }
                     $attachments = $subexercise['attachments'];
                     $tempAttachments = array();
                     foreach ($attachments as $attachment) {
                         $temp = Attachment::createAttachment(null, $attachment['exerciseId'], null, null);
                         $temp->setFile($attachment);
                         $tempAttachments[] = $temp;
                     }
                     $res = Request::routeRequest('POST', '/attachment', $header, Attachment::encodeAttachment($tempAttachments), $this->_postAttachment, 'attachment');
                     // checks the correctness of the query
                     if ($res['status'] >= 200 && $res['status'] <= 299) {
                         // ...
                     } else {
                         $allright = false;
                         break;
                     }
                 }
                 // create ExerciseFileTypes
                 if (isset($FileTypesArrayTemp) && !empty($FileTypesArrayTemp)) {
                     foreach ($FileTypesArrayTemp as $fileType) {
                         $myExerciseFileType = ExerciseFileType::createExerciseFileType(NULL, $fileType['text'], $linkid);
                         $myExerciseFileTypeJSON = ExerciseFileType::encodeExerciseFileType($myExerciseFileType);
                         $URL = $this->lURL . "/DB/exercisefiletype";
                         $FileTypesAnswer = Request::custom('POST', $URL, $header, $myExerciseFileTypeJSON);
                         if ($FileTypesAnswer['status'] != 201) {
                             $allright = false;
                             break;
                         }
                     }
                 }
                 if ($allright == false) {
                     break;
                 }
             } else {
                 $allright = false;
                 break;
             }
         }
     }
     if ($allright == true) {
         $this->app->response->setBody(Exercise::encodeExercise($result));
         $this->app->response->setStatus(201);
     } else {
         $this->app->response->setStatus(409);
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:90,代码来源:LExercise.php

示例2: __construct

 /**
  * the constructor
  *
  * @param $data an assoc array with the object informations
  */
 public function __construct($data = array())
 {
     if ($data === null) {
         $data = array();
     }
     foreach ($data as $key => $value) {
         if (isset($key)) {
             if ($key == 'exercises') {
                 $this->{$key} = Exercise::decodeExercise($value, false);
             } elseif ($key == 'sheetFile' || $key == 'sampleSolution') {
                 $this->{$key} = File::decodeFile($value, false);
             } else {
                 $func = 'set' . strtoupper($key[0]) . substr($key, 1);
                 $methodVariable = array($this, $func);
                 if (is_callable($methodVariable)) {
                     $this->{$func}($value);
                 } else {
                     $this->{$key} = $value;
                 }
             }
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:28,代码来源:ExerciseSheet.php

示例3: __construct

 /**
  * the constructor
  *
  * @param $data an assoc array with the object informations
  */
 public function __construct($data = array())
 {
     if ($data === null) {
         $data = array();
     }
     foreach ($data as $key => $value) {
         if (isset($key)) {
             if ($key == 'attachment') {
                 $this->{$key} = Attachment::decodeAttachment($value, false);
             } else {
                 if ($key == 'workFiles') {
                     $this->{$key} = Attachment::decodeAttachment($value, false);
                 } else {
                     if ($key == 'target') {
                         $this->{$key} = Component::decodeComponent($value, false);
                     } else {
                         if ($key == 'submission') {
                             $this->{$key} = Submission::decodeSubmission($value, false);
                         } else {
                             if ($key == 'rawSubmission') {
                                 $this->{$key} = Submission::decodeSubmission($value, false);
                             } else {
                                 if ($key == 'marking') {
                                     $this->{$key} = Marking::decodeMarking($value, false);
                                 } else {
                                     if ($key == 'exercise') {
                                         $this->{$key} = Exercise::decodeExercise($value, false);
                                     } else {
                                         $func = 'set' . strtoupper($key[0]) . substr($key, 1);
                                         $methodVariable = array($this, $func);
                                         if (is_callable($methodVariable)) {
                                             $this->{$func}($value);
                                         } else {
                                             $this->{$key} = $value;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:50,代码来源:Process.php

示例4: http_delete

 $URL = $databaseURI . "/exercisefiletype/exercisesheet/{$sheetId}";
 $removed = http_delete($URL, true);
 $exerciseMap = array();
 foreach ($exercises as $key => &$exercise) {
     $exercise->setSheetId($sheetId);
     $exerciseMap[$key] = array($key, $exercise->getId());
     if ($exercise->getId() < 0) {
         $exercise->setId(null);
     }
 }
 // Post Excercise to logic Controller to create it
 $exercisesJSON = Exercise::encodeExercise($exercises);
 ///echo $exercisesJSON;
 $output2 = http_post_data($logicURI . "/exercise", $exercisesJSON, true, $message);
 if ($message == 201) {
     $exercises2 = Exercise::decodeExercise($output2);
     foreach ($exercises2 as $key => &$exercise2) {
         if ($exercises[$key]->getId() !== null) {
             $exerciseMap[$key][] = $exercises[$key]->getId();
         } else {
             $exerciseMap[$key][] = $exercise2->getId();
         }
         if ($exercise2->getId() !== null) {
             $exercises[$key]->setId($exercise2->getId());
         }
     }
     #region create_forms
     ##########################
     ### begin create_forms ###
     ##########################
     if ($errorInSent == false) {
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:CreateSheet.php

示例5: ExtractExercise

 public static function ExtractExercise($data, $singleResult = false, $ExerciseExtension = '', $AttachmentExtension = '', $SubmissionExtension = '', $FileTypeExtension = '', $isResult = true)
 {
     // generates an assoc array of an exercise by using a defined
     // list of its attributes
     $exercise = DBJson::getObjectsByAttributes($data, Exercise::getDBPrimaryKey(), Exercise::getDBConvert(), $ExerciseExtension);
     // generates an assoc array of files by using a defined
     // list of its attributes
     $attachments = DBJson::getObjectsByAttributes($data, File::getDBPrimaryKey(), File::getDBConvert(), $AttachmentExtension);
     // generates an assoc array of submissions by using a defined
     // list of its attributes
     $submissions = DBJson::getObjectsByAttributes($data, Submission::getDBPrimaryKey(), Submission::getDBConvert(), $SubmissionExtension . '2');
     // generates an assoc array of exercise file types by using a defined
     // list of its attributes
     $fileTypes = DBJson::getObjectsByAttributes($data, ExerciseFileType::getDBPrimaryKey(), ExerciseFileType::getDBConvert(), $FileTypeExtension);
     // sets the selectedForGroup attribute
     foreach ($submissions as &$submission) {
         if (isset($submission['selectedForGroup'])) {
             if (isset($submission['id']) && $submission['id'] == $submission['selectedForGroup']) {
                 $submission['selectedForGroup'] = (string) 1;
             } else {
                 unset($submission['selectedForGroup']);
             }
         }
     }
     // concatenates the exercise and the associated filetypes
     $exercise = DBJson::concatObjectListResult($data, $exercise, Exercise::getDBPrimaryKey(), Exercise::getDBConvert()['E_fileTypes'], $fileTypes, ExerciseFileType::getDBPrimaryKey(), $FileTypeExtension, $ExerciseExtension);
     // concatenates the exercise and the associated attachments
     $res = DBJson::concatObjectListResult($data, $exercise, Exercise::getDBPrimaryKey(), Exercise::getDBConvert()['E_attachments'], $attachments, File::getDBPrimaryKey(), $AttachmentExtension, $ExerciseExtension);
     // concatenates the exercise and the associated submissions
     $res = DBJson::concatObjectLists($data, $res, Exercise::getDBPrimaryKey(), Exercise::getDBConvert()['E_submissions'], $submissions, Submission::getDBPrimaryKey(), $SubmissionExtension . '2', $ExerciseExtension);
     if ($isResult) {
         // to reindex
         $res = array_values($res);
         $res = Exercise::decodeExercise($res, false);
         if ($singleResult) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:43,代码来源:Exercise.php


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