I need some help with building a site for professor rating for a specific university.
Using the Node Comments and Fivestar module (http://drupal.org/node/234681), I was able to create a rating system for professors. I have two content types, one is "professor" and the other is "professor ratings".
The professor content type has few basic fields such has last name, first name, middle name, and discipline. The discipline field is a content taxonomy field where when creating the a professor, users are required to select a department a professor belongs to from a drop down list. I will manually add a list of departments to a vocabulary which I have created.
The problem I am having is creating a page with a list of professors so users can pick a professor and rate them. I want to create a view with a list of professors which is sortable by either first name, last name, middle name, department, and overall rating. Overall rating is the average of all the raitings given to the professor by the users in the "professor ratings" content type.
I ran into two problems,
1) I set the style of the view to be a table. I managed to get the table to be sortable by name, but I can't get the discipline to be sortable. How do I get it to be sortable?
2) I have no idea how to get the overall rating to show up in the view I have created. Although I did add the PHP code below to node-professor.tpl file, which displays the overall rating, how do I get his overall rating to show in my view? Will I have to add a computed field to the professor content type? If so how would I do this and add it into my view?
<?php
$easiness_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'easiness', 'function' => 'average'));
print '<div><strong>Easiness Rating:</strong>';
print theme('fivestar_static', $easiness_rating[0]['value'], '5');
print '</div>';
$helpfulness_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'helpfulness', 'function' => 'average'));
print '<div><strong>Helpfulness Rating:</strong>';
print theme('fivestar_static', $helpfulness_rating[0]['value'], '5');
print '</div>';
$clarity_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'clarity', 'function' => 'average'));
print '<div><strong>Clarity Rating:</strong>';
print theme('fivestar_static', $clarity_rating[0]['value'], '5');
print '</div>';
$teaching_style_rating = votingapi_select_results(array('content_id' => $node->nid, 'tag' =>'teaching style', 'function' => 'average'));
print '<div><strong>Teaching Style Rating:</strong>';
print theme('fivestar_static', $teaching_style_rating[0]['value'], '5');
print '</div>';
$overall_rating = ($easiness_rating[0]['value'] + $helpfulness_rating[0]['value'] + $clarity_rating[0]['value'] + $teaching_style_rating[0]['value']) / 4;
print '<div><strong>Overall Rating:</strong>';
print theme('fivestar_static', $overall_rating, '5');
print '</div>';
?>