Example #1
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);
Example #2
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;
 }
Example #3
0
 public static function ExtractCourse($data, $singleResult = false, $CourseExtension = '', $SheetExtension = '', $isResult = true)
 {
     // generates an assoc array of courses by using a defined list of
     // its attributes
     $courses = DBJson::getObjectsByAttributes($data, Course::getDBPrimaryKey(), Course::getDBConvert(), $CourseExtension);
     // generates an assoc array of settings by using a defined list of
     // its attributes
     $settings = DBJson::getObjectsByAttributes($data, Setting::getDBPrimaryKey(), Setting::getDBConvert());
     // generates an assoc array of exercise sheets by using a defined list of
     // its attributes
     $exerciseSheets = DBJson::getObjectsByAttributes($data, ExerciseSheet::getDBPrimaryKey(), array(ExerciseSheet::getDBPrimaryKey() => ExerciseSheet::getDBConvert()[ExerciseSheet::getDBPrimaryKey()]), $SheetExtension);
     // concatenates the courses and the associated settings
     $res = DBJson::concatObjectListResult($data, $courses, Course::getDBPrimaryKey(), Course::getDBConvert()['C_settings'], $settings, Setting::getDBPrimaryKey());
     // concatenates the courses and the associated exercise sheet IDs
     $res = DBJson::concatResultObjectListAsArray($data, $res, Course::getDBPrimaryKey(), Course::getDBConvert()['C_exerciseSheets'], $exerciseSheets, ExerciseSheet::getDBPrimaryKey(), $SheetExtension, $CourseExtension);
     if ($isResult) {
         $res = Course::decodeCourse($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }
Example #4
0
 public function getCourseSheets($callName, $input, $params = array())
 {
     $getSheets = function ($input, $courseid, $exercise = null) {
         $getExercises = function ($input, $sheet) {
             $result = Model::isEmpty();
             $result['content'] = array();
             $data = array();
             foreach ($input as $inp) {
                 if ($inp->getNumRows() > 0) {
                     // extract Course data from db answer
                     $result['content'] = Exercise::ExtractExercise($inp->getResponse(), false, '', '', '', '', false);
                     $data = array_merge($data, $inp->getResponse());
                     $result['status'] = 200;
                 }
             }
             $result['content'] = DBJson::concatResultObjectLists($data, $sheet, ExerciseSheet::getDBPrimaryKey(), ExerciseSheet::getDBConvert()['ES_exercises'], $result['content'], Exercise::getDBPrimaryKey());
             $result['content'] = array_merge($result['content']);
             return self::finalizeSheets($result);
         };
         $result = Model::isEmpty();
         $result['content'] = array();
         foreach ($input as $inp) {
             if ($inp->getNumRows() > 0) {
                 $result['content'] = ExerciseSheet::ExtractExerciseSheet($inp->getResponse(), false, '', '', '', $exercise !== null ? false : true);
                 $result['status'] = 200;
             }
         }
         if ($exercise === null) {
             return self::finalizeSheets($result);
         }
         return $this->_component->call('getCourseExercises', array("courseid" => $courseid), '', 200, $getExercises, array("sheet" => $result['content']), 'Model::isProblem', array(), 'Query');
     };
     $params = DBJson::mysql_real_escape_string($params);
     return $this->_component->call('getCourseSheets', $params, '', 200, $getSheets, $params, 'Model::isProblem', array(), 'Query');
 }
Example #5
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));
 }
Example #6
0
                     // save mimeTypes in validated Exercises
                     $validatedExercises[$key1][$key2]['mime-type'] = $mimeTypes;
                 }
             }  else {
                 $notifications = array_merge($notifications, $eval->notifications);
                 $correctExercise = false;
                 break;
             }
         }
     }*/
 // only if validation was correct
 //$ready = $f->evaluate(true);
 $ready = true;
 if ($ready == true && $noFile == false && $correctExercise == true && $correctDates == true) {
     // encode to JSON
     $myExerciseSheetJSON = ExerciseSheet::encodeExerciseSheet($myExerciseSheet);
     // Post ExcercisSheet to logic Controllers to create it and get saved data
     $output = http_post_data($logicURI . "/exercisesheet", $myExerciseSheetJSON, true, $message);
     $output = json_decode($output, true);
     // create subtasks as exercise
     if ($message == 201) {
         if (isset($output['id'])) {
             $id = $output['id'];
             $sid = $id;
         }
         if ($sheet_data_old !== null) {
             // get removed exercises
             if (isset($sheet_data_old['exercises'])) {
                 function comp_func_cr($a, $b)
                 {
                     if (!isset($b['id'])) {