|
|
|
|
@ -161,6 +161,10 @@ class ImportCsv |
|
|
|
|
$method = 'importCareersResults'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($method == 'importCareersresultsremoveStatic') { |
|
|
|
|
$method = 'importCareersResultsRemoveStatic'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($method == 'importOpensessions') { |
|
|
|
|
$method = 'importOpenSessions'; |
|
|
|
|
} |
|
|
|
|
@ -262,6 +266,7 @@ class ImportCsv |
|
|
|
|
'unsubsessionsextid-static', |
|
|
|
|
'subsessionsextid-static', |
|
|
|
|
'calendar-static', |
|
|
|
|
'careersresultsremove-static' |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
foreach ($sections as $section) { |
|
|
|
|
@ -289,6 +294,7 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->logger->addInfo('teacher backup'); |
|
|
|
|
$this->logger->addInfo(print_r($teacherBackup, 1)); |
|
|
|
|
|
|
|
|
|
@ -2813,6 +2819,107 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $file |
|
|
|
|
* @param bool $moveFile |
|
|
|
|
* @param array $teacherBackup |
|
|
|
|
* @param array $groupBackup |
|
|
|
|
*/ |
|
|
|
|
private function importCareersResultsRemoveStatic( |
|
|
|
|
$file, |
|
|
|
|
$moveFile = false, |
|
|
|
|
&$teacherBackup = [], |
|
|
|
|
&$groupBackup = [] |
|
|
|
|
) { |
|
|
|
|
$data = Import::csv_reader($file); |
|
|
|
|
|
|
|
|
|
$careerIdList = []; |
|
|
|
|
$userIdList = []; |
|
|
|
|
|
|
|
|
|
if (!empty($data)) { |
|
|
|
|
$totalCount = count($data); |
|
|
|
|
$this->logger->addInfo($totalCount.' records found.'); |
|
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('career'); |
|
|
|
|
$extraFieldName = $this->extraFieldIdNameList['career']; |
|
|
|
|
$rowCounter = 0; |
|
|
|
|
foreach ($data as $row) { |
|
|
|
|
$this->logger->addInfo("---------- Row: # $rowCounter"); |
|
|
|
|
$rowCounter++; |
|
|
|
|
if (empty($row)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($row as $key => $value) { |
|
|
|
|
$key = (string) trim($key); |
|
|
|
|
// Remove utf8 bom |
|
|
|
|
$key = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $key); |
|
|
|
|
$row[$key] = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$rowStudentId = $row['StudentId']; |
|
|
|
|
|
|
|
|
|
if (isset($userIdList[$rowStudentId])) { |
|
|
|
|
$studentId = $userIdList[$rowStudentId]; |
|
|
|
|
} else { |
|
|
|
|
$studentId = UserManager::get_user_id_from_original_id( |
|
|
|
|
$rowStudentId, |
|
|
|
|
$this->extraFieldIdNameList['user'] |
|
|
|
|
); |
|
|
|
|
$userIdList[$rowStudentId] = $studentId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$careerId = $row['CareerId']; |
|
|
|
|
if (isset($careerIdList[$careerId])) { |
|
|
|
|
$careerChamiloId = $careerIdList[$careerId]; |
|
|
|
|
} else { |
|
|
|
|
$item = $extraFieldValue->get_item_id_from_field_variable_and_field_value( |
|
|
|
|
$extraFieldName, |
|
|
|
|
$careerId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($item)) { |
|
|
|
|
$careerIdList[$careerId] = 0; |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
if (isset($item['item_id'])) { |
|
|
|
|
$careerChamiloId = $item['item_id']; |
|
|
|
|
$careerIdList[$careerId] = $careerChamiloId; |
|
|
|
|
} else { |
|
|
|
|
$careerIdList[$careerId] = 0; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($careerChamiloId)) { |
|
|
|
|
$this->logger->addInfo("Career not found: $careerId "); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userCareerData = UserManager::getUserCareer($studentId, $careerChamiloId); |
|
|
|
|
|
|
|
|
|
if (empty($userCareerData)) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"User chamilo id # $studentId (".$row['StudentId'].") has no career #$careerChamiloId (ext #$careerId)" |
|
|
|
|
); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$extraData = isset($userCareerData['extra_data']) && !empty($userCareerData['extra_data']) ? unserialize($userCareerData['extra_data']) : []; |
|
|
|
|
$extraData[$row['CourseId']][$row['ResultId']] = []; |
|
|
|
|
$serializedValue = serialize($extraData); |
|
|
|
|
|
|
|
|
|
UserManager::updateUserCareer($userCareerData['id'], $serializedValue); |
|
|
|
|
|
|
|
|
|
$this->logger->addInfo('Deleting: result id'.$row['ResultId']); |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Saving graph for user chamilo # $studentId (".$row['StudentId'].") with career #$careerChamiloId (ext #$careerId)" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $file |
|
|
|
|
* @param bool $moveFile |
|
|
|
|
|