personal-course/app/controllers/personal_courses_controller.rb

53 lines
1.7 KiB
Ruby

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 '#'
{
"year" => course.year,
"title" => course.title,
"category" => (course.course_category.title rescue ""),
"semester" => (course.course_semester.title rescue ""),
"authors" => ("<a href='#{path}'>" + member.name + "</a>"),
"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",
"course_code",
"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"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end