Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

public static function getAssignmentMasteredSkillResult($id, $is_dynamic = 0)

{
$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
];
}

public static function getAssignmentAcquiredSkillResult($id)


{
$acquired_skill = 0;
$mastered_skills = RemediationMasteredSkill::distinct('skill_id')-
>where('student_id', Auth::user()->id)->where('assignment_id', $id)->count();
$total_questions = StudentAnswer::where('student_id', Auth::user()->id)
->where('assignment_id', $id)->count();
if ($total_questions > 0) {
$acquired_skill = round($mastered_skills * 100 / $total_questions, 0);
}
return $acquired_skill;
}

You might also like