diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 9eef2c48f..c4eaeee70 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -50,17 +50,18 @@ class CoursesController < ApplicationController
@syllabuses_num = Course.all.count
#@syllabus_count = all_syllabuses.count
# 我创建的课堂
- create_syllabuses = Course.where(:tea_id => @user.id)
+ #create_syllabuses = Course.where(:tea_id => @user.id)
# 我参与的课堂
- join_syllabuses = @user.courses.where("is_delete = 0 and tea_id != #{@user.id}")
- @join_syllabuses_count = join_syllabuses.where(:is_end => 0, :is_delete => 0).count
- @create_syllabuses_count = create_syllabuses.where(:is_end => 0, :is_delete => 0).count
+ #join_syllabuses = @user.courses.where("is_delete = 0 and tea_id != #{@user.id}")
+ # @join_syllabuses_count = @user.courses.not_deleted_not_end.order("updated_at desc").select{ |course| !@user.has_teacher_role(course)}.count
+ # @create_syllabuses_count = @user.courses.not_deleted_not_end.order("updated_at desc").select{ |course| @user.has_teacher_role(course)}.count
+ @my_courses_count = @user.courses.not_deleted_not_end.count
# 页面筛选的课程
if @select == "create"
- @syllabuses = create_syllabuses.where("is_end = 0 and is_delete = 0 and name like '%#{@search}%'")
+ @syllabuses = @user.courses.not_deleted_not_end.where("name like '%#{@search}%'").order("updated_at desc").select{ |course| @user.has_teacher_role(course)}
elsif @select == "join"
- @syllabuses = join_syllabuses.where("is_end = 0 and is_delete = 0 and tea_id != #{@user.id} and name like '%#{@search}%'")
+ @syllabuses = @user.courses.not_deleted_not_end.where("name like '%#{@search}%'").order("updated_at desc").select{ |course| !@user.has_teacher_role(course)}
elsif @select == "end"
# 归档的课堂
end_syllabuses = Course.where("is_end = 1 and name like '%#{@search}%'")
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 6fe639260..6d68ff08c 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -31,7 +31,7 @@ class ExerciseController < ApplicationController
exercises = exercises.where("exercise_name like '%#{@search}%'")
end
@exercises = paginateHelper exercises,15 #分页
- @left_nav_type = 8
+ @left_nav_type = 4
respond_to do |format|
format.js
format.html
@@ -172,7 +172,7 @@ class ExerciseController < ApplicationController
@exercise = Exercise.find(params[:id])
exercise_questions = @exercise.exercise_questions
@exercise_questions = paginateHelper exercise_questions, 5
- @left_nav_type = 8
+ @left_nav_type = 4
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index ccc118f54..acd042a11 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -406,10 +406,15 @@ class MessagesController < ApplicationController
def sticky_topic
(render_403; return false) unless (User.current.admin? || User.current.allowed_to?(:as_teacher, @course))
@topic.update_attributes(:sticky => @topic.sticky == 1 ? 0 : 1)
- if params[:is_board]
- redirect_to course_boards_path(@course)
- else
- redirect_to board_message_path(@topic.board_id, @topic)
+ respond_to do |format|
+ format.js
+ format.html{
+ if params[:is_board]
+ redirect_to course_boards_path(@course)
+ else
+ redirect_to board_message_path(@topic.board_id, @topic)
+ end
+ }
end
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index e627ef519..52fa12073 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -690,7 +690,7 @@ class StudentWorkController < ApplicationController
@score = student_work_score @work,User.current
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if (@homework.homework_detail_manual.comment_status == 3 || @homework.homework_detail_manual.comment_status == 4) && !@is_teacher && @work.user != User.current
- @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc")
+ @student_work_scores = StudentWorksScore.where(:id => @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").select("max(id)"))
else
@student_work_scores = student_work_score_record(@work)
end
@@ -995,7 +995,9 @@ class StudentWorkController < ApplicationController
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
@score = @new_score
if @homework.homework_detail_manual.comment_status == 3 && !@is_teacher && @work.user != User.current
- @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc")
+ @st_cover = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").count > 1 ? 1 : 0
+ @student_work_scores = StudentWorksScore.where(:id => @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").select("max(id)"))
+ #@student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc")
else
@student_work_scores = student_work_score_record(@work)
end
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 21acbdcb2..1a19f3180 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -12,6 +12,15 @@ module CoursesHelper
#AllPeople = StudentRoles+TeacherRoles
## return people count
+ def student_course_homework_score course, user
+ homework_ids = course.homework_commons.where("homework_type in (1, 4) and publish_time < '#{Time.now}'").map(&:id)
+ score = 0
+ user.student_works.where(:homework_common_id => homework_ids).each do |work|
+ score = score + work.work_score if work.work_score
+ end
+ format("%.1f",score)
+ end
+
# 学生的发布资源数
def student_course_resource_num course, user
num = course.attachments.where(:author_id => user.id).count
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index 9b3c17a95..4cdcc2ea3 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -140,13 +140,13 @@ module StudentWorkHelper
end
end
- #获取学生作品的评分记录:同一个教师或教辅只显示未隐藏的评分
+ #获取学生作品的评分记录:同一个教师或教辅只显示未隐藏的评分、匿评多次评分只取最新一条
def student_work_score_record work
- # sql = "SELECT MAX(id) id FROM student_works_scores WHERE (reviewer_role = 2 OR reviewer_role = 1) AND score IS NOT NULL AND is_hidden = 0 AND student_work_id = #{work.id} GROUP BY user_id"
- # tea_ts_ids = StudentWorksScore.find_by_sql sql
- # tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
- # scores = work.student_works_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
- scores = work.student_works_scores.where(:is_hidden => false).order("created_at desc")
+ sql = "SELECT MAX(id) id FROM student_works_scores WHERE reviewer_role = 3 AND score IS NOT NULL AND is_hidden = 0 AND student_work_id = #{work.id} GROUP BY user_id"
+ st_ts_ids = StudentWorksScore.find_by_sql sql
+ st_ts_ids = st_ts_ids.empty? ? "(-1)" : "(" + st_ts_ids.map{|tea| tea.id}.join(",") + ")"
+ scores = work.student_works_scores.where("is_hidden = 0 and(reviewer_role = 1 or reviewer_role = 2 or id in #{st_ts_ids})").order("updated_at desc")
+ #scores = work.student_works_scores.where(:is_hidden => false).order("created_at desc")
return scores
end
diff --git a/app/views/courses/_course_activity_content.html.erb b/app/views/courses/_course_activity_content.html.erb
index 5b7d02b73..87d5c9252 100644
--- a/app/views/courses/_course_activity_content.html.erb
+++ b/app/views/courses/_course_activity_content.html.erb
@@ -32,7 +32,7 @@
<%= link_to '实训作业'.html_safe, shixuns_homework_common_index_path(:course => @course.id),:class => "color-grey", :remote => true %>
- 试 卷
+ <%= link_to '试 卷'.html_safe, new_exercise_path(:course_id => @course.id),:class => "color-grey" %>
资 源
diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb
index fe996262a..123447588 100644
--- a/app/views/courses/index.html.erb
+++ b/app/views/courses/index.html.erb
@@ -15,7 +15,7 @@
- <%= @syllabuses_num %>
全部
- - <%= @create_syllabuses_count + @join_syllabuses_count %>
我的课堂
+ - <%= @my_courses_count %>
我的课堂
<%= link_to "+ 新建".html_safe, new_course_path, :class => "fr font-16 white-btn orange-btn mt10" %>
<%= link_to "+ 加入课堂".html_safe, join_private_courses_courses_path, :remote => true, :method => "post", :class => "fr mr30 font-16 white-btn orange-btn mt10" %>
diff --git a/app/views/courses/settings/_student_table.html.erb b/app/views/courses/settings/_student_table.html.erb
index a822f7de7..3248e4616 100644
--- a/app/views/courses/settings/_student_table.html.erb
+++ b/app/views/courses/settings/_student_table.html.erb
@@ -41,7 +41,7 @@
<%= link_to user.show_real_name, user_path(user), :class => 'edu-txt-w140 task-hide mt5 alink-name', :target => '_blank' %> |
<%= user.user_extensions ? user.user_extensions.student_id : '' %> |
<%= member.course_group_id == 0 ? '未分班' : member.course_group.name %> |
- <%#= student_course_resource_num @course, user %> |
+ <%= student_course_homework_score @course, user %> |
<%= student_course_resource_num @course, user %> |
<%= student_course_message_num @course, user %> |
<%= student_course_reply_num @course, user %> |
diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb
index d06dc69dc..8b9ff2b83 100644
--- a/app/views/exercise/_exercise_student.html.erb
+++ b/app/views/exercise/_exercise_student.html.erb
@@ -59,7 +59,7 @@
<%= format_time @exercise_user.start_at %> 开始答题
- <% unless @exercise.try(:exercise_description).nil? %>
+ <% if !@exercise.try(:exercise_description).nil? && @exercise.try(:exercise_description) != "" %>
<%= @exercise.try(:exercise_description).html_safe%>
@@ -76,6 +76,8 @@
<% if @exercise.question_random == 1 %>
<% question_list = @exercise.exercise_questions.shuffle %>
+ <% else %>
+ <% question_list = @exercise.exercise_questions %>
<% end %>
diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb
index cbfa08564..79ade0035 100644
--- a/app/views/exercise/_exercise_student_result.html.erb
+++ b/app/views/exercise/_exercise_student_result.html.erb
@@ -26,7 +26,7 @@
<%= link_to "返回", student_exercise_list_exercise_path(@exercise), :class => "fr font-12 mr15 mt3 color-grey" %>
-<% unless @exercise.try(:exercise_description).nil? %>
+ <% if !@exercise.try(:exercise_description).nil? && @exercise.try(:exercise_description) != "" %>
<%= @exercise.try(:exercise_description).html_safe%>
@@ -179,6 +179,7 @@
var spn_class = dataObj.score == 0 ? 'color-red' : 'color-light-green'
$("#multi_q_score_"+id).html(""+dataObj.score+ "分");
$("#exercise_user_score").html(dataObj.total_score);
+ $("#ex_comment_status_"+id).removeClass("post_btn_grey").addClass("post_btn_white");
$("#ajax_notice_p").html("分数已保存");
$("#ajax-notice").css('top', $(window).scrollTop()+400);
$("#ajax-notice").show();
diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb
index cadda3248..4013d1c29 100644
--- a/app/views/homework_common/_homework_index_list.html.erb
+++ b/app/views/homework_common/_homework_index_list.html.erb
@@ -36,10 +36,12 @@
<%= link_to had_uncommit_studentwork_count(homework_common), student_work_index_path(:homework => homework_common.id, :tab => 2, :status => ['0']), :class => 'color-orange03 mr5', :target => '_blank' %>
未交
-
- <%= link_to had_unevaluate_count(homework_common), student_work_index_path(:homework => homework_common.id, :tab => 2, :comment => ['0']), :class => 'color-orange03 mr5', :target => '_blank' %>
- 未评
-
+ <% if homework_common.homework_type != 4 %>
+
+ <%= link_to had_unevaluate_count(homework_common), student_work_index_path(:homework => homework_common.id, :tab => 2, :comment => ['0']), :class => 'color-orange03 mr5', :target => '_blank' %>
+ 未评
+
+ <% end %>
<% else %>
<%= link_to had_commit_studentwork_count(homework_common), student_work_index_path(:homework => homework_common.id, :tab => 2), :class => 'color-orange03 mr5', :target => '_blank' %>
diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb
index 893fb84cf..18fce614e 100644
--- a/app/views/layouts/_course_base_info.html.erb
+++ b/app/views/layouts/_course_base_info.html.erb
@@ -101,7 +101,9 @@
- 恢复邀请码
<% end %>
- <%= link_to "设置", {:controller => 'courses', :action => 'settings', :id => @course} %>
- - 删除
+ <% if User.current == @course.teacher || User.current.admin? %>
+ - 删除
+ <% end %>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 6d3e385f0..9ed00f231 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -117,7 +117,7 @@
<%#= link_to( "+", new_board_message_path(:board_id => course_board.id), :class => 'fr mr15 font-18 link-color-grey', :title => "#{l(:label_message_new)}") if User.current.logged? %>
<% count = User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count %>
-
+
试卷
<%= count %>
<%#= link_to( "+", new_exercise_path(:course_id => @course.id), :class => 'fr mr15 font-18 link-color-grey', :title =>"新建试卷") if is_teacher %>
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb
index e2a125e0b..d3493ee30 100644
--- a/app/views/messages/_course_show.html.erb
+++ b/app/views/messages/_course_show.html.erb
@@ -37,7 +37,6 @@
<% if User.current.admin? || User.current.allowed_to?(:as_teacher, @course) %>
<% end %>
-
<% if User.current.admin? || User.current.allowed_to?(:as_teacher, @course) || User.current == @topic.author %>
diff --git a/app/views/messages/sticky_topic.js.erb b/app/views/messages/sticky_topic.js.erb
new file mode 100644
index 000000000..936731f48
--- /dev/null
+++ b/app/views/messages/sticky_topic.js.erb
@@ -0,0 +1 @@
+$("#user_activity_<%= params[:user_activity_id]%>").replaceWith("<%= j(render :partial => 'users/course_message', :locals => {:activity => @topic, :user_activity_id => params[:user_activity_id],:is_course=>1,:is_board=>0}) %>");
\ No newline at end of file
diff --git a/app/views/shixuns/_add_collaborators.html.erb b/app/views/shixuns/_add_collaborators.html.erb
index 44fb5419f..c9bd4543c 100644
--- a/app/views/shixuns/_add_collaborators.html.erb
+++ b/app/views/shixuns/_add_collaborators.html.erb
@@ -18,7 +18,7 @@
diff --git a/app/views/shixuns/_add_collaborators_list.html.erb b/app/views/shixuns/_add_collaborators_list.html.erb
index e219ceb7a..71fab81e4 100644
--- a/app/views/shixuns/_add_collaborators_list.html.erb
+++ b/app/views/shixuns/_add_collaborators_list.html.erb
@@ -8,7 +8,7 @@
diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb
index 049e0cf3d..21a89fbc5 100644
--- a/app/views/student_work/add_score.js.erb
+++ b/app/views/student_work/add_score.js.erb
@@ -1,3 +1,3 @@
$("#student_work_score_div").html("<%= escape_javascript(render :partial => 'student_work/student_work_score_div') %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
-notice_box("提交成功");
+notice_box("<%= (@st_cover && @st_cover == 1) ? '评分已更新' : '提交成功' %>");
diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb
index 4293c48ec..6f6e2511d 100644
--- a/app/views/student_work/index.html.erb
+++ b/app/views/student_work/index.html.erb
@@ -234,17 +234,19 @@
-
- 你的评阅:
-
-
-
- <% has_comment = User.current.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).count %>
- >
-
- >
-
-
+ <% if @homework.homework_type != 4 %>
+
+ 你的评阅:
+
+
+
+ <% has_comment = User.current.student_works_scores.where(:student_work_id => @homework.student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).count %>
+ >
+
+ >
+
+
+ <% end %>
作品状态:
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index 6a00131b2..9e798a956 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -52,21 +52,16 @@
-
- <% if activity.author.id == User.current.id%>
- -
- <%= link_to(
- l(:button_edit),
- edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
- :class => 'postOptionLink'
- ) if activity.course_editable_by?(User.current) %>
-
- <% if activity.course_destroyable_by?(User.current) %>
- -
- 删除
-
- <% end %>
+ - 发 送
+ <% if User.current.admin? || User.current.allowed_to?(:as_teacher, @course) %>
+ - <%= activity.sticky == 1 ? '取消置顶' : '置 顶'.html_safe %>
+ <% end %>
+ <% if User.current.admin? || User.current.allowed_to?(:as_teacher, @course) || User.current == activity.author %>
+ - 编 辑
+ -
+ 删 除
+
<% end %>
- - <%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %>
diff --git a/public/javascripts/edu/homework.js b/public/javascripts/edu/homework.js
index 227c28b99..7d28bd571 100644
--- a/public/javascripts/edu/homework.js
+++ b/public/javascripts/edu/homework.js
@@ -346,5 +346,6 @@ function new_shixun_homework(id){
var type=$("input[name='shixun_homework']:checked").val();
console.log(type);
$("#shixun_homework_common_new").submit();
+ hideModal();
}
}
diff --git a/public/stylesheets/css/edu-common.css b/public/stylesheets/css/edu-common.css
index 4bf7c1872..30b12ad56 100644
--- a/public/stylesheets/css/edu-common.css
+++ b/public/stylesheets/css/edu-common.css
@@ -242,6 +242,7 @@ a.edu-txt-w130,.edu-txt-w130{ width:130px; display: inline-block;text-align: cen
a.edu-txt-w120,.edu-txt-w120{ width:120px; display: inline-block;text-align: center}
a.edu-txt-w100,.edu-txt-w100{ width:100px; display: inline-block;text-align: center}
a.edu-txt-w90,.edu-txt-w90{ width:90px; display: inline-block;text-align: center}
+a.edu-txt-w80,.edu-txt-w80{ width:80px; display: inline-block;text-align: center}
.edu-txt-w50{ width:50px;}
.edu-w245{ width: 245px; }
.overellipsis{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}