/** * public $TH; * public $XZ; * public $E; * public $N; * public $P; * public $L; * @throws Exception * @return boolean */ private static function startMysqlEpqadfMemory() { $epqadf_first = EpqadfMemory::findFirst(); if (isset($epqadf_first->TH)) { return true; } else { try { $manager = new TxManager(); $transaction = $manager->get(); $epqadf_data = Epqadf::find(); foreach ($epqadf_data as $epqadf_record) { $epqadf_memory = new EpqadfMemory(); $epqadf_memory->setTransaction($transaction); $epqadf_memory->TH = $epqadf_record->TH; $epqadf_memory->XZ = $epqadf_record->XZ; $epqadf_memory->E = $epqadf_record->E; $epqadf_memory->N = $epqadf_record->N; $epqadf_memory->P = $epqadf_record->P; $epqadf_memory->L = $epqadf_record->L; if ($epqadf_memory->create() == false) { unset($epqadf_data); $transaction->rollback("EPQADF DATA INSERT INTO MEMORY TABLE ERROR!"); } } $transaction->commit(); return true; } catch (TxFailed $e) { throw new Exception("Failed, reason: " . $e->getMessage()); } } }
/** * 计算EPQA基础得分 * @param \Phalcon\Mvc\Model\Resultsets\Simple $array * @return string */ protected static function handleEPQA(&$array) { $array_list = self::strDivideToArray($array->option, $array->question_number_list); #判断内存表状态 if (!self::$memory_state) { self::loadMemoryTable(); } $rtn_array = array(); foreach ($array_list as $array_record) { $rtn_array[] = EpqadfMemory::getRecord(intval($array_record['number']), intval(ord($array_record['option']) - ord('a') + 1)); } return implode('|', $rtn_array); }