Class: EffortReportsController::SemesterPanel

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/effort_reports_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#course_idObject

Returns the value of attribute course_id.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def course_id
  @course_id
end

#graduation_yearObject

Returns the value of attribute graduation_year.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def graduation_year
  @graduation_year
end

#is_part_timeObject

Returns the value of attribute is_part_time.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def is_part_time
  @is_part_time
end

#person_idObject

Returns the value of attribute person_id.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def person_id
  @person_id
end

#programObject

Returns the value of attribute program.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def program
  @program
end

#semesterObject

Returns the value of attribute semester.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def semester
  @semester
end

#trackObject

Returns the value of attribute track.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def track
  @track
end

#yearObject

Returns the value of attribute year.



11
12
13
# File 'app/controllers/effort_reports_controller.rb', line 11

def year
  @year
end

Instance Method Details

#generate_sql(just_student = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/effort_reports_controller.rb', line 13

def generate_sql(just_student = nil)

  if (self.course_id.blank?)
    sql_statement = "select distinct el.week_number, el.sum as student_effort, el.user_id "
  else
    sql_statement = "select el.week_number, e.sum as student_effort, el.user_id "
  end
  sql_statement = sql_statement + "from effort_log_line_items e, effort_logs el,courses c, users u
  where e.sum>0 and e.course_id=c.id and e.effort_log_id=el.id and el.user_id= u.id and el.year=c.year"
  sql_statement = sql_statement + " AND el.year=#{self.year}"
  sql_statement = sql_statement + " and e.course_id=#{self.course_id}" unless self.course_id.blank?
  sql_statement = sql_statement + " and c.semester='#{self.semester}'"
  sql_statement = sql_statement + " and u.graduation_year='#{self.graduation_year}'" unless self.graduation_year.blank?
  sql_statement = sql_statement + " and u.masters_program='#{self.program}'" unless self.program.blank?
  sql_statement = sql_statement + " and u.masters_track='#{self.track}'" unless self.track.blank?
  case self.is_part_time
    when "PT"
      sql_statement = sql_statement + " and u.is_part_time is true"
    when "FT"
      sql_statement = sql_statement + " and u.is_part_time is false"
  end
  sql_statement = sql_statement + " and el.user_id=#{self.person_id}" if just_student && !self.person_id.blank?

  sql_statement = sql_statement + " order by el.week_number"
  return sql_statement
end