From 38a912672af4bfd23094191c45233daa3f50b65d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 1 Dec 2014 11:15:03 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=89=8B=E5=86=99=E8=AF=84=E5=88=86?= =?UTF-8?q?=E7=9B=B8=E5=85=B3js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 8 ++--- app/views/homework_attach/_show.html.erb | 31 +++++++++++------- app/views/homework_attach/_show_star.html.erb | 22 ++++--------- app/views/homework_attach/show.js.erb | 2 +- public/images/bid/star.png | Bin 0 -> 1601 bytes public/stylesheets/css.css | 3 +- 6 files changed, 30 insertions(+), 36 deletions(-) create mode 100644 public/images/bid/star.png diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index ff6463036..dacf897da 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -393,17 +393,15 @@ class HomeworkAttachController < ApplicationController unless annymous_users.nil? || annymous_users.count == 0 @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") end - @totle_score = score_for_homework @homework - @teaher_score = teacher_score_for_homework @homework + #@totle_score = score_for_homework @homework + #@teaher_score = teacher_score_for_homework @homework is_student = is_cur_course_student @homework.bid.courses.first is_teacher = is_course_teacher User.current,@homework.bid.courses.first @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 if !User.current.member_of_course?(@homework.bid.courses.first) @is_comprehensive_evaluation = 3 #留言 - elsif is_student && @is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 - @is_comprehensive_evaluation = 2 #匿评 - elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 + elsif is_student && @is_anonymous_comments#是学生且开启了匿评 @is_comprehensive_evaluation = 2 #匿评 elsif is_student && !@is_anonymous_comments #是学生未开启匿评 @is_comprehensive_evaluation = 3 #留言 diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index bf797e441..416ca4f66 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -36,17 +36,18 @@ this.relatedElement.className = ''; this.relatedElement.firstChild.nodeValue = currentLength; } - function test(){alert('test');} - //中的onmouseover 改成 onclick; - //]]> + function g(o){return document.getElementById(o);} + function HoverLi(n){ + for(var i=3;i<=5;i++){g('ping_tb_'+i).className='ping_normaltab';g('tbc_0'+i).className='ping_undis';}g('tbc_0'+n).className='ping_dis';g('ping_tb_'+n).className='ping_hovertab'; + } + + function ChoseStars(num) + { + for (var i = num + 1; i <= 5; i++) {$("#star0" + i).css("background-position","-2px 0");} + for (var i = num; i >= 0; i--) {$("#star0" + i).css("background-position","-24px 0px");} + $("#stars_value").val(num); + } -<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>

<%= @homework.name %>

@@ -113,8 +114,14 @@

