private function _sendPayment($marker, $marks, $assessmentAssoc, $assessmentFix = 0) { if (count($marks) === 0 && empty($assessmentAssoc)) { return false; } foreach ($marks as $markAssoc) { $mark = new Mark(); $mark->setKey($markAssoc[$mark->getKeyField()]); $mark->paid(); $mark->update(); $markKeys[] = $markAssoc[$mark->getKeyField()]; } $assessmentAmount = 0; if (!empty($assessmentAssoc)) { $assessment = new Assessment(); $assessment->setKey($assessmentAssoc[$assessment->getKeyField()]); $assessment->paid(); $assessment->update(); $markKeys[] = 'Assessment script'; $assessmentAmount = 1; } if ($assessmentFix) { $assessmentFix = new AssessmentFix(); $assessmentFix->setKey($this->_getUser()); $assessmentFix->paid(); $assessmentFix->update(); $markKeys[] = 'Assessment bounty'; } $this->load->model('wage'); $amount = ($assessmentFix + count($marks) + $assessmentAmount) * 1.5; $wage = new Wage(); $wage->paid($marker, $amount, $markKeys); $wage->create(); return $amount; }
public function addMark() { if (!($jsonData = $this->input->post('jsonData'))) { die('null'); } $this->load->model('assessment'); $this->load->model('script'); $this->load->library('json'); $decoded = $this->json->decode($jsonData); $assessment = new Assessment(); $assessment->setKey($decoded->script); $assessment->set('marker', $this->session->userdata($this->_sessionAuthVar)); $assessment->set('markData', $jsonData); $assessment->set('targets', serialize($decoded->targets)); $assessment->set('generalComment', $decoded->generalComment); $assessment->set('status', Assessment::UNPAID); if ($assessment->create()) { $this->_flexResult(I_FlexMarksIn::SAVE_SUCCESSFUL); } else { $this->_flexResult(I_FlexIO::ERROR); } }