public function setTestResults($args) { Log::debug("Processing test results for User " . $this->getUserId() . " for " . $args['level'] . "/" . $args['lesson']); $defaults = ["max_score" => 100, "min_score" => 0, "passing_score" => 70]; $bad_arg = false; foreach (['passing_score', 'min_score', 'max_score', 'points', 'max_points'] as $key) { if (!(array_key_exists($key, $args) && Number::isInteger($args[$key]))) { Log::error(__METHOD__ . " given invalid argument; {$key} is either undefined or not a valid integer"); $bad_arg = true; } } if ($bad_arg === true) { $debug = str_replace("\n", '\\n', print_r($args, true)); Log::debug("Arguments: {$debug}"); Log::debug("Cancelling collection of test results due to bad arguments :("); return null; } $args = array_merge($defaults, $args); $sql = <<<SQL \t\t\tINSERT INTO test_result (user_id, level_id, lesson_id, score, passing_score, min_score, max_score, points, max_points) \t\t\tVALUES (:user_id, :level_id, :lesson_id, :score, :passing_score, :min_score, :max_score, :points, :max_points); SQL; $stmt = PdoFactory::getInstance()->prepare($sql); Log::debug("User " . $this->getUserId() . ' passed exam ' . $args['level'] . '/' . $args['lesson'] . ' with a score of ' . $args['score']); $rc = $stmt->execute([':user_id' => $this->getUserId(), ':level_id' => $args['level'], ':lesson_id' => $args['lesson'], ':score' => $args['score'], ':passing_score' => $args['passing_score'], ':min_score' => $args['min_score'], ':max_score' => $args['max_score'], ':points' => $args['points'], ':max_points' => $args['max_points']]); if ($rc === false) { Log::debug("Test result insertion failed for user " . $this->getUserId()); return null; } Log::debug("Test result insertion succeeded for user " . $this->getUserId() . ". Invalidating user cache."); $this->invalidateCache(); return $args['score'] >= $args['passing_score']; }
$message .= 'Telephone: ' . $request->post('phone') . "\r\n"; $message .= ' Category: ' . $request->post('verbose_category') . "\r\n"; $message .= "</pre>\r\n"; $comment = $request->post('comment'); if ($comment) { $message .= '<h3 style="font-size:x-large;font-family:Calibri,Verdana,sans;border-bottom:2px solid #000;">Comment' . "</h3>\r\n"; $message .= "{$comment}\r\n"; } $sample = $request->post('arabic'); if ($sample) { $message .= '<h3 style="font-size:x-large;font-family:Calibri,Verdana,sans;border-bottom:2px solid #000;">Arabic Sample' . "</h3>\r\n"; $message .= '<p dir="rtl" style="font-size:xx-large">' . $sample . "</p>\r\n"; } $message .= "</body>\r\n"; $message .= "</html>\r\n"; \PTA\Log::debug("support category: " . $request->post('category')); switch ($request->post('category')) { case 'billing': $subject .= 'a billing enquiry'; $alias = 'billing'; break; case 'feedback': $subject .= 'feedback'; $alias = 'feedback'; break; case 'teacher': $subject .= 'a request for teacher support'; $alias = 'teacher'; break; default: $subject .= 'a support request';