<% unless @students.empty? %>
<% unless @designations.blank? %>
<% @designations.each do|designation| %>
<%= designation.name %>
<% designated_students = [] %>
<% @students.each do|student| %>
<% marks = GroupedExamReport.find_all_by_student_id_and_score_type(student.id,"c") %>
<% unless marks.empty? %>
<% total = marks.map{|m| m.marks} %>
<% avg = (total.sum.to_f)/(total.count.to_f) %>
<% if @batch.gpa_enabled? %>
<% classes = ClassDesignation.find(:all,:conditions=>["cgpa <= ? AND course_id = ?",avg,student.batch.course_id],:order=>"cgpa DESC") %>
<% else %>
<% classes = ClassDesignation.find(:all,:conditions=>["marks <= ? AND course_id = ?",avg,student.batch.course_id],:order=>"marks DESC") %>
<% end %>
<% unless classes.empty? %>
<% if classes.first.id == designation.id %>
<% designated_students << [student,avg] %>
<% end %>
<% end %>
<% end %>
<% end %>
<% c= 'even' %>
<% unless designated_students.empty? %>
<% designated_students.each_with_index do|s,i| %>
<% if (i+1)%(page_val.to_i) == 0 %>
<% end %>
">
<% st = s[0] %>
<%= i+1 %> |
<%= st.admission_no.present? ? st.admission_no : "-" %> |
<%= st.full_name %> |
<%= "%.2f" %(s[1].to_f) %> |
<%# ind=ind+1 %>
<% end %>
<% else %>
<% end %>
<% end %>
<% end %>
<% unless @levels.blank? %>
<% @levels.each do|level| %>
<%= level.name %> <%= t('students') %>
<% unless level.subject_count.nil? %>
<% scores = GroupedExamReport.find(:all,:conditions=>{:student_id=>@students.collect(&:id),:score_type=>"s"}) %>
<% else %>
<% scores = GroupedExamReport.find(:all,:conditions=>{:student_id=>@students.collect(&:id),:score_type=>"c"}) %>
<% end %>
<% if level.marks_limit_type=="upper" %>
<% scores.reject!{|s| !(((s.marks < level.gpa unless level.gpa.nil?) if s.student.batch.gpa_enabled?) or (s.marks < level.marks unless level.marks.nil?))} %>
<% elsif level.marks_limit_type=="exact" %>
<% scores.reject!{|s| !(((s.marks == level.gpa unless level.gpa.nil?) if s.student.batch.gpa_enabled?) or (s.marks == level.marks unless level.marks.nil?))} %>
<% else %>
<% scores.reject!{|s| !(((s.marks >= level.gpa unless level.gpa.nil?) if s.student.batch.gpa_enabled?) or (s.marks >= level.marks unless level.marks.nil?))} %>
<% end %>
<% ranked_students =[] %>
<% unless scores.empty? %>
<% unless level.subject_count.nil? %>
<% sub_count = level.subject_count %>
<% @students.each do|student| %>
<% student_scores = scores.dup %>
<% student_scores.reject!{|s| !(s.student_id==student.id)} %>
<% batch_ids = student_scores.collect(&:batch_id) %>
<% batch_ids.each do|batch_id|%>
<% unless batch_ids.empty? %>
<% count = batch_ids.count(batch_id) %>
<% if level.subject_limit_type=="upper" %>
<% if count < sub_count %>
<% flag=0 %>
<% ranked_students.each do|r| %>
<% if r[0]==student.id %>
<% r[1] << batch_id %>
<% flag=1 %>
<% end %>
<% end %>
<% unless flag==1 %>
<% unless student.has_higher_priority_ranking_level(level.id,"course","") %>
<% ranked_students << [student.id,[batch_id]] %>
<% end %>
<% end %>
<% end %>
<% elsif level.subject_limit_type=="exact" %>
<% if count == sub_count %>
<% flag=0 %>
<% ranked_students.each do|r| %>
<% if r[0]==student.id %>
<% r[1] << batch_id %>
<% flag=1 %>
<% end %>
<% end %>
<% unless flag==1 %>
<% unless student.has_higher_priority_ranking_level(level.id,"course","") %>
<% ranked_students << [student.id,[batch_id]] %>
<% end %>
<% end %>
<% end %>
<% else %>
<% if count >= sub_count %>
<% flag=0 %>
<% ranked_students.each do|r| %>
<% if r[0]==student.id %>
<% r[1] << batch_id %>
<% flag=1 %>
<% end %>
<% end %>
<% unless flag==1 %>
<% unless student.has_higher_priority_ranking_level(level.id,"course","") %>
<% ranked_students << [student.id,[batch_id]] %>
<% end %>
<% end %>
<% end %>
<% end %>
<% batch_ids.delete(batch_id) %>
<% end %>
<% end %>
<% end %>
<% else %>
<% scores.each do|score| %>
<% flag=0 %>
<% ranked_students.each do|r| %>
<% if r[0]==score.student_id %>
<% r[1] << score.batch_id %>
<% flag=1 %>
<% end %>
<% end %>
<% unless flag==1 %>
<% unless score.student.has_higher_priority_ranking_level(level.id,"course","") %>
<% ranked_students << [score.student_id,[score.batch_id]] %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% c= 'even' %>
<% unless ranked_students.empty? %>
<% ranked_students.each_with_index do|r,indx| %>
<% if (indx+1)%(page_val.to_i) == 0 %>
<%#*
%>
<%#*
%>
<% end %>
">
<% stu = Student.find(r[0]) %>
<% marks = GroupedExamReport.find_all_by_student_id_and_score_type(stu.id,"c") %>
<% unless marks.empty? %>
<% total = marks.map{|m| m.marks} %>
<% avg = (total.sum.to_f)/(total.count.to_f) %>
<% end %>
<%= indx+1 %> |
<%= stu.admission_no.present? ? stu.admission_no : "-" %> |
<%= stu.full_name %> |
<%= avg.present? ? "%.2f" %(avg) : "-" %> |
<% batches = r[1] %>
<%= Batch.find_all_by_id(batches).collect(&:full_name).join(", ") %>
|
<%# ind=ind+1 %>
<% end %>
<% else %>
<% end %>
<% end %>
<% end %>
<% end %>