51 lines
2.0 KiB
Ruby
51 lines
2.0 KiB
Ruby
class HpsLearningsController < ApplicationController
|
|
def index
|
|
table_fields = ["hps_learning.course_pic", "hps_learning.title", :category, "hps_learning.runtime", "hps_learning.lectures"].collect{|x| {"head" => t(x.to_sym)}}
|
|
classes = []
|
|
HpsClass.all.desc(:created_at).each do |hpsclass|
|
|
if hpsclass.hps_lectures.count > 0
|
|
classes << {
|
|
"course_pic_thumb" => (hpsclass.course_pic.thumb.url rescue "http://www.placehold.it/150x150/EFEFEF/AAAAAA"),
|
|
"course_pic" => (hpsclass.course_pic.url rescue ""),
|
|
"title" => hpsclass.title,
|
|
"category" => hpsclass.category.title,
|
|
"runtime" => hpsclass.get_runtime,
|
|
"link_to_lectures" => OrbitHelper.url_to_show(hpsclass.to_param)
|
|
}
|
|
end
|
|
end
|
|
{
|
|
"fields" => table_fields,
|
|
"classes" => classes,
|
|
"extra" => {}
|
|
}
|
|
end
|
|
|
|
def show
|
|
params = OrbitHelper.params
|
|
request = OrbitHelper.request
|
|
hpsclass = HpsClass.where(:uid => params[:uid]).first
|
|
table_fields = ["hps_learning.lecture_pic", "hps_learning.subject", "hps_learning.presenter" , "hps_learning.runtime", "hps_learning.link_to_lecture"].collect{|x| {"head" => t(x.to_sym)}}
|
|
lectures = []
|
|
hpsclass.hps_lectures.each do |lecture|
|
|
if !lecture.hps_lecture_file.nil? && !lecture.hps_lecture_file.index_path.nil?
|
|
lectures << {
|
|
"lecture_pic_thumb" => (lecture.lecture_pic.thumb.url rescue "http://www.placehold.it/150x150/EFEFEF/AAAAAA"),
|
|
"lecture_pic" => (lecture.lecture_pic.url rescue ""),
|
|
"subject" => lecture.subject,
|
|
"presenter" => lecture.presenter,
|
|
"runtime" => lecture.get_runtime,
|
|
"link_to_lecture" => "http://#{request.host_with_port}/#{lecture.hps_lecture_file.index_path}"
|
|
}
|
|
end
|
|
end
|
|
{
|
|
"lectures" => lectures,
|
|
"fields" => table_fields,
|
|
"data" => {
|
|
"class-title" => hpsclass.title,
|
|
"view-lecture" => t("hps_learning.view_lecture")
|
|
}
|
|
}
|
|
end
|
|
end |