%-# 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. -%>
<% unless flash[:notice].nil? %>
<%= flash[:notice] %>
<% end %>
<% unless @students.empty? %>
<%= t("students_in_batch") %>
<%= image_tag("loader.gif",:align => "absmiddle",:border => 0,:id => "loader", :style =>"display: none;" ) %>
<% @students.each do |s| %>
<% if @flag.present? %>
<% if @student.id==s.id %>
<%= link_to s.full_name, {:controller=>"exam",:action=>"student_transcript",:student_id=>s.id,:flag=>@flag,:transcript=>{:batch_id=>s.batch_id}}, :class=>"active-link" %>
<% else %>
<%= link_to s.full_name, {:controller=>"exam",:action=>"student_transcript",:student_id=>s.id,:flag=>@flag,:transcript=>{:batch_id=>s.batch_id}}, :class=>"student-link" %>
<% end %>
<% else %>
<% if @student.id==s.id %>
<%= link_to s.full_name, {:controller=>"exam",:action=>"student_transcript",:student_id=>s.id,:transcript=>{:batch_id=>s.batch_id}}, :class=>"active-link" %>
<% else %>
<%= link_to s.full_name, {:controller=>"exam",:action=>"student_transcript",:student_id=>s.id,:transcript=>{:batch_id=>s.batch_id}}, :class=>"student-link" %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= t("no_students_in_batch") %>
<% end %>
<%= t('name') %> : <%= @student.full_name %>
<%= t('course_text') %> : <%= @student.batch.course.course_name %>
<%= t('adm_no') %> : <%= @student.admission_no.present? ? @student.admission_no : "-" %>
<% reports = GroupedExamReport.find_all_by_student_id_and_score_type(@student.id,'c') %>
<% if reports.empty? %>
Grouped Exam Reports have not been generated for this Student.
<% else %>
<% grades = [] %>
<% grade_type = "normal" %>
<% grade_type = "GPA" if @student.batch.gpa_enabled? %>
<% grade_type = "CWA" if @student.batch.cwa_enabled? %>
<% @batches.each do|batch| %>
<% st_mark = GroupedExamReport.find_by_batch_id_and_student_id_and_score_type(batch.id,@student.id,"c") %>
<% unless st_mark.nil? %>
<% general_subjects = Subject.find_all_by_batch_id(batch.id, :conditions=>"elective_group_id IS NULL AND is_deleted=false") %>
<% student_electives = StudentsSubject.find_all_by_student_id(@student.id,:conditions=>"batch_id = #{batch.id}") %>
<% elective_subjects = [] %>
<% student_electives.each do |elect| %>
<% elective_subjects.push Subject.find(elect.subject_id) %>
<% end %>
<% @subjects = general_subjects + elective_subjects %>
<% unless @subjects.empty? %>
<%= batch.full_name %>
<% total_credits=0 %>
<%= t('subject_code') %>
<%= t('subject_title') %>
<% if grade_type=="GPA" or grade_type=="CWA" %>
<%= t('credit') %>
<%= t('marks') %>
<% else %>
<%= t('percentage') %>(%)
<% end %>
<% @subjects.each do |s| %>
<% subject_average = GroupedExamReport.find_by_student_id_and_subject_id_and_score_type(@student.id,s.id,"s") %>
<% unless subject_average.nil? %>
<% if @student.has_retaken_exam(s.id) %>
<%= s.code %> - <%= t('retaken') %>
<% else %>
<%= s.code %>
<% end %>
<%= s.name %>
<% if grade_type=="GPA" or grade_type=="CWA" %>
<%= s.credit_hours %>
<% total_credits = total_credits + s.credit_hours.to_f %>
<% end %>
<%= subject_average.present? ? subject_average.marks : "-" %>
<% end %>
<% end %>
<% if grade_type=="GPA" or grade_type=="CWA" %>
<%= t('total') %>
<%= total_credits %>
-
<% end %>
<% unless st_mark.nil? %>
<% mark = st_mark.marks || 0 %>
<% else %>
<% mark=0 %>
<% end %>
<% grades << mark %>
<% if grade_type=="CWA" %>
<%= t('combined_weighted_average') %> = <%= mark==0 ? "-" : mark %>
<% elsif grade_type=="GPA" %>
<%= t('batch_wise_cumulative_grade_point_average') %> = <%= mark==0 ? "-" : mark %>
<% else %>
<%= t('combined_percentage') %> = <%= mark==0 ? "-" : mark %>
<% end %>
<% end %>
<% end %>
<% end %>
<% unless grades.count.to_f==0 %>
<% cgpa = (grades.sum.to_f)/(grades.count.to_f) %>
<% else %>
<% cgpa=0 %>
<% end %>
<% if grade_type=="GPA" %>
<% designations = ClassDesignation.find(:all,:conditions=>["cgpa <= ? AND course_id = ? ",cgpa,@student.batch.course_id],:order=>"cgpa DESC") %>
<%= t('course_wise_cumulative_grade_point') %> = <%= "%.2f" %(cgpa) %>
<% else %>
<% designations = ClassDesignation.find(:all,:conditions=>["marks <= ? AND course_id = ?",cgpa,@student.batch.course_id],:order=>"marks DESC") %>
<% if grade_type=="CWA" %>
<%= t('course_wise_combined_weighted_average') %> = <%= "%.2f" %(cgpa) %>
<% else %>
<%= t('course_wise_combined_percentage') %>= <%= "%.2f" %(cgpa) %>
<% end %>
<% end %>
<%= t('class_designations_text') %> : <%= designations.empty? ? "-" : designations.first.name %>
<% end %>