Hi,
I hope I understand the question correctly.
Normally you should minimize the code-usage in a view. This is because a view is normally not compiled but just interpreted on runtime.
So I would suggest you, that you extend your student model with an enum, which contains the state of the average points of this student. Now on the view simply use this state for example to form a css class and style the td in a .css stylesheet (please DON'T use inline-styles, because if someone want to change a style later on, it is nearly impossible to do so with inline styles).
Here is a small example:
Model-Data:
[
{ name: "student 1", points: 40, state: TooLow },
{ name: "student 2", points: 60, state: Ok },
{ name: "student 3", points: 100, state: Excellent }
]
View:
<table>
<thead>
<tr>
<th>Name</th>
<th>Points</th>
</tr>
</thead>
<tbody>
@foreach (var student in Model)
{
<tr>
<td>@student.name</td>
<td class="@student.state">@student.points</td>
</tr>
}
</tbody>
</table>
Css:
table td.TooLow {
background-color: #f00;
}
table td.Ok {
background-color: #ff0;
}
table td.Excellent {
background-color: #0f0;
}
Hope this helps :)
Best regards and happy coding,
Chris