Merge branch 'develop' into szzh

This commit is contained in:
huang 2015-11-30 14:34:13 +08:00
commit 031715ce28
12 changed files with 101 additions and 46 deletions

View File

@ -81,8 +81,10 @@ class Comment < ActiveRecord::Base
# 课程成员得分(英雄榜)
def act_as_student_score
unless self.author.allowed_to?(:as_teacher, self.commented.course)
course_member_score(self.commented.course.id, self.author_id, "NewReply")
if self.commented.course
unless self.author.allowed_to?(:as_teacher, self.commented.course)
course_member_score(self.commented.course.id, self.author_id, "NewReply")
end
end
end

View File

@ -287,13 +287,15 @@ class Message < ActiveRecord::Base
# 课程成员得分(英雄榜)
def act_as_student_score
unless self.author.allowed_to?(:as_teacher, self.course)
if self.parent_id.nil?
# 发帖
course_member_score(self.course.id, self.author_id, "Message")
else
# 回帖
course_member_score(self.course.id, self.author_id, "MessageReply")
if self.course
unless self.author.allowed_to?(:as_teacher, self.course)
if self.parent_id.nil?
# 发帖
course_member_score(self.course.id, self.author_id, "Message")
else
# 回帖
course_member_score(self.course.id, self.author_id, "MessageReply")
end
end
end
end

View File

