|
@@ -86,16 +86,21 @@ class LearnReportShareImage extends Api
|
|
|
$uid = $this->checkLogin();
|
|
|
// 接收参数
|
|
|
$courseId = request('course_id', 0);
|
|
|
+ $recordId = request('record_id', 0);
|
|
|
$url = request('page', 'pages/video/index');
|
|
|
$size = request('size', 150);
|
|
|
$scene = request('scene', '');
|
|
|
$position = 'bottom-left';
|
|
|
$fontPath = public_path() . '/fonts/msyh14.ttf'; // 指定字体文件路径
|
|
|
//获取总积分(客户)
|
|
|
- $totalQuestionNum = $learnRecordModel->query()->where([['course_id', '=', $courseId], ['custom_uid', '=', $uid]])->sum('question_total');
|
|
|
- $correctNum = $learnRecordModel->query()->where([['course_id', '=', $courseId], ['custom_uid', '=', $uid]])->sum('isanswer_total');
|
|
|
+ $reportData = $learnRecordModel->query()->where([['id','=',$recordId]])->first(['question_total','isanswer_total']);
|
|
|
+ // 如果没有数据
|
|
|
+ if( !$reportData ) return json_send(['code' => 'error', 'msg' => '没有答题记录']);
|
|
|
+ // 返回结果
|
|
|
+ $totalQuestionNum = $reportData['question_total'];
|
|
|
+ $correctNum = $reportData['isanswer_total'];
|
|
|
$inCorrectNum = $totalQuestionNum - $correctNum;
|
|
|
- $accuracy = $correctNum / $totalQuestionNum * 100;
|
|
|
+ $accuracy = $totalQuestionNum ? ($correctNum / $totalQuestionNum) * 100 : 100;
|
|
|
try {
|
|
|
// 加载图片
|
|
|
$image = Image::make(public_path('uploads/images/default/') . 'analysis_report_share_base.png');
|