Merge branch 'cxt_course' into szzh

This commit is contained in:
cxt 2016-03-10 14:52:15 +08:00
commit 2c579c2979
13 changed files with 130 additions and 110 deletions

View File

@ -1067,7 +1067,7 @@ class CoursesController < ApplicationController
sql_select = ""
if groupid == 0
sql_select = "SELECT members.*,(
SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
@ -1079,7 +1079,7 @@ class CoursesController < ApplicationController
WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}"
else
sql_select = "SELECT members.*,(
SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}

View File

@ -36,6 +36,14 @@ class StudentWorkController < ApplicationController
unless student_work.save
resultObj[:status] = 200
else
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
end
student_work.save
resultObj[:status] = result["status"].to_i
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
@ -93,12 +101,12 @@ class StudentWorkController < ApplicationController
end
#老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
if @homework.is_open == 1
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
if @is_teacher || @homework.homework_detail_manual.nil? ||
(@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
if @homework.homework_type == 3
@ -106,10 +114,10 @@ class StudentWorkController < ApplicationController
if pro.nil?
@stundet_works = []
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
@ -129,15 +137,15 @@ class StudentWorkController < ApplicationController
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true
end
else
@ -148,14 +156,14 @@ class StudentWorkController < ApplicationController
return
end
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
else
if @homework.is_open == 1
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
if @homework.homework_type == 3
@ -163,10 +171,10 @@ class StudentWorkController < ApplicationController
if pro.nil?
@stundet_works = []
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
@ -186,15 +194,15 @@ class StudentWorkController < ApplicationController
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
end
else
@ -205,7 +213,7 @@ class StudentWorkController < ApplicationController
return
end
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count
end
@score = @b_sort == "desc" ? "asc" : "desc"

View File

@ -150,7 +150,7 @@ class Member < ActiveRecord::Base
#当前学生在指定作业内的得分
def homework_common_score homework_common
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)
StudentWork.select("IF(final_score is null,null,IF(final_score = 0, 0, 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,7 @@ class Member < ActiveRecord::Base
end
def student_work_score_sum
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
sql_select = "SELECT (SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,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}

View File

@ -1,81 +1,81 @@
<!-- 加入分班 -->
<div style="margin-left: 15px">
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<%= join_in_course_group(@course.course_groups,@group, User.current) unless @canShowCode %>
<span style="font-size: 12px; float: left; margin-right: 5px">
<%= l(:label_current_group)%>:&nbsp;
<%= @group.name %>
</span>
<% end %>
</div>
<div class="cl"></div>
<% if members.any? %>
<% if @result_count %>
<p style="font-size: 18px;">
<%= l(:label_search_member_count) %>
<%= @result_count %>
<%= l(:label_member_people) %>
</p>
<div class="cl"></div>
<% end %>
<div class="st_box">
<ul class="st_box_top">
<li class="ml50" style="padding-right: 5px;"><a href="">姓名</a></li>
<li class="ml10" style="padding-right: 15px;"><a href="">学号</a></li>
<li class="ml358">
<%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<% if @score_sort_by == 'desc' %>
<a id="pic" href="javascript:" class= "st_down"></a>
<% else %>
<a id="pic" href="javascript:" class= "st_up"></a>
<% end %>
</li>
<li class="ml50"><a href="javascript:void(0)" >加入时间</a></li>
</ul>
<div class="cl"></div><!--st_box_top end-->
<% members.each do |member| %>
<div class="st_boxlist">
<a href="javascript:" class="st_img">
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
</a>
<ul>
<% if @canShowCode %>
<li>
<% if member.user.show_name == ''%>
<%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.name}</span>".html_safe,user_path(member.user)) %>
<% else%>
<%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.show_name}</span>".html_safe,user_path(member.user)) %>
<%end%>
</li>
<% else %>
<li><%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.name}</span>".html_safe, user_path(member.user)) %></li>
<% end %>
<br/>
<% unless member.user.user_extensions.student_id == ''%>
<li><%= link_to("#{l(:label_bidding_user_studentcode)}<span >#{member.user.user_extensions.student_id}</span>".html_safe,user_path(member.user)) %></li>
<% end%>
</ul>
<%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
:action => 'show_member_score',
:member_id => member.id,
:remote => true},
:class => 'ml258 c_red' %>
<span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
</div>
<div class="cl"></div>
<% end; reset_cycle %>
</div>
<!--<ul class="wlist">
<% #= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>-->
<% else%>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end%>
<!-- 加入分班 -->
<div style="margin-left: 15px">
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<%= join_in_course_group(@course.course_groups,@group, User.current) unless @canShowCode %>
<span style="font-size: 12px; float: left; margin-right: 5px">
<%= l(:label_current_group)%>:&nbsp;
<%= @group.name %>
</span>
<% end %>
</div>
<div class="cl"></div>
<% if members.any? %>
<% if @result_count %>
<p style="font-size: 18px;">
<%= l(:label_search_member_count) %>
<%= @result_count %>
<%= l(:label_member_people) %>
</p>
<div class="cl"></div>
<% end %>
<div class="st_box">
<ul class="st_box_top">
<li class="ml50" style="padding-right: 5px;"><a href="">姓名</a></li>
<li class="ml10" style="padding-right: 15px;"><a href="">学号</a></li>
<li class="ml358">
<%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<% if @score_sort_by == 'desc' %>
<a id="pic" href="javascript:" class= "st_down"></a>
<% else %>
<a id="pic" href="javascript:" class= "st_up"></a>
<% end %>
</li>
<li class="ml50"><a href="javascript:void(0)" >加入时间</a></li>
</ul>
<div class="cl"></div><!--st_box_top end-->
<% members.each do |member| %>
<div class="st_boxlist">
<a href="javascript:" class="st_img">
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
</a>
<ul>
<% if @canShowCode %>
<li>
<% if member.user.show_name == ''%>
<%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.name}</span>".html_safe,user_path(member.user)) %>
<% else%>
<%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.show_name}</span>".html_safe,user_path(member.user)) %>
<%end%>
</li>
<% else %>
<li><%= link_to("#{l(:label_bidding_user_studentname)}<span >#{member.user.name}</span>".html_safe, user_path(member.user)) %></li>
<% end %>
<br/>
<% unless member.user.user_extensions.student_id == ''%>
<li><%= link_to("#{l(:label_bidding_user_studentcode)}<span >#{member.user.user_extensions.student_id}</span>".html_safe,user_path(member.user)) %></li>
<% end%>
</ul>
<%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
:action => 'show_member_score',
:member_id => member.id,
:remote => true},
:class => 'ml258 c_red' %>
<span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
</div>
<div class="cl"></div>
<% end; reset_cycle %>
</div>
<!--<ul class="wlist">
<% #= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>-->
<% else%>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end%>

