+1  A: 
  1. Can this be done in Code Igniter? Yes you should be able to.

  2. Should this be done in the view? No you should not be doing your calculations in a view. Make a class and bring that in when you're creating a model to handle the grades. Your view should only be used to render your user interface.

Chris
+1  A: 

I'd suggest doing this in the Model when you are getting your data from MySQL. That way your data is all sorted and ready to use when you get it back.

Take a look at http://rpbouman.blogspot.com/2009/09/mysql-another-ranking-trick.html for a way to rank data in a SQL query.

bradym
You beet me to it.
Christopher W. Allen-Poole
A: 

I wouldn't recommend calculating anything in the view.

I would suggest if your using codeigniter to go with an MVC framework, then possibly have a model representing the functionality you're describing and a controller to pull this model and your view together.

I would also suggest this video tutorial on codeigniter for a very good overview of the framework and on coding MVC applications.

Shane