diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a44b58789..25536615a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -395,4 +395,74 @@ class AdminController < ApplicationController end + #留言列表 + def leave_messages + @jour = JournalsForMessage.where("jour_type = 'Principal' or jour_type = 'Course'").reorder('created_on desc') + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 30}) + else + @limit = 30#per_page_option + end + + @jour_count = @jour.count + @jour_pages = Paginator.new @jour_count, @limit, params['page'] + @offset ||= @jour_pages.offset + @jour = @jour.limit(@limit).offset(@offset).all + + respond_to do |format| + format.html + end + end + + #帖子 + def messages_list + @memo = Memo.reorder("created_at desc") + +=begin + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 30}) + else + @limit = 30#per_page_option + end + + @memo_count = @memo.count + @memo_pages = Paginator.new @memo_count, @limit, params['page'] + @offset ||= @memo_pages.offset + @memo = @memo.limit(@limit).offset(@offset).all +=end + + respond_to do |format| + format.html + end + end + + #课程讨论区的帖子 + def course_messages + #@boards=Board.where('course_id is NULL') + #@course_ms = Message.reorder('created_on desc') + @course_ms=Message.joins("join boards on messages.board_id=boards.id where boards.course_id is not NULL").reorder('created_on desc') + end + + #项目讨论区的帖子 + def project_messages + @project_ms=Message.joins("join boards on messages.board_id=boards.id where boards.project_id != -1").reorder('created_on desc') + end + + #通知 + def notices + @news = News.where('course_id is not NULL').order('created_on desc') + end + + #最近登录用户列表 + def latest_login_users + @user = User.order('last_login_on desc') + end + + #作业 + def homework + @homework = HomeworkCommon.order('end_time desc') + end + end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 21f781a1a..87c1e288b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -19,28 +19,28 @@ class HomeworkCommonController < ApplicationController end def new - # @homework_type = "1" - # - # @homework = HomeworkCommon.new - # @homework.safe_attributes = params[:homework_common] - # @homework.late_penalty = 2 - # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.publish_time = Time.now.strftime('%Y-%m-%d') - # - # if @homework_type == "1" - # #匿评作业相关属性 - # @homework_detail_manual = HomeworkDetailManual.new - # @homework_detail_manual.ta_proportion = 0.6 - # @homework_detail_manual.absence_penalty = 2 - # @homework_detail_manual.evaluation_num = 3 - # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') - # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.homework_detail_manual = @homework_detail_manual - # elsif @homework_type == "2" - # #编程作业相关属性 - # @homework_detail_programing = HomeworkDetailPrograming.new - # @homework.homework_detail_programing = @homework_detail_programing - # end + @homework_type = "1" + + @homework = HomeworkCommon.new + @homework.safe_attributes = params[:homework_common] + @homework.late_penalty = 2 + @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.publish_time = Time.now.strftime('%Y-%m-%d') + + if @homework_type == "1" + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 2 + @homework_detail_manual.evaluation_num = 3 + @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') + @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.homework_detail_manual = @homework_detail_manual + elsif @homework_type == "2" + #编程作业相关属性 + @homework_detail_programing = HomeworkDetailPrograming.new + @homework.homework_detail_programing = @homework_detail_programing + end respond_to do |format| format.html end diff --git a/app/views/admin/_tab_messages.erb b/app/views/admin/_tab_messages.erb new file mode 100644 index 000000000..ec04246ba --- /dev/null +++ b/app/views/admin/_tab_messages.erb @@ -0,0 +1,8 @@ +
+ +
\ No newline at end of file diff --git a/app/views/admin/course_messages.html.erb b/app/views/admin/course_messages.html.erb new file mode 100644 index 000000000..8564d13dc --- /dev/null +++ b/app/views/admin/course_messages.html.erb @@ -0,0 +1,66 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_borad_course) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for course in @course_ms -%> + + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= Board.where('id=?',course.board_id).first.course_id %> + <%= course.try(:author)%><% else %><%=course.try(:author).try(:realname) %><% end %>'> + <% if course.try(:author).try(:realname) == ' '%> + <%= link_to(course.try(:author), user_path(course.author)) %> + <% else %> + <%= link_to(course.try(:author).try(:realname), user_path(course.author)) %> + <% end %> + + <%= format_date(course.created_on) %> + + <%= course.subject %> + + <%=course.replies_count %> +
+
+ +<% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb new file mode 100644 index 000000000..360ca4e39 --- /dev/null +++ b/app/views/admin/homework.html.erb @@ -0,0 +1,62 @@ +

+ <%=l(:label_user_homework)%> +

+ +
+ + + + + + + + + + + + + <%@count=0 %> + <% for homework in @homework do %> + <% @count+=1 %> + + + + + + + + + <% end %> + +
+ 序号 + + 作业名称 + + 课程名称 + + 作者 + + 提交作品数 + + 提交截止日期 +
+ <%=@count %> + + <%=link_to(homework.name, student_work_index_path(:homework => homework.id))%> + + <%= link_to(homework.course.name, course_path(homework.course.id)) %> + <%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'> + <% if homework.try(:user).try(:realname) == ' '%> + <%= link_to(homework.try(:user), user_path(homework.user_id)) %> + <% else %> + <%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %> + <% end %> + + <%=StudentWork.where('homework_common_id=?',homework.id).count %> + + <%=format_date(homework.end_time) %> +
+
+ +<% html_title(l(:label_user_homework)) -%> diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb new file mode 100644 index 000000000..dc35daec8 --- /dev/null +++ b/app/views/admin/latest_login_users.html.erb @@ -0,0 +1,73 @@ +

