Example #1
0
 public static function ExtractCourseStatus($data, $singleResult = false, $UserExtension = '', $CourseStatusExtension = '', $CourseExtension = '', $isResult = true)
 {
     // generates an assoc array of a user by using a defined list of its
     // attributes
     $user = 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);
     // concatenates the course stats and the associated courses
     $res = DBJson::concatObjectListsSingleResult($data, $courseStatus, CourseStatus::getDBPrimaryKey(), CourseStatus::getDBConvert()['CS_course'], $courses, Course::getDBPrimaryKey(), $CourseExtension, $CourseStatusExtension);
     // concatenates the users and the associated course stats
     $res = DBJson::concatResultObjectLists($data, $user, User::getDBPrimaryKey(), User::getDBConvert()['U_courses'], $res, CourseStatus::getDBPrimaryKey(), $CourseStatusExtension, $UserExtension);
     if ($isResult) {
         // to reindex
         // $res = array_merge($res);
         $res = CourseStatus::decodeCourseStatus($res, false);
         if ($singleResult == true) {
             // only one object as result
             if (count($res) > 0) {
                 $res = $res[0];
             }
         }
     }
     return $res;
 }