public static function ExtractUser($data, $singleResult = false, $UserExtension = '', $CourseStatusExtension = '', $CourseExtension = '', $isResult = true) { // generates an assoc array of users by using a defined list of its // attributes $users = DBJson::getObjectsByAttributes($data, User::getDBPrimaryKey(), User::getDBConvert(), $UserExtension); // generates an assoc array of course stats by using a defined list of // its attributes $courseStatus = DBJson::getObjectsByAttributes($data, CourseStatus::getDBPrimaryKey(), CourseStatus::getDBConvert(), $CourseStatusExtension); // generates an assoc array of courses by using a defined list of // its attributes $courses = DBJson::getObjectsByAttributes($data, Course::getDBPrimaryKey(), Course::getDBConvert(), $CourseExtension); $settings = DBJson::getObjectsByAttributes($data, Setting::getDBPrimaryKey(), Setting::getDBConvert()); // concatenates the courses and the associated settings $res = DBJson::concatObjectListResult($data, $courses, Course::getDBPrimaryKey(), Course::getDBConvert()['C_settings'], $settings, Setting::getDBPrimaryKey()); // concatenates the course stats and the associated courses $res = DBJson::concatObjectListsSingleResult($data, $courseStatus, CourseStatus::getDBPrimaryKey(), CourseStatus::getDBConvert()['CS_course'], $res, Course::getDBPrimaryKey(), $CourseExtension, $CourseStatusExtension); // concatenates the users and the associated course stats $res = DBJson::concatResultObjectLists($data, $users, User::getDBPrimaryKey(), User::getDBConvert()['U_courses'], $res, CourseStatus::getDBPrimaryKey(), $CourseStatusExtension, $UserExtension); if ($isResult) { // to reindex // $res = array_merge($res); $res = User::decodeUser($res, false); if ($singleResult) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
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; }
public static function ExtractProcess($data, $singleResult = false, $ProcessExtension = '', $ComponentExtension = '', $ExerciseExtension = '', $isResult = true) { // generates an assoc array of processes by using a defined list of // its attributes $process = DBJson::getObjectsByAttributes($data, Process::getDBPrimaryKey(), Process::getDBConvert(), $ProcessExtension); // generates an assoc array of components by using a defined // list of its attributes $component = DBJson::getObjectsByAttributes($data, Component::getDBPrimaryKey(), Component::getDBConvert(), $ComponentExtension); // generates an assoc array of exercises by using a defined // list of its attributes $exercise = DBJson::getObjectsByAttributes($data, Exercise::getDBPrimaryKey(), Exercise::getDBConvert(), $ExerciseExtension); $attachment = Attachment::extractAttachment($data, false, '_PRO1', '_PRO1', false); $workFiles = Attachment::extractAttachment($data, false, '_PRO2', '_PRO2', false); // concatenates the processes and the associated attachments $process = DBJson::concatObjectListResult($data, $process, Process::getDBPrimaryKey(), Process::getDBConvert()['A_attachment'], $attachment, Attachment::getDBPrimaryKey(), '_PRO1', $ProcessExtension); // concatenates the processes and the associated attachments $process = DBJson::concatObjectListResult($data, $process, Process::getDBPrimaryKey(), Process::getDBConvert()['A_workFiles'], $workFiles, Attachment::getDBPrimaryKey(), '_PRO2', $ProcessExtension); // concatenates the processes and the associated components $process = DBJson::concatObjectListsSingleResult($data, $process, Process::getDBPrimaryKey(), Process::getDBConvert()['E_exercise'], $exercise, Exercise::getDBPrimaryKey(), $ExerciseExtension, $ProcessExtension); $res = DBJson::concatObjectListsSingleResult($data, $process, Process::getDBPrimaryKey(), Process::getDBConvert()['CO_target'], $component, Component::getDBPrimaryKey(), $ComponentExtension, $ProcessExtension); if ($isResult) { // to reindex $res = array_values($res); $res = Process::decodeProcess($res, false); if ($singleResult == true) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
public static function ExtractForm($data, $singleResult = false, $FormsExtension = '', $ChoiceExtension = '', $isResult = true) { // generates an assoc array of an forms by using a defined // list of its attributes $forms = DBJson::getObjectsByAttributes($data, Form::getDBPrimaryKey(), Form::getDBConvert(), $FormsExtension); // generates an assoc array of choices by using a defined // list of its attributes $choices = DBJson::getObjectsByAttributes($data, Choice::getDBPrimaryKey(), Choice::getDBConvert(), $ChoiceExtension); // concatenates the forms and the associated choices $res = DBJson::concatObjectListResult($data, $forms, Form::getDBPrimaryKey(), Form::getDBConvert()['FO_choices'], $choices, Choice::getDBPrimaryKey(), $ChoiceExtension, $FormsExtension); if ($isResult) { // to reindex $res = array_values($res); $res = Form::decodeForm($res, false); if ($singleResult) { // only one object as result if (count($res) > 0) { $res = $res[0]; } } } return $res; }
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; }