@ -20,7 +20,7 @@
<a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));">
保存
</a>
<a class="btn_cancel" data-button="cancel" onclick="resetHead();pollsCancel();">
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">
<%= l(:button_cancel)%>
</a>
</div>
@ -35,6 +35,6 @@
$("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>");
$("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>");
/*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/
document.getElementById("exercise_description").innerText = <%=exercise.exercise_description.html_safe %>;
document.getElementById("exercise_description").innerHTML = <%=exercise.exercise_description.html_safe %>;
}
</script>

View File

@ -212,7 +212,7 @@
<% contributor_course_scor(@course.id).each do |contributor_score| %>
<% unless contributor_score.total_score ==0 %>
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a>
<p><a href="javascript:void:(0);"><%=link_to contributor_score.user, user_path(contributor_score.user), :title => contributor_score.user %></a></p>
<p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p>
<p><span class="c_green" style="cursor:pointer">
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p>
<div style="display: none" class="numIntro">
@ -244,9 +244,9 @@
<ul class="rankList">
<h4>课程英雄榜</h4>
<% hero_homework_scores.each do |student_score| %>
<% unless student_score.score.nil? %>
<% if student_score.score != 0 %>
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a>
<p><a href="javascript:void:(0);"><%=link_to student_score.user, user_path(student_score.user), :title => student_score.user %></a></p>
<p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p>
<p><span class="c_red" style="cursor:pointer" title="作业总分:<%= student_score.score %>"><%= student_score.score.to_i %></span></p>
</li>
<% end %>

View File

@ -1,16 +1,16 @@
<%= form_tag(
{:controller => 'repositories', :action => 'diff', :id => project,
:repository_id => @repository.identifier_param, :path => to_path_param(path)},
:method => :get
:method => :get
) do %>
<table class="list changesets">
<!--<thead><tr>-->
<!--<th>#</th>-->
<!--<th></th>-->
<!--<th></th>-->
<!--<th><%= l(:label_date) %></th>-->
<!--<th><%= l(:field_author) %></th>-->
<!--<th><%= l(:field_comments) %></th>-->
<!--<th>#</th>-->
<!--<th></th>-->
<!--<th></th>-->
<!--<th><%= l(:label_date) %></th>-->
<!--<th><%= l(:field_author) %></th>-->
<!--<th><%= l(:field_comments) %></th>-->
<!--</tr></thead>-->
<tbody>
@ -24,6 +24,7 @@
<strong class="str-truncated">
<a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a>
</strong>
<div class="pull-right" title="修订号">
<%= h truncate(changeset.short_id.to_s, :length => 20) %>
</div>
@ -31,13 +32,29 @@
</div>
</div>
<div class="commit-row-info">
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
<%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %>
<%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time> &nbsp;
</div>
<% if !user_commit_rep(changeset.author_email).nil? %>
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
<%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %>
<%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>
</time>
&nbsp;
</div>
<% else %>
<span class="commit-author-name"><%= changeset.author_email %></span>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %>
</time>
&nbsp;
</div>
<% end %>
</div>
</li>
</ul>
@ -50,7 +67,7 @@
</p>
<ul class="wlist">
<%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%>
<%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true %>
</ul>
<% end %>

View File

@ -0,0 +1,5 @@
class AddIndexToHomeworkCommons < ActiveRecord::Migration
def change
add_index :homework_commons, [:course_id, :id]
end
end

View File

@ -0,0 +1,5 @@
class AddIndexToStudentWorks < ActiveRecord::Migration
def change
add_index :student_works, [:homework_common_id, :user_id]
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 => 20151126160252) do
ActiveRecord::Schema.define(:version => 20151130033906) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -736,6 +736,8 @@ ActiveRecord::Schema.define(:version => 20151126160252) do
t.integer "anonymous_comment", :default => 0
end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
create_table "homework_detail_manuals", :force => true do |t|
t.float "ta_proportion"
t.integer "comment_status"
@ -961,6 +963,7 @@ ActiveRecord::Schema.define(:version => 20151126160252) do
t.integer "course_group_id", :default => 0
end
add_index "members", ["course_id"], :name => "index_members_on_course_id"
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"
@ -1506,6 +1509,8 @@ ActiveRecord::Schema.define(:version => 20151126160252) do
t.boolean "is_test", :default => false
end
add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id"
create_table "student_works_evaluation_distributions", :force => true do |t|
t.integer "student_work_id"
t.integer "user_id"

View File

@ -0,0 +1,13 @@
namespace :delete_evalution do
desc "delete evaluation"
task :delete => :environment do
homework = HomeworkCommon.where("id = 844").first
homework.homework_detail_manual.update_column('comment_status', 3)
student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first
student_work_score.destroy
student_work_9203 = StudentWork.where("id = 28088").first
student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first
student_work_9203.update_column("student_score",91)
student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework.homework_detail_manual.absence_penalty)
end
end

View File

@ -60,7 +60,7 @@ namespace :homework_evaluation do
work_ids = "(" + homework_common.student_works.map(&:id).join(",") + ")"
homework_common.student_works.each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manuals.absence_penalty : 0
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
homework_detail_manual.update_column('comment_status', 3)

View File

@ -6,24 +6,30 @@ namespace :gitlab do
users = User.find_by_sql("select * from users where gid is null")
s = Trustie::Gitlab::Sync.new
g = Gitlab.client
logger = Logger.new('./log/add_gid.log', 'daily') #按天生成
users.each do |user|
us = g.get("/users?search=#{user.mail}")
puts user.mail
if us.blank?
puts "55555555555555555"
s.sync_user(user)
else
# 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com
puts "66666666666666666666"
puts user.id
if Array === us
us.each do |u|
if u.email == user.mail
user.gid = u.id
user.save
begin
us = g.get("/users?search=#{user.mail}")
puts user.mail
if us.blank?
puts "55555555555555555"
s.sync_user(user)
else
# 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com
puts "66666666666666666666"
puts user.id
if Array === us
us.each do |u|
if u.email == user.mail
user.gid = u.id
user.save
end
end
end
end
rescue => e
logger.error("userid=#{user.id},mail=#{user.mail},login=#{user.login},error=#{e}")
puts e
end
end
end

View File

@ -9,7 +9,7 @@ namespace :sync_rep do
if project.repositories && project.repositories.count == 1 && project.repositories.first.type == "Repository::Git"
rep = project.repositories.first
count = Repository.find_by_sql("SELECT * FROM `repositories` where identifier = '#{rep.identifier}'").count
puts count
puts project.id
unless count > 1
rep.identifier
s = Trustie::Gitlab::Sync.new