Ejemplo n.º 1
0
 public static function ExtractExerciseSheet($data, $singleResult = false, $SheetExtension = '', $SheetFileExtension = '', $SheetSolutionExtension = '', $isResult = true)
 {
     // generates an assoc array of an exercise sheet by using a defined list of its attributes
     $exerciseSheet = DBJson::getObjectsByAttributes($data, ExerciseSheet::getDBPrimaryKey(), ExerciseSheet::getDBConvert(), $SheetExtension);
     // generates an assoc array of an file by using a defined list of its attributes
     $exerciseSheetFile = DBJson::getObjectsByAttributes($data, File::getDBPrimaryKey(), File::getDBConvert(), $SheetFileExtension);
     // generates an assoc array of an file by using a defined list of its attributes
     $sampleSolutions = DBJson::getObjectsByAttributes($data, File::getDBPrimaryKey(), File::getDBConvert(), $SheetSolutionExtension . '2');
     // concatenates the exercise sheet and the associated sample solution
     $res = DBJson::concatObjectListsSingleResult($data, $exerciseSheet, ExerciseSheet::getDBPrimaryKey(), ExerciseSheet::getDBConvert()['F_id_file'], $exerciseSheetFile, File::getDBPrimaryKey(), $SheetFileExtension, $SheetExtension);
     // concatenates the exercise sheet and the associated exercise sheet file
     $res = DBJson::concatObjectListsSingleResult($data, $res, ExerciseSheet::getDBPrimaryKey(), ExerciseSheet::getDBConvert()['F_id_sampleSolution'], $sampleSolutions, File::getDBPrimaryKey(), $SheetSolutionExtension . '2', $SheetExtension);
     if ($isResult) {
         // to reindex
         $res = array_merge($res);
         $res = ExerciseSheet::decodeExerciseSheet($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
Ejemplo n.º 2
0
<?php

// removes all tutor assignments by deleting all markings of the exercisesheet
if (isset($_POST['action']) && $_POST['action'] == "AssignMakeWarning") {
    $assignMakeNotifications[] = MakeNotification("warning", Language::Get('main', 'askMake', $langTemplate));
} elseif (isset($_POST['action']) && $_POST['action'] == "AssignMake") {
    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);
Ejemplo n.º 3
0
 /**
  * Deletes an exercise sheet.
  *
  * Called when this component receives an HTTP DELETE request to
  * /exercisesheet/exercisesheet/$sheetid(/).
  * Deletes the exercise sheet information from the database first. At success
  * the file belongs to this exercise will be deleted from the filesystem.
  *
  * @param int $sheetid The id of the exercise sheet that is being deleted.
  */
 public function deleteExerciseSheet($sheetid)
 {
     $this->app->response->setStatus(201);
     Logger::Log('starts DELETE DeleteExerciseSheet', LogLevel::DEBUG);
     $body = $this->app->request->getBody();
     $res = null;
     // getExerciseSheet
     $result = Request::routeRequest('GET', '/exercisesheet/' . $sheetid, array(), '', $this->_getExerciseSheet, 'exercisesheet');
     // checks the correctness of the query
     if ($result['status'] >= 200 && $result['status'] <= 299 && isset($result['content'])) {
         $exerciseSheet = ExerciseSheet::decodeExerciseSheet($result['content']);
         $sampleFile = $exerciseSheet->getSampleSolution();
         $sheetFile = $exerciseSheet->getSheetFile();
         // delete exerciseSheet
         $result = Request::routeRequest('DELETE', '/exercisesheet/' . $sheetid, array(), '', $this->_deleteExerciseSheet, 'exercisesheet');
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             // exerciseSheet is deleted
             // delete sampleSolution if exists
             if ($sampleFile !== null) {
                 $result = Request::routeRequest('DELETE', '/file/' . $sampleFile->getFileId(), array(), '', $this->_deleteFile, 'file');
             }
             // delete sheetFile if exists
             if ($sheetFile !== null) {
                 $result = Request::routeRequest('DELETE', '/file/' . $sheetFile->getFileId(), array(), '', $this->_deleteFile, 'file');
             }
             $res = new ExerciseSheet();
         } else {
             $res = null;
             $this->app->response->setStatus(409);
         }
     } else {
         $res = null;
         $this->app->response->setStatus(409);
     }
     if ($this->app->response->getStatus() != 201) {
         Logger::Log('DELETE DeleteExerciseSheet failed', LogLevel::ERROR);
     }
     $this->app->response->setBody(ExerciseSheet::encodeExerciseSheet($res));
 }