View File

@ -15,10 +15,10 @@
<li>
<% if @homework.homework_type != 3 %>
<ul class="mt10 fl">
<li class="hworkStName mr10 mt16" title="姓名">
<li class="hworkStName mr10 mt16" title="<%= student_work.user.show_name%>">
<%= student_work.user.show_name%>
</li>
<li class="hworkStID mt16" title="学号">
<li class="hworkStID mt16" title="<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>">
<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
</li>
</ul>

View File

@ -21,10 +21,10 @@
<li onclick="show_student_work('<%= student_work_path(student_work)%>');" style="cursor: pointer;" class="student_work_<%= student_work.id%>">
<% if @homework.homework_type != 3 %>
<ul class="mt10 fl">
<li class="hworkStName mr10 mt16" title="姓名">
<li class="hworkStName mr10 mt16" title="<%= student_work.user.show_name%>">
<%= student_work.user.show_name%>
</li>
<li class="hworkStID mt16" title="学号">
<li class="hworkStID mt16" title="<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>">
<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
</li>
</ul>

View File

@ -25,7 +25,7 @@
<li >
<span class="tit_fb ">编程代码:</span>
<div class="showHworkP break_word"><pre id="work-src" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code">
<div class="showHworkP break_word"><pre id="work-src" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code_<%= work.id%>">
</div>
</div>
<div class="cl"></div>

View File

@ -63,7 +63,7 @@
} else if(language==4){
program_name = 'text/x-java';
}
var editor = CodeMirror(document.getElementById("work-code"), {
var editor = CodeMirror(document.getElementById("work-code_<%= work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},

View File

@ -17,7 +17,7 @@ else{
program_name = 'text/x-java';
}
var editor = CodeMirror(document.getElementById("work-code"), {
var editor = CodeMirror(document.getElementById("work-code_<%= @work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},

View File

@ -0,0 +1,8 @@
class DeleteStudentWorkData < ActiveRecord::Migration
def up
StudentWork.where("homework_common_id = 2604 AND user_id = 10763 AND final_score = 0").destroy_all
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160309024051) do
ActiveRecord::Schema.define(:version => 20160310033019) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1387,7 +1387,6 @@ ActiveRecord::Schema.define(:version => 20160309024051) do
t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0
t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0
t.datetime "commit_time"
end

View File

@ -1289,3 +1289,6 @@ a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: no
.active-degree-rule{font-size: 12px;color: #888; text-align: center; cursor: pointer;}
.hero-degree-rule{font-size: 12px;color: #888;text-align: center;}
.contributor-course-calculate{padding-left: 54px; font-size: 12px;color: #888}
/*20160310分班样式*/
.select-class-option {width:125px;}

View File

@ -66,6 +66,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.ml15{ margin-left:15px;}
.ml16{ margin-left: 16px;}
.ml20{ margin-left:20px;}
.ml25 {margin-left:25px;}
.ml30{margin-left:30px !important;}
.ml35{margin-left: 35px;}
.ml40{ margin-left:40px;}
@ -144,6 +145,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w80{ width:80px;}
.w90{ width:90px;}
.w100{width: 100px;}
.w125{width:125px;}
.w210{ width:210px;}
.w150{ width:150px;}
.w170{width:170px;}