- <%= render :partial => 'show_star',:locals => {:is_comprehensive_evaluation => @is_comprehensive_evaluation,:totle_score => @totle_score,:has_evaluation => @has_evaluation , - :homework => @homework} %> + <% if @is_comprehensive_evaluation == 3 || User.current == homework.user%> + + <% else @is_comprehensive_evaluation == 2 %> + + <%= l(:label_work_rating) %>: + <%= render :partial => 'show_star',:locals => {start_score:@m_score} %> + <% end %> +
diff --git a/app/views/homework_attach/_show_star.html.erb b/app/views/homework_attach/_show_star.html.erb index 0f842a1cd..d98e35a0e 100644 --- a/app/views/homework_attach/_show_star.html.erb +++ b/app/views/homework_attach/_show_star.html.erb @@ -1,16 +1,6 @@ -<% if is_comprehensive_evaluation == 3 || User.current == homework.user%> - -<% elsif is_comprehensive_evaluation == 2 %> - <% if has_evaluation %> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: @m_score, class: 'rateable div_inline' %> - <% else %> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: 0, class: 'rateable div_inline' %> - <% end %> - -<% elsif @is_comprehensive_evaluation == 1%> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: @m_score, class: 'rateable div_inline' %> -<% end %> \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/app/views/homework_attach/show.js.erb b/app/views/homework_attach/show.js.erb index d63b5fb8f..ac0a3e505 100644 --- a/app/views/homework_attach/show.js.erb +++ b/app/views/homework_attach/show.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework}) %>'); showModal('ajax-modal', '513px'); $('#ajax-modal').css('height','569px'); $('#ajax-modal').siblings().remove(); diff --git a/public/images/bid/star.png b/public/images/bid/star.png new file mode 100644 index 0000000000000000000000000000000000000000..507e19020d7030cd0ccd5e07f0f74cebce399475 GIT binary patch literal 1601 zcmV-H2EO@;P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ>$4Nv%RCwC#m_ck4R~pBEGd8xd9UGirBH9pD1%iVjN+}XZyP!s^4J)mXno|!8 z((Z-54}DN<9>D*aOvSwNkPYyAmsbHqvU*T7oJSE{;tgq)zN63{D)^j>j|e z=Jnvlj^o%&7WcIMq)+mE{=fgc`Oo*h_q|c1l>BV1rtWrtuIoRYl9j*yWZb1vX;<9J zZZbyGG#Lm4c>er3Cr+GDx;pcW(wN9$*;Ve@+1WaGEEZF`nlVBM>G62*`Fw;zA` z=P?YU?(_5W-K#O>a#?yj9#mDuwryN47vXT2#l^+ff3s^hB*nYU!W8e;;;(5dD=RXe z&$BgS^7%X~D=YGKYK*jPn@XjEWm)v}^dP0gw(U9~m&>td&mImQJc!HX0&rFvq>$Jp zDEtMoe{7F?;|tjLA*ex6T#mS+3vu z@}wRMg+dGu4-*cDm6oOS=+ProRi&@5k4Pj!Fc|D83V`45r?6Dnr}D<6oJz_V7~%Fz|kMC zf7Q9axpnK-|6H&yU%sroviM3V<()fsID7Uie!rg`YE#`d3v@gl=iW#bS{}BGJ@?UA=l0kH^!(?QVAikH@2w%Vnu33a>gg$oF+cU?pNn6$*`q`hMtikb*pyzEUJcjgVko|izUQr$QG1Y1n zfRT|AW@cu1`t&JX2RM@+B zZ&Ok3?d_#pE)x!ioe5LTH?jd>@ovpK;e7`jQEzN)uqn*Vn>SnjUs_t?{{8z+_|2n^ zBVj6)3U0R>%d#*{lT<22B9WlKzn|shWkyCuIDY&%UayxxAV8r|a4t;g+h$<^_5|V0 zi?H-hFiWj?hr+C`u3{L*_T|OVqeq#Wn``-R>lx6IFoi+^%d$u&lg!S}a_Q0~&Ye4_ zZ0$C0-@Z*O7GwYZ{gg^2=S%7POzljxX}`~dH_}Mw>Z;^Vz0LT(_naNQ*48l1hU(X^ zU&rtFD_b%|Ub}X!2|q9}(7q4Z?m`GTIXNkl$)vPxTeia`lSw%_IVr2vYFkW;3scI^ zk#g}~=P`@-YB*s!<`zQ8iHQlBPNzGLNvG3tVq!uHA$G)d{7_}vwsg{$2qC1)<=WlH zC8q^-7ln6g0ahIB8l7;;&)A?E00000NkvXXu0mjf)oc^Q literal 0 HcmV?d00001 diff --git a/public/stylesheets/css.css b/public/stylesheets/css.css index 17316c095..b6d61c865 100644 --- a/public/stylesheets/css.css +++ b/public/stylesheets/css.css @@ -80,8 +80,7 @@ a.wzan_visited{background:url(images/pic_zan.png) 0 0 no-repeat;} .ping_con p{ color:#777777; font-size:12px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con p span a{ color:#777777;} .ping_star{ width:160px; color:#333; font-weight:bold; margin-bottom:5px;} -.ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png) -2px 0 no-repeat; margin-right:3px;} -.ping_star span a:hover{background:url(images/star.png) -24px 0 no-repeat;} +.ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png);background-repeat: no-repeat; margin-right:3px;} .ping_con textarea{ height:76px; border:1px solid #15bccf; margin-bottom:5px; color:#666; font-size:12px;} a.ping_sub{ float:right; height:22px; width:60px; margin-right:20px; background:#15bccf; color:#fff; text-align:center;} a.ping_sub1{ float:right; height:22px; width:60px; background:#15bccf; color:#fff; text-align:center;} From f5b1cbcfe456ee36e823e0745180ca6f21b70a21 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 1 Dec 2014 14:47:07 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 14 +++++++++----- app/views/homework_attach/_addjour.html.erb | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index dacf897da..2f6be7611 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -372,11 +372,11 @@ class HomeworkAttachController < ApplicationController def show if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) # 打分统计 - stars_reates = @homework. rates(:quality) + #stars_reates = @homework. rates(:quality) #是否已经进行过评价 temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{@homework.id} AND rater_id = #{User.current.id}").first @m_score = temp.nil? ? 0:temp.stars - @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0 + @has_evaluation = @homework.has_rated?( User.current,:quality) #@jours留言 is null条件用以兼容历史数据 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @cur_page = params[:cur_page] || 1 @@ -385,13 +385,17 @@ class HomeworkAttachController < ApplicationController teachers = searchTeacherAndAssistant @course @comprehensive_evaluation = [] + #JourForMessage的is_comprehensive_evaluation字段: + #1:老师评价 + #2:学生评价 + #3 || null:学生留言 teachers.each do|teacher| temp = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first @comprehensive_evaluation << temp if temp end - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end #@totle_score = score_for_homework @homework #@teaher_score = teacher_score_for_homework @homework diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 5b2889b57..8d4c1eaf2 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -50,7 +50,7 @@ } } - function submit1(button) + function submit1() { $('#jours_submit').parent().submit(); } From 9a613543287e6998a07e98677330c24ccbfd1e39 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 1 Dec 2014 15:41:49 +0800 Subject: [PATCH 03/12] =?UTF-8?q?1.=E8=AF=84=E5=88=86=E3=80=81=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E4=BD=9C=E4=B8=BA=E4=B8=80=E4=B8=AAaction=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=88=B0=E6=9C=8D=E5=8A=A1=E5=99=A8=202.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BD=9C=E4=B8=9A=E7=9A=84show=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8F=82=E6=95=B0=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 51 ++++++++----------- app/views/homework_attach/_addjour.html.erb | 15 +++++- app/views/homework_attach/_show.html.erb | 14 +---- app/views/homework_attach/_show_star.html.erb | 2 +- .../lib/seems_rateable/model.rb | 6 +-- 5 files changed, 41 insertions(+), 47 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2f6be7611..17dbb5cae 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -403,10 +403,13 @@ class HomeworkAttachController < ApplicationController is_student = is_cur_course_student @homework.bid.courses.first is_teacher = is_course_teacher User.current,@homework.bid.courses.first @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 + #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 if !User.current.member_of_course?(@homework.bid.courses.first) @is_comprehensive_evaluation = 3 #留言 - elsif is_student && @is_anonymous_comments#是学生且开启了匿评 + elsif is_student && @is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 @is_comprehensive_evaluation = 2 #匿评 + elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 + @is_comprehensive_evaluation = 3 #留言 elsif is_student && !@is_anonymous_comments #是学生未开启匿评 @is_comprehensive_evaluation = 3 #留言 elsif is_teacher @@ -458,14 +461,17 @@ class HomeworkAttachController < ApplicationController #添加留言 def addjours @homework = HomeworkAttach.find(params[:jour_id]) + #保存评分 + @homework.rate(params[:stars_value],User.current.id,:quality) + #保存评论 @add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation] if @add_jour.is_comprehensive_evaluation == 3 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @jour = paginateHelper @jours,5 elsif @add_jour.is_comprehensive_evaluation == 2 - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end elsif @add_jour.is_comprehensive_evaluation == 1 teachers = searchTeacherAndAssistant @homework.bid.courses.first @@ -476,36 +482,23 @@ class HomeworkAttachController < ApplicationController end end - - #@limit = 10 - #@feedback_count = @jours.count - #@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - #@offset ||= @feedback_pages.offset - #@jour = @jours[@offset, @limit] - #@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") - - @totle_score = score_for_homework @homework - @teaher_score = teacher_score_for_homework @homework - stars_reates = @homework. rates(:quality) is_student = is_cur_course_student @homework.bid.courses.first - is_teacher = is_course_teacher User.current,@homework.bid.courses.first - @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0 - @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 - if !User.current.member_of_course?(@homework.bid.courses.first) - @is_comprehensive_evaluation = 3 #留言 - elsif is_student && @is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 - @is_comprehensive_evaluation = 2 #匿评 - elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 - @is_comprehensive_evaluation = 3 #留言 - elsif is_student && !@is_anonymous_comments #是学生未开启匿评 - @is_comprehensive_evaluation = 3 #留言 - elsif is_teacher - @is_comprehensive_evaluation = 1 #教师评论 + #@has_evaluation = @homework.has_rated?( User.current,:quality) + is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 + if User.current.member_of_course?(@homework.bid.courses.first) + if is_student && is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 + @is_comprehensive_evaluation = 2 #匿评 + elsif is_student && is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 + @is_comprehensive_evaluation = 3 #留言 + elsif is_student && !is_anonymous_comments #是学生未开启匿评 + @is_comprehensive_evaluation = 3 #留言 + else #是老师 + @is_comprehensive_evaluation = 1 #教师评论 + end else @is_comprehensive_evaluation = 3 end - respond_to do |format| format.js end diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 8d4c1eaf2..a2b0013e0 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -52,6 +52,8 @@ function submit1() { + if($("#stars_value").val() == "0"){alert("您还没有打分");return;} + if($("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;} $('#jours_submit').parent().submit(); } @@ -62,6 +64,18 @@ :jour_id => homework_attach.id, :is_comprehensive_evaluation => is_comprehensive_evaluation, :sta => sta}) do |f|%> + +
+ <% if @is_comprehensive_evaluation == 3 || User.current == homework_attach.user%> + + <% else @is_comprehensive_evaluation == 2 %> + + <%= l(:label_work_rating) %>: + <%= render :partial => 'show_star',:locals => {start_score:m_score} %> + <% end %> +
+
+
<%= render :partial => 'words/pre_show', :locals => {:content => @content} %> @@ -75,7 +89,6 @@ <%= f.text_field :reference_user_id, :style=>"display:none"%> <% else %>
diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index 416ca4f66..42a5cead5 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -112,20 +112,8 @@ <% end%>

