|
@@ -2643,6 +2643,108 @@ class ImportCsv
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * @param $file
|
|
|
+ * @param bool $moveFile
|
|
|
+ * @param array $teacherBackup
|
|
|
+ * @param array $groupBackup
|
|
|
+ */
|
|
|
+ private function importCareersResults(
|
|
|
+ $file,
|
|
|
+ $moveFile = false,
|
|
|
+ &$teacherBackup = [],
|
|
|
+ &$groupBackup = []
|
|
|
+ ) {
|
|
|
+ $data = Import::csv_reader($file);
|
|
|
+
|
|
|
+ if (!empty($data)) {
|
|
|
+ $this->logger->addInfo(count($data).' records found.');
|
|
|
+ $values = [];
|
|
|
+ foreach ($data as $row) {
|
|
|
+ if (empty($row)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($row as $key => $value) {
|
|
|
+ $key = (string) trim($key);
|
|
|
+
|
|
|
+ $key = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $key);
|
|
|
+ $row[$key] = $value;
|
|
|
+ }
|
|
|
+ $values[$row['Column']][] = $row;
|
|
|
+ }
|
|
|
+
|
|
|
+ $careerList = [];
|
|
|
+ $careerNameList = [];
|
|
|
+ ksort($values);
|
|
|
+ $careerChamiloIdList = [];
|
|
|
+ $extraFieldValue = new ExtraFieldValue('career');
|
|
|
+ $extraFieldName = $this->extraFieldIdNameList['career'];
|
|
|
+
|
|
|
+
|
|
|
+ foreach ($values as $column => $rowList) {
|
|
|
+ foreach ($rowList as $row) {
|
|
|
+ $studentId = $row['StudentId'];
|
|
|
+ $studentInfo = api_get_user_info($studentId);
|
|
|
+ if (empty($studentInfo)) {
|
|
|
+ $this->logger->addInfo("Student id not found: $studentId");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $careerId = $row['CareerId'];
|
|
|
+ $item = $extraFieldValue->get_item_id_from_field_variable_and_field_value(
|
|
|
+ $extraFieldName,
|
|
|
+ $careerId
|
|
|
+ );
|
|
|
+
|
|
|
+ $careerChamiloId = null;
|
|
|
+ if (empty($item)) {
|
|
|
+ $this->logger->addInfo("Career not found: $careerId");
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ if (isset($item['item_id'])) {
|
|
|
+ $careerChamiloId = $item['item_id'];
|
|
|
+
|
|
|
+ $career = $career->find($careerChamiloId);
|
|
|
+ $chamiloCareerName = $career['name'];
|
|
|
+ $careerNameList[$careerId] = $chamiloCareerName;
|
|
|
+ $careerChamiloIdList[$careerId] = $careerChamiloId;*/
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (UserManager::userHasCareer($studentId, $careerChamiloId) === false) {
|
|
|
+ $this->logger->addInfo("User #$studentId has no career # $careerChamiloId");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $userCareerData = UserManager::getUserCareer($studentId, $careerChamiloId);
|
|
|
+
|
|
|
+ $extraData = isset($userCareerData['extra_data']) && !empty($userCareerData['extra_data']) ? unserialize($userCareerData['extra_data']) : [];
|
|
|
+
|
|
|
+ $extraData[$row['CourseId']][] = [
|
|
|
+ 'Description' => $row['Description'],
|
|
|
+ 'Period' => $row['Period'],
|
|
|
+ 'TeacherText' => $row['TeacherText'],
|
|
|
+ 'TeacherUsername' => $row['TeacherUsername'],
|
|
|
+ 'ScoreText' => $row['ScoreText'],
|
|
|
+ 'ScoreValue' => $row['ScoreValue'],
|
|
|
+ 'Info' => $row['Info'],
|
|
|
+ 'BgColor' => $row['BgColor'],
|
|
|
+ 'Color' => $row['Color'],
|
|
|
+ 'BorderColor' => $row['BorderColor'],
|
|
|
+ 'Icon' => $row['Icon'],
|
|
|
+ 'IconColor' => $row['IconColor'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $serializedValue = serialize($extraData);
|
|
|
+
|
|
|
+ UserManager::updateUserCareer($userCareerData['id'], $serializedValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* @param $file
|
|
|
* @param bool $moveFile
|