我有一个grade
功能:
def grade(submission)
score_counter = 0
total_score = submission.test.questions.size
#the scoring logic is here
return (score_counter/total_score)*100
end
目的是返回百分比,但在我看来显示的所有内容都是0
。如果我只是尝试单独返回score_counter
和total_score
,它们会显示正确的值。有什么想法吗?
答案 0 :(得分:2)
您需要将值更改为浮动
$query = "SELECT * FROM assignments WHERE course_id=1";
$result1 = mysqli_query($conn, $query);
if (mysqli_num_rows($result1) != 0) {
$i = 0; //-------------->INITIALIZE THE VARIABLE
while ($row=mysqli_fetch_assoc($result1)) {
echo '<th colspan="'.$my_values[$i].'">'.$row['assignment_name'].'</th>';
$i++; //----------------> INCREMENT THE VARIABLE
}
}