- -
- <% if @is_comprehensive_evaluation == 3 || User.current == homework.user%> - - <% else @is_comprehensive_evaluation == 2 %> - - <%= l(:label_work_rating) %>: - <%= render :partial => 'show_star',:locals => {start_score:@m_score} %> - <% end %> - -
-
- <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => @is_comprehensive_evaluation} %> + <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => @is_comprehensive_evaluation, :m_score => @m_score} %>
diff --git a/app/views/homework_attach/_show_star.html.erb b/app/views/homework_attach/_show_star.html.erb index d98e35a0e..3b6e23880 100644 --- a/app/views/homework_attach/_show_star.html.erb +++ b/app/views/homework_attach/_show_star.html.erb @@ -3,4 +3,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/lib/seems_rateable/lib/seems_rateable/model.rb b/lib/seems_rateable/lib/seems_rateable/model.rb index b4ebbb196..83d37d555 100644 --- a/lib/seems_rateable/lib/seems_rateable/model.rb +++ b/lib/seems_rateable/lib/seems_rateable/model.rb @@ -37,9 +37,9 @@ module SeemsRateable def update_users_rating(stars, user_id, dimension=nil) obj = rates(dimension).where(:rater_id => user_id).first - current_record = average(dimension) - current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt) - current_record.save! + #current_record = average(dimension) + #current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt) + #current_record.save! obj.stars = stars obj.save! end From 21c4caa7a696230197b1376073bf0abddf6e51ab Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 1 Dec 2014 16:31:13 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E3=80=81=E7=95=99=E8=A8=80=E5=80=BC=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E9=80=BB=E8=BE=91=E6=B7=B7=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 17dbb5cae..816ee0bf8 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -400,20 +400,20 @@ class HomeworkAttachController < ApplicationController #@totle_score = score_for_homework @homework #@teaher_score = teacher_score_for_homework @homework - is_student = is_cur_course_student @homework.bid.courses.first + #is_student = is_cur_course_student @homework.bid.courses.first is_teacher = is_course_teacher User.current,@homework.bid.courses.first @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 - if !User.current.member_of_course?(@homework.bid.courses.first) - @is_comprehensive_evaluation = 3 #留言 - elsif is_student && @is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 - @is_comprehensive_evaluation = 2 #匿评 - elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 - @is_comprehensive_evaluation = 3 #留言 - elsif is_student && !@is_anonymous_comments #是学生未开启匿评 - @is_comprehensive_evaluation = 3 #留言 - elsif is_teacher - @is_comprehensive_evaluation = 1 #教师评论 + if User.current.member_of_course?(@homework.bid.courses.first) + if is_teacher + @is_comprehensive_evaluation = 1 #教师评论 + else + if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + @is_comprehensive_evaluation = 2 #匿评 + else #是学生未开启匿评或者已经进行评分 + @is_comprehensive_evaluation = 3 #留言 + end + end else @is_comprehensive_evaluation = 3 end @@ -438,9 +438,9 @@ class HomeworkAttachController < ApplicationController @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @jour = paginateHelper @jours,5 elsif @is_comprehensive_evaluation == 2 - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users.count == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end elsif @is_comprehensive_evaluation == 1 teachers = searchTeacherAndAssistant @course @@ -450,9 +450,6 @@ class HomeworkAttachController < ApplicationController @comprehensive_evaluation << temp if temp end end - - - respond_to do |format| format.js end @@ -482,18 +479,18 @@ class HomeworkAttachController < ApplicationController end end - is_student = is_cur_course_student @homework.bid.courses.first - #@has_evaluation = @homework.has_rated?( User.current,:quality) - is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 + is_teacher = is_course_teacher User.current,@homework.bid.courses.first + @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 + #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 if User.current.member_of_course?(@homework.bid.courses.first) - if is_student && is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分 - @is_comprehensive_evaluation = 2 #匿评 - elsif is_student && is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分 - @is_comprehensive_evaluation = 3 #留言 - elsif is_student && !is_anonymous_comments #是学生未开启匿评 - @is_comprehensive_evaluation = 3 #留言 - else #是老师 + if is_teacher @is_comprehensive_evaluation = 1 #教师评论 + else + if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + @is_comprehensive_evaluation = 2 #匿评 + else #是学生未开启匿评或者已经进行评分 + @is_comprehensive_evaluation = 3 #留言 + end end else @is_comprehensive_evaluation = 3 From 6fd68806d542b4a11b32b813ff940cfef9d2891c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 1 Dec 2014 16:45:03 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=95=99=E5=B8=88=E5=B0=B1=E5=85=B7=E6=9C=89=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E3=80=81=E5=85=B3=E9=97=AD=E5=8C=BF=E8=AF=84=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BD=9C=E4=B8=9A=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 3 +++ app/views/bids/_bid_homework_show.html.erb | 2 +- app/views/layouts/base_homework.html.erb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 816ee0bf8..28bac9627 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -570,6 +570,9 @@ class HomeworkAttachController < ApplicationController #获取课程的老师列表 def find_course_teachers course + t = [] + course.members.map{|m| t << m.user_id if m.user.allowed_to?(:as_teacher,course)} + teachers = "(" teacher_members = searchTeacherAndAssistant(course) teacher_members.each do |member| diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 630d7552c..e7b58fefc 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -68,7 +68,7 @@ <% end %> <% end %> - <% if (User.current.admin?||User.current.id==bid.author_id) %> + <% if (User.current.admin?||User.current.allowed_to?(:as_teacher,@course)) %> <% if bid.open_anonymous_evaluation == 1 && bid.homeworks.count >= 2%> <% case bid.comment_status %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 9ce2a6edf..7c40173a0 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -117,7 +117,7 @@
- <% if (User.current.admin?||User.current.id==@bid.author_id) %> + <% if (User.current.admin?||User.current.allowed_to?(:as_teacher,course)) %>
<% if @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2%> From bc6db4adc71946fd909807d5430dfc4ad0513383 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 2 Dec 2014 08:45:53 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=80=81=E5=B8=88=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 28bac9627..816ee0bf8 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -570,9 +570,6 @@ class HomeworkAttachController < ApplicationController #获取课程的老师列表 def find_course_teachers course - t = [] - course.members.map{|m| t << m.user_id if m.user.allowed_to?(:as_teacher,course)} - teachers = "(" teacher_members = searchTeacherAndAssistant(course) teacher_members.each do |member| From 277e5ecad3ff0e80382441f12b40a4b92faf6dc5 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 2 Dec 2014 16:21:36 +0800 Subject: [PATCH 07/12] =?UTF-8?q?1.=E8=80=81=E5=B8=88=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E3=80=81=E5=AD=A6=E7=94=9F=E5=8C=BF=E8=AF=84=E3=80=81=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=95=99=E8=A8=80=E4=B8=8D=E5=90=8C=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=202.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=80=81=E5=B8=88=E8=AF=84=E4=BB=B7=E3=80=81=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=8C=BF=E8=AF=84=E3=80=81=E5=AD=A6=E7=94=9F=E7=95=99?= =?UTF-8?q?=E8=A8=80=E6=98=AF=E8=BD=BD=E5=85=A5=E4=B8=AD=E5=9C=A8=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E7=AA=97=E5=90=8E=E9=9D=A2=E6=98=BE=E7=A4=BA=203.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=81=E5=B8=88=E6=9C=AA=E6=89=B9=E5=88=97?= =?UTF-8?q?=E8=A1=A8=204.=E5=8F=96=E6=B6=88=E5=85=B3=E9=97=AD=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=97=B6=E7=95=8C=E9=9D=A2=E5=88=B7=E6=96=B0=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=AF=84=E8=AE=BA=E6=97=B6=E5=88=B7=E6=96=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=205.=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=95=8C=E9=9D=A2=E7=BC=BA=E5=A4=B1=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 117 +++++++++++------- app/views/bids/_homework.html.erb | 94 +++++++------- app/views/homework_attach/_addjour.html.erb | 8 +- app/views/homework_attach/_homework.html.erb | 13 +- app/views/homework_attach/_show.html.erb | 45 ++----- app/views/homework_attach/addjours.js.erb | 42 +++++-- app/views/homework_attach/show.js.erb | 6 +- public/stylesheets/application.css | 2 +- 8 files changed, 171 insertions(+), 156 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 816ee0bf8..6088e2294 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -22,23 +22,10 @@ class HomeworkAttachController < ApplicationController #获取未批作业列表 def get_not_batch_homework sort, direction = params[:sort] || "s_socre", params[:direction] || "desc" - if sort == 't_socre' - order_by = "t_score #{direction}" - elsif sort == 's_socre' - order_by = "s_score #{direction}" - elsif sort == 'time' - order_by = "created_at #{direction}" - end teachers = find_course_teachers @course - all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score - FROM homework_attaches WHERE bid_id = #{@bid.id} - ORDER BY #{order_by}) AS table1 - WHERE table1.t_score IS NULL") + get_not_batch_homework_list sort,direction,teachers, @bid.id @cur_page = params[:page] || 1 @cur_type = 1 - @homework_list = paginateHelper all_homework_list,10 @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| format.js @@ -57,8 +44,8 @@ class HomeworkAttachController < ApplicationController end teachers = find_course_teachers @course all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers} and stars IS NOT NULL) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers}) and stars IS NOT NULL) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 WHERE table1.t_score IS NOT NULL") @@ -83,8 +70,8 @@ class HomeworkAttachController < ApplicationController end teachers = find_course_teachers @course all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in #{teachers}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in #{teachers}) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in (#{teachers})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in (#{teachers})) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}") @cur_page = params[:page] || 1 @@ -101,8 +88,8 @@ class HomeworkAttachController < ApplicationController @is_student_batch_homework = true teachers = find_course_teachers @course all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id @@ -120,15 +107,15 @@ class HomeworkAttachController < ApplicationController @is_my_homework = true teachers = find_course_teachers @course all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches WHERE homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}") #如果我没有创建过作业,就检索我是否参与了某个作业 if all_homework_list.empty? all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}") @@ -401,14 +388,14 @@ class HomeworkAttachController < ApplicationController #@teaher_score = teacher_score_for_homework @homework #is_student = is_cur_course_student @homework.bid.courses.first - is_teacher = is_course_teacher User.current,@homework.bid.courses.first + @is_teacher = is_course_teacher User.current,@homework.bid.courses.first @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 if User.current.member_of_course?(@homework.bid.courses.first) - if is_teacher + if @is_teacher @is_comprehensive_evaluation = 1 #教师评论 else - if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 @is_comprehensive_evaluation = 2 #匿评 else #是学生未开启匿评或者已经进行评分 @is_comprehensive_evaluation = 3 #留言 @@ -459,19 +446,26 @@ class HomeworkAttachController < ApplicationController def addjours @homework = HomeworkAttach.find(params[:jour_id]) #保存评分 - @homework.rate(params[:stars_value],User.current.id,:quality) + @homework.rate(params[:stars_value],User.current.id,:quality) if params[:stars_value] && params[:stars_value] != "0" #保存评论 - @add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation] - if @add_jour.is_comprehensive_evaluation == 3 + @cur_is_comprehensive_evaluation = params[:is_comprehensive_evaluation] + if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言 + @homework.addjours User.current.id, params[:new_form][:user_message],0,@cur_is_comprehensive_evaluation + end + + @cur_page = params[:cur_page] || 1 + @cur_type = params[:cur_type] || 5 + teachers = searchTeacherAndAssistant @homework.bid.courses.first + if @cur_is_comprehensive_evaluation == "3" @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @jour = paginateHelper @jours,5 - elsif @add_jour.is_comprehensive_evaluation == 2 + elsif @cur_is_comprehensive_evaluation == "2" annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') unless annymous_users.nil? || annymous_users == "" @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end - elsif @add_jour.is_comprehensive_evaluation == 1 - teachers = searchTeacherAndAssistant @homework.bid.courses.first + @m_score = params[:stars_value].to_i + elsif @cur_is_comprehensive_evaluation == "1" @comprehensive_evaluation = [] teachers.each do|teacher| temp = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first @@ -486,7 +480,7 @@ class HomeworkAttachController < ApplicationController if is_teacher @is_comprehensive_evaluation = 1 #教师评论 else - if is_student && @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 @is_comprehensive_evaluation = 2 #匿评 else #是学生未开启匿评或者已经进行评分 @is_comprehensive_evaluation = 3 #留言 @@ -496,6 +490,33 @@ class HomeworkAttachController < ApplicationController @is_comprehensive_evaluation = 3 end + #teachers = find_course_teachers @homework.bid.courses.first + teachers_str = teachers.map{|teacher| teacher.user_id}.join(",") + if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面 + @bid = @homework.bid + get_not_batch_homework_list "s_socre","desc",teachers_str,@homework.bid_id + elsif @cur_type == "2" #老师已批列表 + @result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers_str}) and stars IS NOT NULL) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers_str})) AS s_score + FROM homework_attaches WHERE id = #{@homework.id}").first + elsif @cur_type == "3" #全部作业列表 + @result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in (#{teachers_str})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in (#{teachers_str})) AS s_score + FROM homework_attaches WHERE id = #{@homework.id}").first + elsif @cur_type == "4" #匿评作业列表 + @is_student_batch_homework = true + @result_homework = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers_str})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers_str})) AS s_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score + FROM homework_attaches + WHERE homework_attaches.id = #{@homework.id}").first + else #其他的不用管 + + end + respond_to do |format| format.js end @@ -570,16 +591,7 @@ class HomeworkAttachController < ApplicationController #获取课程的老师列表 def find_course_teachers course - teachers = "(" - teacher_members = searchTeacherAndAssistant(course) - teacher_members.each do |member| - if member == teacher_members.last - teachers += member.user_id.to_s + ")" - else - teachers += member.user_id.to_s + "," - end - end - teachers + searchTeacherAndAssistant(course).map{|teacher| teacher.user_id}.join(",") end #获取作业教师评分所占比例 @@ -591,5 +603,22 @@ class HomeworkAttachController < ApplicationController end teacher_proportion end + + def get_not_batch_homework_list sort,direction,teachers,bid_id + if sort == 't_socre' + order_by = "t_score #{direction}" + elsif sort == 's_socre' + order_by = "s_score #{direction}" + elsif sort == 'time' + order_by = "created_at #{direction}" + end + all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score + FROM homework_attaches WHERE bid_id = #{bid_id} + ORDER BY #{order_by}) AS table1 + WHERE table1.t_score IS NULL") + @homework_list = paginateHelper all_homework_list,10 + end end diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 7cde4f31d..db1f555d3 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -58,53 +58,53 @@ { hideModal($("#popbox")); // 评了分的则刷新列表 - switch (cur_type) - { - case 1: - $.ajax({ - type: "GET", - url: "<%= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 2: - $.ajax({ - type: "GET", - url: "<%= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 3: - $.ajax({ - type: "GET", - url: "<%= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 4: - $.ajax({ - type: "GET", - url: "<%= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 5: - break; - default : - break; - } +// switch (cur_type) +// { +// case 1: +// $.ajax({ +// type: "GET", +// url: "<%#= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 2: +// $.ajax({ +// type: "GET", +// url: "<%#= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 3: +// $.ajax({ +// type: "GET", +// url: "<%#= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 4: +// $.ajax({ +// type: "GET", +// url: "<%#= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 5: +// break; +// default : +// break; +// } } diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index a2b0013e0..955399d31 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -50,10 +50,10 @@ } } - function submit1() + function submit1(is_teacher) { if($("#stars_value").val() == "0"){alert("您还没有打分");return;} - if($("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;} + if(!is_teacher&&$("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;} $('#jours_submit').parent().submit(); } @@ -63,6 +63,8 @@ :action => 'addjours', :jour_id => homework_attach.id, :is_comprehensive_evaluation => is_comprehensive_evaluation, + :cur_page => cur_page, + :cur_type => cur_type, :sta => sta}) do |f|%>
@@ -88,7 +90,7 @@ %> <%= f.text_field :reference_user_id, :style=>"display:none"%> <% else %>
diff --git a/app/views/homework_attach/_homework.html.erb b/app/views/homework_attach/_homework.html.erb index e14475f9f..802a021a4 100644 --- a/app/views/homework_attach/_homework.html.erb +++ b/app/views/homework_attach/_homework.html.erb @@ -1,3 +1,4 @@ +<% bid = homework.bid%>
  • <% if is_student_batch_homework %> @@ -46,7 +47,7 @@
  • <%= link_to l(:label_work_rating),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type),:remote => true %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • @@ -54,7 +55,7 @@ <% if is_my_homework %> - <% if @bid.comment_status == 0 || @bid.open_anonymous_evaluation == 0 %> + <% if bid.comment_status == 0 || bid.open_anonymous_evaluation == 0 %>
  • <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> <% if homework.user == User.current || User.current.admin? %> @@ -85,21 +86,21 @@ <% end %> <% elsif is_student_batch_homework%> - <% if @bid.comment_status == 1 %> + <% if bid.comment_status == 1 %>
  • <%= link_to l(:label_anonymous_comments),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type),:remote => true %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • - <% elsif @bid.comment_status == 2%> + <% elsif bid.comment_status == 2%>
  • <%= l(:label_anonymous_comments) %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index 42a5cead5..937c068c1 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -1,41 +1,5 @@ -<% reply_allow = JournalsForMessage.create_by_user? User.current %> - - +<%# reply_allow = JournalsForMessage.create_by_user? User.current %>