This commit is contained in:
sw 2014-12-18 15:49:49 +08:00
commit b6327460a8
15 changed files with 206 additions and 107 deletions

View File

@ -318,7 +318,6 @@ class CoursesController < ApplicationController
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@role = params[:role]
@course_groups = @course.course_groups if @course.course_groups
@course_group_id = params[:@course_group_id] unless params[:@course_group_id].nil?
@show_serch = params[:role] == '2'
case params[:role]
when '1'
@ -340,6 +339,15 @@ class CoursesController < ApplicationController
render_403
end
end
# 显示每个学生的作业评分详情
def show_member_score
@member_score = Member.find(params[:member_id]) if params[:member_id]
respond_to do |format|
format.html {render :layout => 'course_base'}
format.js
end
end
#判断指定用户是否为课程教师
@ -840,4 +848,6 @@ class CoursesController < ApplicationController
render_404
end
end
end

View File

@ -166,11 +166,27 @@ module CoursesHelper
def searchStudent project
#searchPeopleByRoles(project, StudentRoles)
members = []
project.members.each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_student,project)
if m && m.user && m.user.allowed_to?(:as_student,project)
members << m
end
end
members
end
def search_student_and_score project
#searchPeopleByRoles(project, StudentRoles)
members = []
scores = []
project.members.each do |m|
if m && m.user && m.user.allowed_to?(:as_student,project)
members << m
end
end
members
end
def searchStudent_by_name project, name
#searchPeopleByRoles(project, StudentRoles)
members = []
@ -392,7 +408,13 @@ module CoursesHelper
return teacher_score_for_homework homework
end
end
def score_for_homework_new homework
if teacher_score_for_homework(homework) != 0
return teacher_score_for_homework homework
else
return student_score_for_homework homework
end
end
#获取作业的互评得分
def student_score_for_homework homework
#member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first

View File