+ <%=l(:label_latest_login_user_list)%> +

+ +
+ + + + + + + + + + + + + <% @count=0 %> + <% for user in @user do %> + + <% @count +=1 %> + + + + + + + + <% end %> + +
+ 序号 + + 登录时间 + + 用户id + + 用户姓名 + + 用户昵称 + + 用户身份 +
+ <%=@count %> + + <%=format_date(user.last_login_on) %> + + <%=user.id %> + <%= user.login%><% else %><%=user.try(:realname) %><% end %>'> + <% if user.try(:realname) == ' '%> + <%= link_to(user.login, user_path(user)) %> + <% else %> + <%= link_to(user.try(:realname), user_path(user)) %> + <% end %> + + <%=link_to(user.login, user_path(user)) %> + + <% case user.user_extensions.identity %> + <% when 0 %> + <%='老师' %> + <% when 1 %> + <%='学生' %> + <% when 2 %> + <%='企业' %> + <% when 3 %> + <%='开发者' %> + <% else %> + <%='未知身份' %> + <% end %> +
+
+ +<% html_title(l(:label_latest_login_user_list)) -%> diff --git a/app/views/admin/leave_messages.html.erb b/app/views/admin/leave_messages.html.erb new file mode 100644 index 000000000..975c60b15 --- /dev/null +++ b/app/views/admin/leave_messages.html.erb @@ -0,0 +1,79 @@ +

+ <%=l(:label_leave_message_list)%> +

+ + +
+ + + + + + + + + + + + + + <% @count=0%> + <% for journal in @jour -%> + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 类型 + + 来源 + + 留言人 + + 留言时间 + + 留言内容 + + 回复数 +
+ <%= @count %> + + <%case journal.jour_type %> + <% when 'Principal' %> + <%='用户主页' %> + <% when 'Course' %> + <%='课程' %> + <% end %> + + <%= journal.jour_id %> + + <%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %> + + <%= format_date(journal.created_on) %> + + <%= journal.notes.truncate(15, omission: '...') %> + + <% if(journal.m_reply_count) %> + <%=journal.m_reply_count%> + <% else %> + <%=0 %> + <% end %> +
+
+ + +<% html_title(l(:label_leave_message_list)) -%> diff --git a/app/views/admin/messages_list.html.erb b/app/views/admin/messages_list.html.erb new file mode 100644 index 000000000..77cdbbc69 --- /dev/null +++ b/app/views/admin/messages_list.html.erb @@ -0,0 +1,69 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_forum) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for memo in @memo -%> + <% @count=@count + 1 %> + "> + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= memo.forum_id %> + <%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'> + <% if memo.try(:author).try(:realname) == ' '%> + <%= link_to(memo.try(:author), user_path(memo.author)) %> + <% else %> + <%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %> + <% end %> + + <%= format_date(memo.created_at) %> + + <%= memo.subject %> + + <%=memo.replies_count %> +
+
+ + +<% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/notices.html.erb b/app/views/admin/notices.html.erb new file mode 100644 index 000000000..56f212720 --- /dev/null +++ b/app/views/admin/notices.html.erb @@ -0,0 +1,74 @@ +

+ <%=l(:label_notification_list)%> +

+ +
+ + + + + + + + + + + + + + + <% @count=0%> + <% for news in @news -%> + <% @count=@count + 1 %> + "> + + + + + + + + + + <% end %> + +
+ 序号 + + 课程id + + 课程名称 + + 主讲老师 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%=news.course_id %> + + <%=link_to(news.course.name, course_path(news.course)) %> + + <%=link_to(news.course.try(:teacher).try(:realname), user_path(news.course.teacher)) %> + <%= news.try(:author)%><% else %><%=news.try(:author).try(:realname) %><% end %>'> + <% if news.try(:author).try(:realname) == ' '%> + <%= link_to(news.try(:author), user_path(news.author)) %> + <% else %> + <%= link_to(news.try(:author).try(:realname), user_path(news.author)) %> + <% end %> + + <%= format_date(news.created_on) %> + + <%= link_to(news.title, news_path(news)) %> + + <%=news.comments_count %> +
+
+ +<% html_title(l(:label_notification_list)) -%> diff --git a/app/views/admin/project_messages.html.erb b/app/views/admin/project_messages.html.erb new file mode 100644 index 000000000..af2978422 --- /dev/null +++ b/app/views/admin/project_messages.html.erb @@ -0,0 +1,66 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_borad_project) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for project in @project_ms -%> + + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= Board.where('id=?',project.board_id).first.project_id %> + <%= project.try(:author)%><% else %><%=project.try(:author).try(:realname) %><% end %>'> + <% if project.try(:author).try(:realname) == ' '%> + <%= link_to(project.try(:author), user_path(project.author)) %> + <% else %> + <%= link_to(project.try(:author).try(:realname), user_path(project.author)) %> + <% end %> + + <%= format_date(project.created_on) %> + + <%= project.subject %> + + <%=project.replies_count %> +
+
+ +<% html_title(l(:label_message_plural)) -%> diff --git a/app/views/boards/_form.html.erb b/app/views/boards/_form.html.erb index 47ae0672d..a4f58dcc3 100644 --- a/app/views/boards/_form.html.erb +++ b/app/views/boards/_form.html.erb @@ -1,7 +1,7 @@ <%= error_messages_for @board %>
-

+

<%= f.text_field :name, :required => true %>

diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 5520f526d..609294161 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,12 +1,5 @@