public static function manage() { self::ensureAdmin(); // Handle creation of vanilla questions. $createVanillaData = self::createVanilla(); // Handle deletion of questions. self::delete(); // Handle editing of questions. self::edit(); // Load all questions. $questions = Question::getAll(); $typeMap = mapDataArrayByField($questions, function (Question $each) { return $each->getVanilla(); }, [true => 'vanilla', false => 'custom']); $viewData = ['vanilla' => [], 'custom' => []]; foreach ($typeMap['vanilla'] as $vanilla) { $viewData['vanilla'][] = $vanilla->getData(); } foreach ($typeMap['custom'] as $custom) { $viewData['custom'][] = $custom->getData(); } self::render('admin/questions', array_merge($viewData, $createVanillaData)); }
public static function getClaimedByJob(MongoId $jobId) { $jobs = self::processDataArray(ApplicationModel::getClaimed($jobId)); $statusMap = mapDataArrayByField($jobs, function (ApplicationStudent $each) { return $each->getStatus(); }, [self::STATUS_REVIEW => 'review', self::STATUS_REJECTED => 'rejected', self::STATUS_ACCEPTED => 'accepted']); return $statusMap; }