personal-course/app/controllers/personal_courses_controller.rb

48 lines
1.5 KiB
Ruby
Raw Normal View History

2015-12-29 11:35:44 +00:00
class PersonalCoursesController < ApplicationController
def index
courses = Course.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
courses_list = courses.collect do |course|
{
"year" => course.year,
"title" => course.title,
"category" => course.course_category.title,
"semester" => course.course_semester.title,
"authors" => (course.member_profile.name rescue ""),
"link_to_show" => OrbitHelper.url_to_show(course.to_param)
}
end
{
"courses" => courses_list,
"extras" => {
"widget-title" => t("module_name.personal_course"),
"th_year" => t('personal_course.year'),
"th_course_title" => t("personal_course.title"),
"th_course_category" => t("personal_course.course_category"),
"th_course_semester" => t("personal_course.course_semester"),
"th_authors" => t('users.name')
},
"total_pages" => courses.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Course.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"course_category",
"title",
"objective",
"course_semester",
"course_syllabus_file",
"course_progress_file",
"course_activity_file",
"course_multimedia_file",
"course_material_file",
"course_supplement_file",
"course_evaluation_file"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end