Merge branch 'szzh' into develop

This commit is contained in:
cxt 2016-01-29 19:43:56 +08:00
commit 49369bf109
4 changed files with 10 additions and 5 deletions

View File

@ -344,7 +344,7 @@ class HomeworkCommonController < ApplicationController
#当前用户是不是课程的成员
def member_of_course
render_403 unless @course.is_public || User.current.member_of_course?(@course) || User.current.admin?
render_403 unless @course.is_public==1 || User.current.member_of_course?(@course) || User.current.admin?
end
def get_assigned_homeworks(student_works, n, index)

View File

@ -150,7 +150,7 @@ class Member < ActiveRecord::Base
#当前学生在指定作业内的得分
def homework_common_score homework_common
StudentWork.select("final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
StudentWork.select("IF(final_score is null,null,final_score - absence_penalty - late_penalty) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
end
def student_work_score_avg
@ -158,7 +158,12 @@ class Member < ActiveRecord::Base
end
def student_work_score_sum
StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").sum(:final_score).try(:round, 2).to_f
sql_select = "SELECT (SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))) as score
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{self.course_id}
AND student_works.user_id = #{self.user_id}"
score = StudentWork.find_by_sql(sql_select)
end
protected

View File

@ -28,7 +28,7 @@
</span>
</li>
<% end %>
<li><span class="c_blue03 w280">作业积分(总分)</span><span class="c_red w70"><%= @member_score.student_work_score_sum %></span></li>
<li><span class="c_blue03 w280">作业积分(总分)</span><span class="c_red w70"><%= (@member_score.student_work_score_sum).first.score %></span></li>
</ul>
</div>

View File

@ -1,6 +1,6 @@
<%= form_tag( url_for(:controller => 'courses',:action => 'homework_search',:id=>course.id),
:remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
<input type="text" name="search" placeholder="输入作业关键词进行搜索" class="searchResource" />
<input type="text" name="search" placeholder="输入作业名称进行搜索" class="searchResource" />
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
<% end %>