Professional Documents
Culture Documents
refactored_functions
refactored_functions
{
$AssignmentQuestions = StudentAnswer::where('assignment_id', $id)-
>where('student_id', Auth::user()->id)
->pluck("question_id")->toArray();
switch ($is_dynamic) {
case 1:
$total_questions_skills =
QueryHelper::getQuestionsSkillsCount($AssignmentQuestions);
break;
default:
$total_questions_skills =
QueryHelper::getQuestionsSkillsCount($AssignmentQuestions);
break;
}
$studentCorrectAnswersQuestionsIds = StudentAnswer::where('assignment_id',
$id)
->where('student_id', Auth::user()->id)
->where('is_correct', 1)
->pluck('question_id');
$mastered_questions_skills =
QueryHelper::getSkillsIdsByQuestions($studentCorrectAnswersQuestionsIds);
$mastered_skill = 0;
if ($total_questions_skills > 0) {
$mastered_skill = number_format(count($mastered_questions_skills) * 100
/ $total_questions_skills, 0);
}
return [
'mastered_skill' => $mastered_skill,
'number_mastered_skill' => count($mastered_questions_skills),
'total_skills' => $total_questions_skills
];
}