personal-course/app/controllers/personal_courses_controller.rb

53 lines
1.7 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|
member = course.member_profile
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
2015-12-29 11:35:44 +00:00
{
"year" => course.year,
"title" => course.title,
2015-12-29 16:33:23 +00:00
"category" => (course.course_category.title rescue ""),
"semester" => (course.course_semester.title rescue ""),
"authors" => ("<a href='#{path}'>" + member.name + "</a>"),
2015-12-29 11:35:44 +00:00
"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",
2021-02-24 03:38:05 +00:00
"course_code",
2015-12-29 11:35:44 +00:00
"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",
"students"
2015-12-29 11:35:44 +00:00
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end