@ -114,9 +114,50 @@ class Member < ActiveRecord::Base
member
end
# 查找每个学生每个作业的评分
def student_homework_score
teachers = find_course_teachers(self.course)
score_count = 0
homework_scores = HomeworkAttach.find_by_sql("SELECT homework_attaches.bid_id as bid_id, bids.name as name,
(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, bids where homework_attaches.user_id = #{self.user_id}
and homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses where course_id = #{self.course_id}
and homework_attaches.bid_id = bids.id)")
homework_scores.each do |homework|
if !homework.t_score.nil? && homework.t_score != 0
score = homework.t_score
else
if !homework.s_score.nil?
score= homework.s_score
else
score = 0
end
end
score_count = score_count + score
end
[homework_scores, format("%0.2f", score_count)]
end
protected
def validate_role
errors.add_on_empty :role if member_roles.empty? && roles.empty?
end
#获取课程的老师列表
def find_course_teachers course
searchTeacherAndAssistant(course).map{|teacher| teacher.user_id}.join(",")
end
def searchTeacherAndAssistant project
#searchPeopleByRoles(project, TeacherRoles)
members = []
project.members.each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
end
members
end
end

View File

@ -90,7 +90,7 @@ class User < Principal
has_many :contesting_projects, :dependent => :destroy
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
##ended by xianbo
#####fq
has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy
has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy
@ -105,7 +105,7 @@ class User < Principal
#has_many :courses, :through => :students_for_courses, :source => :project
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
####
####
# added by bai
has_many :join_in_contests, :dependent => :destroy
has_many :news, :foreign_key => 'author_id'

View File

@ -20,7 +20,7 @@
%>
<% end %>
<% if @canShowCode %>
<a href="javascript:void(0)" class="f_l" onclick="$('#add_tag_<%= group.id %>').slideToggle();"><img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" /></a>
<a href="javascript:void(0)" class="f_l" onclick="document.getElementById('group_name<%= group.id %>').value='';$('#add_tag_<%= group.id %>').slideToggle();"><img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" /></a>
<% end %>
</li>
<li>
@ -36,7 +36,7 @@
<% end %>
<% if @canShowCode %>
<li style="margin-left:15px;">
<a href="javascript:void(0)" class="st_add f_l" onclick="$('#add_tag04').slideToggle();">+添加分班</a>
<a href="javascript:void(0)" class="st_add f_l" onclick="document.getElementById('group_name').value='';$('#add_tag04').slideToggle();">+添加分班</a>
</li>
<li>
<span id="add_tag04" style="display:none; vertical-align: middle;" class="ml10 f_l">
@ -44,7 +44,7 @@
<%= text_field_tag "group_name", params[:group_name], size: "20", class: "isTxt w90 f_l", style: "padding: 0px", maxlength: "100" %>
<%= submit_tag '', class: "submit f_l",:onclick => "validate_add_group()", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
<%= link_to_function '', "$('#add_tag04').slideToggle();", class: "submit_2", style: "width: 43px"%>
<%= link_to_function '', "document.getElementById('group_name').value='';$('#add_tag04').slideToggle();", class: "submit_2", style: "width: 43px"%>
<% end %>
</span>

View File

@ -1,4 +1,4 @@
<div style="margin-left: 15px">
<div style="margin-left: 15px" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<% if !@canShowCode %>
<%= join_in_course_group(@course.course_groups,@group, User.current) %>
@ -26,31 +26,66 @@
<% if @result_count %>
<p style="font-size: 18px;"><%= l(:label_search_member_count) %><%= @result_count %><%= l(:label_member_people) %></p>
<% end %>
<% members.each do |member| %>
<div class="well">
<div class="cl"></div>
<div class="st_box">
<ul class="st_box_top">
<% if @subPage_title == l(:label_student_list) %>
<li class="ml358"><a href="#" >作业积分</a><a href="#" class="st_down"></a></li>
<li class="ml50"><a href="#" >加入时间</a></li>
<% else %>
<li class="ml50" style="margin-left: 470px"><a href="#" >加入时间</a></li>
<% end %>
</ul>
<% members.each do |member| %>
<div class="cl"></div><!--st_box_top end-->
<div class="st_boxlist">
<% next if member.new_record? %>
<% unless member.created_on.nil? %>
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
<% end %>
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
<a href="#" class="st_img" style="float:left;"> <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %></a>
<ul style="margin-left: 15px">
<% if @canShowCode %>
<%= content_tag "div", link_to(member.user.show_name, user_path(member.user)), :class => "nomargin avatar_name" %>
<li>
<%= l(:label_bidding_user_studentname) %> :
<%= link_to member.user.show_name, user_path(member.user) %>
</li> </br>
<%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
<% else %>
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
<%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
<% end %>
<!--teacher's code disapeared moified by huang-->
<% if @canShowCode %>
<%= content_tag "p", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :class => "nomargin avatar_name" %>
<% if @canShowCode %>
<li>
<%= l(:label_bidding_user_studentcode) %> :
<%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
</li>
<%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
<% end %>
<div class ="clear avatar_name"> &nbsp;
<p>
</p>
</div>
</ul>
<% if @subPage_title == l(:label_student_list) %>
<%= link_to member.student_homework_score[1].to_s, {
:action => 'show_member_score',
:member_id => member.id,
:remote => true},
:class => 'ml258 c_red', :style => "color:red;" %>
<% unless member.created_on.nil? %>
<%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey" %>
<% end %>
<% else %>
<% unless member.created_on.nil? %>
<%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey", :style=>"margin-left:195px" %>
<% end %>
<% end %>
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
</div>
<% end; reset_cycle %>
</div>
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
<% else %>
<p class="nodata">

View File

@ -0,0 +1,58 @@
<style>
table,tr,td{border:0; cellspacing:0; cellpadding:0;}
ul,li{ list-style-type:none}
.cl{ clear:both; overflow:hidden; }
a{ text-decoration:none; text-align:center; }
a:hover{ text-decoration:underline;}
/**** 常用***/
.f_l{ float:left;}
.f_r{ float:right;}
.b_lblue{ background:#64bdd9;}
.b_dblue{ background:#55a1b9; cursor:pointer;}
.f_b{ font-weight: bold;}
.c_blue{ color:#64bdd9;}
.c_grey{ color:#999999;}
.c_grey02{ color:#666666;}
.f_14{ font-size:14px;}
.c_dblue{ color:#3e6d8e;}
.w90{width:90px;}
.ml10{margin-left:10px;}
.ml5{margin-left:5px;}
.b_grey{ background:#a3a3a3;}
.c_blue02{ color:#15bcce; font-weight: bold;}
.w280{ display:block; width:280px;float:left;}
.w70{ display:block;width:70px; text-align:center; float:left;}
.c_red{ color:#e50000;}
.c_blue03{ color:#0d90c4;}
/***弹框***/
#popbox_tscore{width:480px;position:absolute;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.alert .close02{width:26px;height:26px;overflow:hidden;position:absolute;top:-10px;right:-490px;background:url(images/close.png) no-repeat;cursor:pointer;}
.tscore_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;}
.tscore_box{ width:350px; margin:15px auto;}
.tscore_box li{ height:25px;}
</style>
<div class="tscore_con">
<h2><%= @member_score.user.name %> 历次作业积分</h2>
<ul class="tscore_box">
<li ><span class="c_blue02 w280">作业名称</span><span class="c_blue02 w70">得分</span></li>
<% @member_score.student_homework_score[0].each do |homework_score| %>
<% if !homework_score.t_score.nil? && homework_score.t_score != 0 %>
<% score = homework_score.t_score %>
<% else %>
<% if !homework_score.s_score.nil? %>
<% score = homework_score.s_score %>
<% else %>
<% score = 0 %>
<% end %>
<% end %>
<li><span class="c_grey02 w280"><%= homework_score.name %></span><span class="c_red w70"><%= format("%0.2f",score) %></span></li>
<% end %>
<li><span class="c_blue03 w280">作业积分(总得分)</span><span class="c_red w70"><%= @member_score.student_homework_score[1] %></span></li>
</ul>
</div>

View File

@ -0,0 +1,3 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/show_member_score', :locals => {:member => @member_score}) %>');
showModal('ajax-modal', '400px');
$('#ajax-modal').addClass('new-watcher');

View File

@ -30,7 +30,7 @@
<div id="content_">
<%= render_flash_messages %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<%= call_hook :view_layouts_base_course %>
<div style="clear:both;"></div>
<%=render :partial => 'layouts/base_footer'%>
</div>

View File

@ -1,7 +1,5 @@
<% @nav_dispaly_course_all_label = 1
@nav_dispaly_forum_label = 1
@nav_dispaly_course_label = nil
@nav_dispaly_store_all_label = 1 %>
<% @nav_dispaly_project_label = 1
@nav_dispaly_forum_label = 1 %>
<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>

View File

@ -1,71 +0,0 @@
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= hubspot_head %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
</head>
<% if @project %>
<h3 class="title"><%= l(:label_projects_score) %></h3>
<div class="inf_user_image">
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
<tr>
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@project), :class => 'avatar2') %></td>
<td>
<table>
<tr class="info_font" align="center" style=" word-wrap: break-word; word-break: break-all"><td><%= @project.name %></td>
</tr>
</table>
</td>
<td width="35%">
<table>
<tr class="info_font"><td><%= l(:label_projects_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , project_scores(@project) ).to_i %></span></td></tr>
</table>
</td>
</tr>
</table>
</div>
<div class="tabs_new">
<ul>
<li>
<%= link_to l(:label_projects_score), {:controller => 'projects', :action => 'show_projects_score', :remote => true}%> :
<%= format("%.2f" , project_scores(@project) ).to_i %>
</li>
<li>
<%= link_to l(:label_issue_score), {:controller => 'projects', :action => 'issue_score_index', :remote => true}%> :
<%= format("%.2f" , issue_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_news_score), {:controller => 'projects', :action => 'news_score_index', :remote => true}%> :
<%= format("%.2f" , news_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> :
<%= format("%.2f" , documents_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> :
<%= format("%.2f" , changesets_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_topic_score), {:controller => 'projects', :action => 'projects_topic_score_index', :remote => true}%> :
<%= format("%.2f" , board_message_score(@project)).to_i %>
</li>
</ul>
</div>
<div id="show_score_detail">
<%= render :partial => 'projects/project_score_index', :locals => {:index => 0,:project => @project } %>
</div>
<% end %>

View File

@ -5,4 +5,4 @@
:action => 'show_new_score',
:remote => true,
:id => user.id
}, :style => 'color :#E8770D;',:id => 'user_score') %>
}, :style => 'color :#E8770D;',:id => 'user_score') %>

View File

@ -1572,6 +1572,7 @@ zh:
label_bidding_user: 应标人:
label_bidding_user_homework: 作业提交者
label_bidding_user_studentcode: 学号
label_bidding_user_studentname: 姓名
label_bidding_reason: 应标宣言:
label_bidding_reason_homewrok: 作业提交说明
label_username: 用户名:

View File

@ -641,6 +641,7 @@ RedmineApp::Application.routes.draw do
get 'file', :action => 'file', :as => 'file'
get 'feedback', :action => 'feedback', :as => 'course_feedback'
get 'member', :controller => 'courses', :action => 'member', :as => 'member'
get 'member_score', :to => 'courses#member_score'
post 'finishcourse'
post 'restartcourse'
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
@ -648,6 +649,7 @@ RedmineApp::Application.routes.draw do
match "updategroupname", :via => [:post, :get]
match "addgroups", :via => [:post, :get]
match 'deletegroup', :via => [:delete]
match 'show_member_score', :via => [:get]
post 'join_in/join_group', :to => 'courses#join_group', :as => 'join_group'
delete 'join_in/join_group', :to => 'courses#unjoin_group'
end

View File

@ -60,15 +60,15 @@ input.f_2 {
.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
a.st_img { display:block;width:40px; height:40px; border:1px solid #CCC; padding:1px;}
a:hover.st_img { border:1px solid #1c9ec7; }
.st_boxlist{ border-bottom:1px dashed #CCC; height:53px; padding-top:10px; }
.st_boxlist a{ float:left;}
.st_boxlist{ border-bottom:1px dashed #CCC; height:53px; padding-top:10px;padding-bottom: 10px; }
.st_boxlist a{ }
.st_boxlist ul{ float:left; width:200px; margin-left:10px;}
.st_boxlist ul li a{ color:#5d5d5d;}
.st_boxlist ul li a span{ color:#1c9ec7;}
.st_boxlist ul li a:hover span{ color:#ff8e15;}
.st_boxlist ul li a { color:#1c9ec7;}
.st_boxlist ul li a:hover{ color:#ff8e15;}
.ml50{ margin-left:50px;}
.ml358{ margin-left:358px;}
.ml258{ margin-left:254px;}
.ml358{ margin-left:360px;}
.ml258{ margin-left:110px;}
.ml65{ margin-left:65px;}
a:hover.st_add{ color:#ff8e15;}