/**
  * @param Member $owner
  * @param string $exam_ext_id
  * @return ICertifiedOpenStackAdministratorExam
  */
 public function build(Member $owner, $exam_ext_id)
 {
     //create exam
     $exam = CertifiedOpenStackAdministratorExam::create();
     $exam->OwnerID = $owner->ID;
     $exam->ExternalID = $exam_ext_id;
     return $exam;
 }
 function process()
 {
     set_time_limit(0);
     $csv_file = isset($_GET['csv_file']) ? trim($_GET['csv_file']) : null;
     if (is_null($csv_file)) {
         echo 'ERROR - csv_file param missing!';
         exit;
     }
     $ds = new CvsDataSourceReader(",");
     $cur_path = Director::baseFolder();
     $ds->Open($cur_path . "/assets/" . $csv_file);
     $headers = $ds->getFieldsInfo();
     try {
         $exams = 0;
         while (($row = $ds->getNextRow()) !== FALSE) {
             $code = trim($row[$headers["exam_code"]]);
             if ($code != 'COA-EVENT') {
                 continue;
             }
             $email = trim($row[$headers['open_stack_id']]);
             $exam_ext_id = trim($row[$headers['candidate_exam_id']]);
             $status = trim($row[$headers['exam_status']]);
             $pass_date = trim($row[$headers['pass_fail_date_c']]);
             $cert_nbr = trim($row[$headers['certification_number']]);
             $modified_date = trim($row[$headers['candidate_exam_date_modified']]);
             $exam_expiration_date = trim($row[$headers['exam_expiration_date']]);
             $cert_exam_expiration_date = trim($row[$headers['certificate_expiration_date']]);
             $cert_status = trim($row[$headers['certification_status']]);
             $member = $this->member_repository->findByEmail($email);
             if (is_null($member)) {
                 continue;
             }
             $exam = $member->getExamByExternalId($exam_ext_id);
             if (is_null($exam)) {
                 //create exam
                 $exam = CertifiedOpenStackAdministratorExam::create();
                 $exam->OwnerID = $member->ID;
                 $exam->ExternalID = $exam_ext_id;
             }
             $exam->setState($status, $modified_date, $exam_expiration_date, $pass_date, $code, $cert_nbr, $cert_exam_expiration_date, $cert_status);
             $exam->write();
             $exams++;
         }
     } catch (Exception $e) {
         $status = 0;
     }
     echo sprintf("created %s exams", $exams);
 }
 /**
  * @param string $track_id
  * @return ICertifiedOpenStackAdministratorExam[]
  */
 public function getByTrackId($track_id)
 {
     return CertifiedOpenStackAdministratorExam::get()->filter('TrackID', $track_id)->sort('TrackModifiedDate', 'ASC')->toArray();
 }