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


PHP Submission::encodeSubmission方法代码示例

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


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

示例1: addSubmission

 /**
  * Adds a user's submission to the database and filesystem
  *
  * Called then this component receives an HTTP POST request to
  * /submission(/)
  * The request body should contain a JSON object representing a submission.
  *
  * @author Till Uhlig
  * @date 2014
  */
 public function addSubmission()
 {
     $body = $this->app->request->getBody();
     $submission = Submission::decodeSubmission($body);
     $file = $submission->getFile();
     if (!isset($file) || $file == array()) {
         $file = new File();
     }
     if ($file->getTimeStamp() === null) {
         $file->setTimeStamp(time());
     }
     ///echo File::encodeFile($file);return;
     // upload file to filesystem
     $result = Request::routeRequest('POST', '/file', array(), File::encodeFile($file), $this->_file, 'file');
     ///var_dump($result);
     ///echo $result['content'];return;
     if ($result['status'] >= 200 && $result['status'] <= 299) {
         // file is uploaded
         $newFile = File::decodeFile($result['content']);
         $file->setAddress($newFile->getAddress());
         $file->setHash($newFile->getHash());
         $file->setFileId($newFile->getFileId());
         $file->setBody(null);
         $submission->setFile($file);
         // upload submission to database
         if ($submission->getId() === null) {
             //echo Submission::encodeSubmission($submission);return;
             $result = Request::routeRequest('POST', '/submission', array(), Submission::encodeSubmission($submission), $this->_submission, 'submission');
         } else {
             $result['status'] = 201;
             $result['content'] = Submission::encodeSubmission($submission);
         }
         //var_dump($result);
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             // submission is uploaded
             $newsubmission = Submission::decodeSubmission($result['content']);
             $submission->setId($newsubmission->getId());
             // select new submission
             if ($submission->getSelectedForGroup() == '1') {
                 $selectedSubmission = SelectedSubmission::createSelectedSubmission($submission->getLeaderId(), $submission->getId(), $submission->getExerciseId());
                 $result = Request::routeRequest('POST', '/selectedsubmission', array(), SelectedSubmission::encodeSelectedSubmission($selectedSubmission), $this->_selectedSubmission, 'selectedsubmission');
                 if ($result['status'] >= 200 && $result['status'] <= 299) {
                     $this->app->response->setBody(Submission::encodeSubmission($submission));
                     $this->app->response->setStatus(201);
                     $this->app->stop();
                 } else {
                     $result = Request::routeRequest('PUT', '/selectedsubmission/leader/' . $submission->getLeaderId() . '/exercise/' . $submission->getExerciseId(), $this->app->request->headers->all(), SelectedSubmission::encodeSelectedSubmission($selectedSubmission), $this->_selectedSubmission, 'selectedsubmission');
                     if ($result['status'] >= 200 && $result['status'] <= 299) {
                         $this->app->response->setBody(Submission::encodeSubmission($submission));
                         $this->app->response->setStatus(201);
                         $this->app->stop();
                     }
                 }
             } else {
                 $this->app->response->setBody(Submission::encodeSubmission($submission));
                 $this->app->response->setStatus(201);
                 $this->app->stop();
             }
         }
     }
     Logger::Log('POST AddSubmission failed', LogLevel::ERROR);
     $this->app->response->setBody(Submission::encodeSubmission(new Submission()));
     $this->app->response->setStatus(409);
     $this->app->stop();
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:75,代码来源:LSubmission.php

示例2: postSubmission


