如何使用php對此測試進行評分?我需要一個百分比...在php中使用加權平均數進行評分
我有一系列的問題,包含正確/不正確的布爾和相應的重量。
我需要先找到正確答案的平均值嗎?
方程是什麼?
$questions = array(
0=>array(
'Question'=>"Some Question",
'Correct'=>true,
'Weight'=>5,
),
1=>array(
'Question'=>"Some Question",
'Correct'=>false,
'Weight'=>5,
),
2=>array(
'Question'=>"Some Question",
'Correct'=>true,
'Weight'=>4,
),
3=>array(
'Question'=>"Some Question",
'Correct'=>true,
'Weight'=>0,
),
4=>array(
'Question'=>"Some Question",
'Correct'=>false,
'Weight'=>5,
),
5=>array(
'Question'=>"Some Question",
'Correct'=>true,
'Weight'=>4,
),
);
$weights = array(
0=>0
1=>0
2=>.05
3=>.20
4=>.25
5=>.50
);
$totalQuestions=0;
$correctAnswers=0;
$points=0;
foreach($questions as $question){
$totalQuestions++;
if($question['Correct']){
$correctAnswers++;
$points = $points = $weights[$question['Weight'];
}
}