You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/web/model/topic/ExaminationTestRecord.php

57 lines
2.0 KiB

10 months ago
<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\web\model\topic;
use traits\ModelTrait;
use basic\ModelBasic;
/**
* 考试试题记录 Model
* Class ExaminationTestRecord
*/
class ExaminationTestRecord extends ModelBasic
{
use ModelTrait;
/**保存试题答题结果
* @param $data
* @param $uid
*/
public static function addExaminationTestRecord($data, $uid)
{
$id = self::where(['e_id' => $data['e_id'], 'type' => $data['type'], 'questions_id' => $data['questions_id'], 'uid' => $uid])->value('id');
if ($data['is_correct'] != 2) $data['score'] = 0;
if ($id) {
$dat['user_answer'] = $data['user_answer'];
$dat['is_correct'] = $data['is_correct'];
$dat['score'] = $data['score'];
$res = self::edit($dat, $id);
} else {
$data['uid'] = $uid;
$res = self::set($data);
}
return $res;
}
/**检测是否答题
* @param $e_id
* @param $uid
* @param $qid
*/
public static function checkWhetherAnswerQuestions($e_id, $type, $uid, $qid)
{
$test = self::where(['e_id' => $e_id, 'type' => $type, 'questions_id' => $qid, 'uid' => $uid])->find();
if (!$test) return [];
else return ['is_correct' => $test['is_correct'], 'user_answer' => $test['user_answer']];
}
}