//.........这里部分代码省略.........
                 $component = $pro->getTarget();
                 if ($process->getExercise() === null) {
                     $process->setExercise($pro->getExercise());
                 }
                 $process->setParameter($pro->getParameter());
                 $process->setAttachment($pro->getAttachment());
                 $process->setTarget($pro->getTarget());
                 $process->setWorkFiles($pro->getWorkFiles());
                 //echo Process::encodeProcess($process)."_______";// return;
                 $result = Request::post($component->getAddress() . '/process', array(), Process::encodeProcess($process));
                 //echo $result['content'].'_______';
                 if ($result['status'] >= 200 && $result['status'] <= 299) {
                     $process = Process::decodeProcess($result['content']);
                 } else {
                     $fail = true;
                     $submission->addMessage("Beim Verarbeiten der Einsendung ist ein Fehler aufgetreten");
                     if (isset($result['content'])) {
                         $content = Process::decodeProcess($result['content']);
                         $submission->setStatus($content->getStatus());
                         $submission->addMessages($content->getMessages());
                     }
                     break;
                 }
             }
         }
         if ($fail) {
             if (isset($submission)) {
                 $submission->setFile(null);
             }
             $res[] = $submission;
             $this->app->response->setStatus(409);
             continue;
         }
         // upload submission
         $uploadSubmission = $process->getSubmission();
         if ($uploadSubmission === null) {
             $uploadSubmission = $process->getRawSubmission();
             if ($uploadSubmission->getFile() != null) {
                 $file = $uploadSubmission->getFile();
                 if ($file->getDisplayName() == null) {
                     $file->setDisplayName($submission->getExerciseName());
                 }
             }
         }
         if ($uploadSubmission !== null) {
             ///echo Submission::encodeSubmission($uploadSubmission);return;
             $result = Request::routeRequest('POST', '/submission', array(), Submission::encodeSubmission($uploadSubmission), $this->_submission, 'submission');
             //var_dump($result);return;
             // checks the correctness of the query
             if ($result['status'] >= 200 && $result['status'] <= 299) {
                 $queryResult = Submission::decodeSubmission($result['content']);
                 $uploadSubmission->setId($queryResult->getId());
                 $uploadSubmission->setFile($queryResult->getFile());
                 if ($process->getMarking() !== null) {
                     $process->getMarking()->setSubmission($queryResult);
                 }
             } else {
                 $uploadSubmission->addMessage("Beim Speichern der Einsendung ist ein Fehler aufgetreten.");
                 //var_dump($uploadSubmission); return;
                 if (isset($result['content'])) {
                     $content = Submission::decodeSubmission($result['content']);
                     $uploadSubmission->setStatus($content->getStatus());
                     $uploadSubmission->addMessages($content->getMessages());
                 }
                 $uploadSubmission->setStatus(409);
                 $res[] = $uploadSubmission;
                 $this->app->response->setStatus(409);
                 continue;
             }
         }
         // upload marking
         if ($process->getMarking() !== null) {
             //echo Marking::encodeMarking($process->getMarking());
             $result = Request::routeRequest('POST', '/marking', array(), Marking::encodeMarking($process->getMarking()), $this->_marking, 'marking');
             // checks the correctness of the query
             if ($result['status'] >= 200 && $result['status'] <= 299) {
                 $queryResult = Marking::decodeMarking($result['content']);
             } else {
                 $uploadSubmission->addMessage("Beim Speichern der Korrektur ist ein Fehler aufgetreten");
                 if (isset($result['content'])) {
                     $content = Marking::decodeMarking($result['content']);
                     $uploadSubmission->addMessages($content->getMessages());
                 }
                 $res[] = $uploadSubmission;
                 $this->app->response->setStatus(409);
                 continue;
             }
         }
         $rr = $process->getSubmission();
         if ($rr === null) {
             $rr = $process->getRawSubmission();
         }
         $res[] = $rr;
     }
     if (!$arr && count($res) == 1) {
         $this->app->response->setBody(Submission::encodeSubmission($res[0]));
     } else {
         $this->app->response->setBody(Submission::encodeSubmission($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:LProcessor.php

示例3: MakeNotification

if (isset($_POST['deleteSubmissionWarning'])) {
    $notifications[] = MakeNotification("warning", Language::Get('main', 'askDeleteSubmission', $langTemplate));
} elseif (isset($_POST['deleteSubmission'])) {
    $suid = cleanInput($_POST['deleteSubmission']);
    // extractes the studentId of the submission
    $URI = $databaseURI . "/submission/" . $suid;
    $submission = http_get($URI, true);
    $submission = json_decode($submission, true);
    // only deletes the submission if it belongs to the user
    if ($submission['studentId'] == $uid) {
        $URI = $databaseURI . "/selectedsubmission/submission/" . $suid;
        http_delete($URI, true, $message);
        // todo: treat the case if the previous operation failed
        $submissionUpdate = Submission::createSubmission($suid, null, null, null, null, null, null, 0);
        $URI = $databaseURI . "/submission/submission/" . $suid;
        http_put_data($URI, Submission::encodeSubmission($submissionUpdate), true, $message2);
        if ($message == "201" && $message2 == 201) {
            $notifications[] = MakeNotification("success", Language::Get('main', 'successDeleteSubmission', $langTemplate));
        } else {
            $notifications[] = MakeNotification("error", Language::Get('main', 'errorDeleteSubmission', $langTemplate));
        }
    }
} elseif (isset($_POST['downloadMarkings'])) {
    downloadMarkingsForSheet($uid, $_POST['downloadMarkings']);
}
// load tutor data from GetSite
$URI = $getSiteURI . "/student/user/{$uid}/course/{$cid}";
$student_data = http_get($URI, true);
$student_data = json_decode($student_data, true);
$student_data['filesystemURI'] = $filesystemURI;
$student_data['cid'] = $cid;
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:Student.php

示例4: http_post_data

     $uploadFile = File::createFile(null, $file['name'], null, $timestamp, null, null);
     $uploadFile->setBody(Reference::createReference($file['tmp_name']));
 } else {
     $uploadFile = File::createFile(null, null, null, $timestamp, null, null);
     $uploadFile->setBody(Form::encodeForm($formdata), true);
 }
 $uploadSubmission = Submission::createSubmission(null, $uid, null, $exerciseId, $exercise['comment'], 1, $timestamp, null, $leaderId);
 $uploadSubmission->setFile($uploadFile);
 $uploadSubmission->setExerciseName(isset($exercise['name']) ? $exercise['name'] : null);
 $uploadSubmission->setSelectedForGroup('1');
 if ($isExpired) {
     $uploadSubmission->setAccepted(0);
 }
 $URL = $serverURI . '/logic/LProcessor/submission';
 ///echo Submission::encodeSubmission($uploadSubmission);return;
 $result = http_post_data($URL, Submission::encodeSubmission($uploadSubmission), true, $message);
 //echo $result;
 if ($message != "201") {
     $result = Submission::decodeSubmission($result);
     $exercise = $key + 1;
     $errormsg = Language::Get('main', 'errorUploadSubmission', $langTemplate, array('status' => $message, 'exerciseName' => $exercise['name']));
     if ($result !== null && !empty($result)) {
         $errormsg .= "<br><br>";
         $messages = $result->getMessages();
         foreach ($messages as $message) {
             $errormsg .= str_replace("\n", '<br>', $message) . '<br>';
         }
     }
     $notifications[] = MakeNotification('error', $errormsg);
     continue;
 } else {
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:Upload.php

示例5: updateSubmission

function updateSubmission($submissionId, $accepted)
{
    global $databaseURI;
    $newSubmission = Submission::createSubmission(null, null, null, null, null, $accepted, null, null);
    $newSubmission = Submission::encodeSubmission($newSubmission);
    $URI = $databaseURI . "/submission/{$submissionId}";
    http_put_data($URI, $newSubmission, true, $message);
    if ($message != 201) {
        return false;
    } else {
        return true;
    }
}
开发者ID:sawh,项目名称:ostepu-system,代码行数:13,代码来源:Helpers.php


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