<%-# Fedena #Copyright 2010 Foradian Technologies Private Limited # #This product includes software developed at #Project Fedena - http://www.projectfedena.org/ # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. #You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #Unless required by applicable law or agreed to in writing, #software distributed under the License is distributed on an #"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY #KIND, either express or implied. See the License for the #specific language governing permissions and limitations #under the License. -%>
<%= image_tag("/images/examination/show_exam.png") %>

<%= t('exams_text') %>

<%= t('combined_report') %>

<%= link_to_function image_tag("/images/buttons/back.png",:border => 0), "history.back()" %>
<% unless flash[:notice].nil? %>

<%= flash[:notice] %>

<% end %>

<%= @batch.full_name %>

<% 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 %> <% unless designated_students.empty? %> <% if @batch.cwa_enabled? %> <% elsif @batch.gpa_enabled? %> <% else %> <% end %> <% designated_students.each_with_index do|s,i| %> <% st = s[0] %> <% end %> <% else %> <% end %>
<%= t('sl_no') %> <%= t('adm_no') %> <%= t('name') %><%= t('cwa') %><%= t('cgpa') %><%= t('percentage') %>
<%= i+1 %> <%= st.admission_no.present? ? st.admission_no : "-" %> <%= st.full_name %> <%= "%.2f" %(s[1].to_f) %>
<%= t('no_students_for_this_class_designation') %>
<% 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 %> <% unless ranked_students.empty? %> <% if @batch.cwa_enabled? %> <% elsif @batch.gpa_enabled? %> <% else %> <% end %> <% ranked_students.each_with_index do|r,ind| %> <% 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 %> <% end %> <% else %> <% end %>
<%= t('sl_no') %> <%= t('adm_no') %> <%= t('name') %><%= t('cwa') %><%= t('cgpa') %><%= t('percentage') %><%= t('courses_text') %> <%= level.name %>
<%= ind+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(", ") %>
<%= t('no_students_for_this_ranking_level') %>
<% end %> <% end %> <% end %>