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


PHP Submission::decodeSubmission方法代码示例

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


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

示例1: loadSubmissionAsZip

 /**
  * Loads all selected submissions as a zip file.
  *
  * Called when this component receives an HTTP GET request to
  * /submissions/exercisesheet/$sheetid/user/$userid.
  *
  * @param int $sheetid The id of the sheet of which the submissions should
  * be zipped.
  * @param int $userid The id of the user whose submissions should be zipped.
  *
  * @author Till Uhlig
  * @date 2014
  */
 public function loadSubmissionAsZip($sheetid, $userid)
 {
     $result = Request::routeRequest('GET', '/submission/group/user/' . $userid . '/exercisesheet/' . $sheetid . '/selected', $this->app->request->headers->all(), '', $this->_submission, 'submission');
     if ($result['status'] >= 200 && $result['status'] <= 299) {
         $submissions = Submission::decodeSubmission($result['content']);
         $files = array();
         foreach ($submissions as $submission) {
             $file = $submission->getFile();
             $file->setDisplayName($file->getDisplayName());
             $files[] = $file;
         }
         $result = Request::routeRequest('POST', '/zip/' . $sheetid . '.zip', $this->app->request->headers->all(), File::encodeFile($files), $this->_zip, 'zip');
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $this->app->response->setBody($result['content']);
             $this->app->response->setStatus(200);
             if (isset($result['headers']['Content-Type'])) {
                 $this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
             if (isset($result['headers']['Content-Disposition'])) {
                 $this->app->response->headers->set('Content-Disposition', $result['headers']['Content-Disposition']);
             }
             $this->app->stop();
         }
     }
     $this->app->response->setBody('');
     $this->app->response->setStatus(404);
     $this->app->stop();
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:41,代码来源:LSubmission.php

示例2: set_time_limit

 set_time_limit(180);
 $URI = $databaseURI . "/group/exercisesheet/{$sid}";
 $groups = http_get($URI, true, $message);
 $groups = Group::decodeGroup($groups);
 if ($message == "200") {
     $URI = $databaseURI . "/exercisesheet/{$sid}/exercise";
     $exerciseSheet = http_get($URI, true, $message);
     $exerciseSheet = ExerciseSheet::decodeExerciseSheet($exerciseSheet);
     if ($message == "200") {
         $exercises = array();
         foreach ($exerciseSheet->getExercises() as $exercise) {
             $exercises[] = $exercise->getId();
         }
         $URI = $databaseURI . "/submission/exercisesheet/{$sid}/selected";
         $submissions = http_get($URI, true, $message);
         $submissions = Submission::decodeSubmission($submissions);
         if ($message == "200") {
             $users = array();
             foreach ($exercises as $exercise) {
                 $users[$exercise] = array();
                 foreach ($groups as $group) {
                     $users[$exercise][] = $group->getLeader()->getId();
                 }
             }
             unset($groups);
             $submitted = array();
             foreach ($exercises as $exercise) {
                 $submitted[$exercise] = array();
             }
             foreach ($submissions as $submission) {
                 $submitted[$submission->getExerciseId()][] = $submission->getLeaderId();
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:AssignMake.php

示例3: ExtractSubmission

 public static function ExtractSubmission($data, $singleResult = false, $FileExtension = '', $SubmissionExtension = '', $isResult = true)
 {
     // generates an assoc array of files by using a defined list of
     // its attributes
     $files = DBJson::getObjectsByAttributes($data, File::getDBPrimaryKey(), File::getDBConvert(), $FileExtension);
     // generates an assoc array of submissions by using a defined list of
     // its attributes
     $submissions = DBJson::getObjectsByAttributes($data, Submission::getDBPrimaryKey(), Submission::getDBConvert(), $SubmissionExtension);
     // 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 submissions and the associated files
     $res = DBJson::concatObjectListsSingleResult($data, $submissions, Submission::getDBPrimaryKey(), Submission::getDBConvert()['S_file'], $files, File::getDBPrimaryKey(), $FileExtension, $SubmissionExtension);
     if ($isResult) {
         // to reindex
         $res = array_values($res);
         $res = Submission::decodeSubmission($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:33,代码来源:Submission.php

示例4: array

 //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 {
     $result = Submission::decodeSubmission($result);
     // if using forms, upload user input
     if (isset($exercise['choices'])) {
         $i = 0;
         foreach ($formdata as &$form) {
             $choices = $form->getChoices();
             foreach ($choices as &$choice) {
                 $choice->setSubmissionId($result->getId());
             }
             $URL = $serverURI . '/DB/DBChoice/formResult/choice';
             $result2 = http_post_data($URL, Choice::encodeChoice($choices), true, $message);
             if ($message != "201") {
                 $result2 = Choice::decodeChoice($result2);
                 $exercise = $key + 1;
                 $errormsg = Language::Get('main', 'errorUploadSubmission', $langTemplate, array('status' => $message, 'exerciseName' => $exercise['name']));
                 if ($result2 !== null) {
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:Upload.php

示例5: postSubmission

 /**
  * Processes a submissions
  *
  * Called when this component receives an HTTP POST request to
  * /submission(/).
  */
 public function postSubmission()
 {
     $this->app->response->setStatus(201);
     $body = $this->app->request->getBody();
     $submissions = Submission::decodeSubmission($body);
     // always been an array
     $arr = true;
     if (!is_array($submissions)) {
         $submissions = array($submissions);
         $arr = false;
     }
     $res = array();
     foreach ($submissions as $submission) {
         $fail = false;
         $process = new Process();
         $process->setRawSubmission($submission);
         $eid = $submission->getExerciseId();
         // load processor data from database
         $result = Request::routeRequest('GET', '/process/exercise/' . $eid, array(), '', $this->_processorDb, 'process');
         $processors = null;
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $processors = Process::decodeProcess($result['content']);
         } else {
             if ($result['status'] != 404) {
                 $submission->addMessage("Interner Fehler");
                 $res[] = $submission;
                 $this->app->response->setStatus(409);
                 continue;
             }
         }
         $result2 = Request::routeRequest('GET', '/exercisefiletype/exercise/' . $eid, array(), '', $this->_getExerciseExerciseFileType, 'exercisefiletype');
         $exerciseFileTypes = null;
         if ($result2['status'] >= 200 && $result2['status'] <= 299) {
             $exerciseFileTypes = ExerciseFileType::decodeExerciseFileType($result2['content']);
             if (!is_array($exerciseFileTypes)) {
                 $exerciseFileTypes = array($exerciseFileTypes);
             }
             $filePath = null;
             if ($submission->getFile() != null) {
                 $file = $submission->getFile()->getBody(true);
                 if ($file !== null) {
                     $fileHash = sha1($file);
                     $filePath = '/tmp/' . $fileHash;
                     if ($submission->getFile()->getDisplayName() != null) {
                         LProcessor::generatepath($filePath);
                         file_put_contents($filePath . '/' . $submission->getFile()->getDisplayName(), $file);
                         $filePath .= '/' . $submission->getFile()->getDisplayName();
                     } else {
                         LProcessor::generatepath($filePath);
                         file_put_contents($filePath . '/tmp', $file);
                         $filePath .= '/tmp';
                     }
                 }
             }
             // check file type
             if ($filePath != null) {
                 $found = false;
                 $types = array();
                 $mimeType = MimeReader::get_mime($filePath);
                 $foundExtension = isset(pathinfo($filePath)['extension']) ? pathinfo($filePath)['extension'] : '-';
                 foreach ($exerciseFileTypes as $type) {
                     $types[] = $type->getText();
                     $type = explode(' ', str_replace('*', '', $type->getText()));
                     //echo MimeReader::get_mime($filePath);
                     if (strpos($mimeType, $type[0]) !== false && (!isset($type[1]) || '.' . $foundExtension == $type[1])) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found && count($exerciseFileTypes) > 0) {
                     $submission->addMessage("falscher Dateityp \nGefunden: " . $mimeType . " ." . $foundExtension . "\nErlaubt: " . implode(',', $types));
                     $res[] = $submission;
                     $this->app->response->setStatus(409);
                     unlink($filePath);
                     continue;
                 }
                 unlink($filePath);
             }
         } else {
             if ($result2['status'] != 404) {
                 $submission->addMessage("Interner Fehler");
                 $res[] = $submission;
                 $this->app->response->setStatus(409);
                 continue;
             }
         }
         // process submission
         if ($processors !== null) {
             if (!is_array($processors)) {
                 $processors = array($processors);
             }
             foreach ($processors as $pro) {
                 $component = $pro->getTarget();
                 if ($process->getExercise() === null) {
//.........这里部分代码省略.........
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:LProcessor.php

示例6:

             }
             if (!isset($exercise['submission']) && (isset($statusID) && $statusID != 0 || isset($tutorID) && $tutorID != 'all')) {
                 continue;
             }
             if (isset($exercise['submission'])) {
                 if (isset($exercise['submission']['marking'])) {
                     // submission + marking
                     $tempMarking = Marking::decodeMarking(json_encode($exercise['submission']['marking']));
                     $tempSubmission = Submission::decodeSubmission(json_encode($exercise['submission']));
                     $tempMarking->setSubmission($tempSubmission);
                     $markings[] = $tempMarking;
                 } else {
                     // no marking
                     $tempMarking = Marking::createMarking($newMarkings, $uid, null, $exercise['submission']['id'], null, null, 1, null, $timestamp, null);
                     $newMarkings--;
                     $tempSubmission = Submission::decodeSubmission(json_encode($exercise['submission']));
                     $tempMarking->setSubmission($tempSubmission);
                     $markings[] = $tempMarking;
                 }
             } else {
                 // no submission
                 $tempMarking = Marking::createMarking($newMarkings, $uid, null, null, null, null, 1, null, $timestamp, null);
                 $tempSubmission = Submission::createSubmission($newMarkings, $group['leader']['id'], null, $exercise['id'], null, null, $timestamp, null, $group['leader']['id'], null);
                 $tempSubmission->setSelectedForGroup(1);
                 $newMarkings--;
                 $tempMarking->setSubmission($tempSubmission);
                 $markings[] = $tempMarking;
             }
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:MarkingTool.php

示例7: set_time_limit

<?php

if (isset($_POST['action']) && isset($_POST['action']) && $_POST['action'] == "AssignManually") {
    set_time_limit(180);
    // automatically assigns all unassigned proposed submissions to tutors
    if (isset($_POST['actionAssignAllProposals'])) {
        // load user data from the database
        $URL = $getSiteURI . "/tutorassign/user/{$uid}/course/{$cid}/exercisesheet/{$sid}";
        $tutorAssign_data = http_get($URL, true);
        $tutorAssign_data = json_decode($tutorAssign_data, true);
        $markings = array();
        if (!empty($tutorAssign_data['tutorAssignments'])) {
            foreach ($tutorAssign_data['tutorAssignments'] as $tutorAssignment) {
                if (isset($tutorAssignment['proposalSubmissions'])) {
                    foreach ($tutorAssignment['proposalSubmissions'] as $submission) {
                        $sub = Submission::decodeSubmission(json_encode($submission));
                        $marking = new Marking();
                        $marking->setSubmission($sub);
                        $marking->setStatus(1);
                        $marking->setTutorId($tutorAssignment['tutor']['id']);
                        $markings[] = $marking;
                    }
                }
            }
        }
        $URI = $serverURI . "/logic/LMarking/marking";
        http_post_data($URI, Marking::encodeMarking($markings), true, $message);
        if ($message == "201" || $message == "200") {
            $msg = Language::Get('main', 'successAssignment', $langTemplate);
            $assignManuallyNotifications[] = MakeNotification("success", $msg);
        } else {
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:AssignManually.php

示例8: __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

示例9: __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 == 'submissions') {
                 $this->{$key} = Submission::decodeSubmission($value, false);
             } elseif ($key == 'attachments') {
                 $this->{$key} = File::decodeFile($value, false);
             } elseif ($key == 'fileTypes') {
                 $this->{$key} = ExerciseFileType::decodeExerciseFileType($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,代码行数:30,代码来源:Exercise.php

示例10: updateSelectedSubmission

/**
 * Updates the selected submission of a group.
 *
 * @param string $databaseURI The url at which the database server is running.
 * @param int $leaderId The id of the the group's leader
 * @param int $submissionUd The new selected submission
 * @param int $exerciseId The submission's exercise id.
 * @param string &$message A reference to a variable that will contain the HTTP
 * status code on return.
 *
 * @return string On success rturns a json object, representing the selected
 * submission in the database. NULL otherwise.
 */
function updateSelectedSubmission($databaseURI, $leaderId, $submissionId, $exerciseId, &$message, $newFlag = null)
{
    $selectedSubmission = SelectedSubmission::createSelectedSubmission($leaderId, $submissionId, $exerciseId);
    $URL = $databaseURI . '/selectedsubmission';
    $returnedSubmission = http_post_data($URL, json_encode($selectedSubmission), true, $message);
    if ($message != "201") {
        $URL = $databaseURI . '/selectedsubmission/leader/' . $leaderId . '/exercise/' . $exerciseId;
        $returnedSubmission = http_put_data($URL, json_encode($selectedSubmission), true, $message);
    }
    if ($newFlag !== null) {
        // todo: treat the case if the previous operation failed
        if ($submissionId === null) {
            $ret = Submission::decodeSubmission($returnedSubmission);
            $submissionId = $ret->getId();
        }
        $URL = $databaseURI . '/submission/submission/' . $submissionId;
        $submissionUpdate = Submission::createSubmission($submissionId, null, null, null, null, null, null, $newFlag);
        $returnedSubmission2 = http_put_data($URL, json_encode($submissionUpdate), true, $message2);
    }
    return $returnedSubmission;
}
开发者ID:sawh,项目名称:ostepu-system,代码行数:34,代码来源:Helpers.php


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