$infoToSet['exam_group'] = $courseInfo['exam']['group']; if ($existingEvaluationId) { $infoToSet['id'] = $existingEvaluationId; } $courses->setInfoArray($infoToSet); $success = $courses->commit(); if (!$success) { $infoToSet['description'] = mb_convert_encoding($infoToSet['description'], 'UTF-8', 'Windows-1252'); $courses->setInfoArray($infoToSet); $success = $courses->commit(); } ProjectFunctions::assertAndPrint($success, $courses); if (!$existingEvaluationId) { $existingEvaluationId = $courses->insertId; } $courseNames->clearInfo(); $infoToSet = array_merge(extractFieldsFromArray(array('subject', 'number'), $courseInfo['course_codes']['listings'][0]), extractFieldsFromArray(array('section', 'oci_id'), $courseInfo['course_codes'])); $infoToSet['course_id'] = $existingEvaluationId; $courseNames->setInfoArray($infoToSet); ProjectFunctions::assertAndPrint($courseNames->commit(), $courseNames); $courseAreas = new MysqlTable($mysqli, 'course_areas'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseAreas, $existingEvaluationId, 'area', $courseInfo['areas']), $courseAreas); $courseSkills = new MysqlTable($mysqli, 'course_skills'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseSkills, $existingEvaluationId, 'skill', $courseInfo['skills']), $courseSkills); $courseProfessors = new MysqlTable($mysqli, 'course_professors'); ProjectFunctions::assertAndPrint(addCourseItemsMappings($courseProfessors, $existingEvaluationId, 'professor', $courseInfo['professors']), $courseProfessors); if ($courseInfo['exam']['group'] !== 0) { $examGroups = new MysqlTable($mysqli, 'exam_groups'); $infoToSet = extractFieldsFromArray(array('date', 'time'), $courseInfo['exam']); $infoToSet['id'] = $courseInfo['exam']['group']; $examGroups->setInfoArray($infoToSet);