<?php
 namespace Module\Paper\Util; use ModStart\Core\Dao\ModelUtil; class PaperUtil { public static function listQuestions($paperId) { $paperQuestions = ModelUtil::all('paper_question', ['paperId' => $paperId], ['*'], ['id', 'asc']); ModelUtil::decodeRecordsJson($paperQuestions, 'score'); return $paperQuestions; } public static function deleteQuestion($paperId, $questionId) { ModelUtil::delete('paper_question', ['paperId' => $paperId, 'questionId' => $questionId]); } public static function listCategories() { return ModelUtil::all('paper_category', [], ['*'], ['sort', 'asc']); } public static function getPaper($id) { return ModelUtil::get('paper', $id); } public static function getPaperByAlias($alias) { return ModelUtil::get('paper', ['alias' => $alias]); } public static function getPaperExam($id) { $paperExam = ModelUtil::get('paper_exam', $id); return $paperExam; } public static function listPaperExamQuestions($paperExamId) { $list = ModelUtil::all('paper_exam_question', ['examId' => $paperExamId], ['*'], ['id', 'asc']); ModelUtil::decodeRecordsJson($list, 'answer'); ModelUtil::decodeRecordsJson($list, 'score'); return $list; } }