diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index e3424707f..6f2ecef0b 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -223,17 +223,19 @@ class HomeworkCommonController < ApplicationController
homework_test = HomeworkTest.find id
homework_test.destroy if homework_test
end
- if params[:input] && params[:output]
+ if params[:input] && params[:output] && params[:result]
params[:input].each do |k,v|
if params[:output].include? k
homework_test = HomeworkTest.find_by_id k
if homework_test #已存在的测试,修改
homework_test.input = v
homework_test.output = params[:output][k]
+ homework_test.result = params[:result][k]
else #不存在的测试,增加
homework_test = HomeworkTest.new
homework_test.input = v
homework_test.output = params[:output][k]
+ homework_test.result = params[:result][k]
homework_test.homework_common = @homework
end
homework_test.save
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index a971787d1..49865d335 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -333,40 +333,45 @@ module UsersHelper
end
def get_create_course_count(user)
- if user == User.current
- user.courses.count
- else
- user.courses.where("is_public = 1").count
- end
+ user.courses.visible.where("tea_id = ?",user.id).count
end
+ #获取加入课程数
def get_join_course_count(user)
- user.coursememberships.count - get_create_course_count(user)
+ user.courses.visible.count - get_create_course_count(user)
end
+ #发布作业数
def get_homework_commons_count(user)
HomeworkCommon.where("user_id = ?",user.id).count
end
+ #资源数
def get_projectandcourse_attachment_count(user)
Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
end
+
+ #创建项目数
def get_create_project_count(user)
- Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count
+ user.projects.visible.where("projects.user_id=#{user.id}").count
end
+ #加入项目数
def get_join_project_count(user)
- user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user)
+ user.projects.visible.count - get_create_project_count(user)
end
+ #创建缺陷数
def get_create_issue_count(user)
Issue.where("author_id = ?",user.id).count
end
+ #解决缺陷数
def get_resolve_issue_count(user)
Issue.where("assigned_to_id = ? and status_id=3",user.id).count
end
+ #参与匿评数
def get_anonymous_evaluation_count(user)
StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
end
diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb
index 4ed290ecd..df2848194 100644
--- a/app/models/homework_test.rb
+++ b/app/models/homework_test.rb
@@ -1,5 +1,5 @@
class HomeworkTest < ActiveRecord::Base
- attr_accessible :input, :output, :homework_common_id
+ attr_accessible :input, :output, :homework_common_id,:result,:error_msg
belongs_to :homework_common
has_many :student_work_test
diff --git a/app/models/user.rb b/app/models/user.rb
index 005c394a8..2271adc18 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -418,7 +418,7 @@ class User < Principal
end
def nickname(formatter = nil)
- login
+ login.nil? || (login && login.empty?) ? "AnonymousUser" : login
end
def name(formatter = nil)
diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb
index f880ce945..0542f2a0c 100644
--- a/app/views/courses/_set_join.js.erb
+++ b/app/views/courses/_set_join.js.erb
@@ -1,11 +1,11 @@
<% if object_id%>
$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(course, user)) %>");
- $("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品");
<% end %>
<% if @state %>
<% if @state == 0 %>
alert("加入成功");
hideModal($("#popbox02"));
+ $("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品");
<% elsif @state == 1 %>
alert("密码错误");
<% elsif @state == 2 %>
diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb
index 5e53c4b15..22ca4cac7 100644
--- a/app/views/homework_common/_homework_detail_programing_form.html.erb
+++ b/app/views/homework_common/_homework_detail_programing_form.html.erb
@@ -78,7 +78,7 @@
-
+
@@ -96,8 +96,16 @@
- 测试
-
+ <% if homework_test.result && !homework_test.result.to_s.empty?%>
+ <% if homework_test.result == 0%>
+ 成功
+ <% else%>
+ 错误
+ <% end%>
+ <% else%>
+ 测试
+ <% end%>
+
@@ -115,7 +123,7 @@
- 测试
+ 测试
@@ -142,4 +150,12 @@
}
);
}
+
+ function init_programing_test()
+ {
+ $(".programing_test").each(function(){
+ $(this).removeClass("green_btn red_btn").addClass("blue_btn").text("测试");
+ $(this).next("input").val("");
+ });
+ }
\ No newline at end of file
diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb
index 74ec9439a..8f76642f1 100644
--- a/app/views/homework_common/programing_test.js.erb
+++ b/app/views/homework_common/programing_test.js.erb
@@ -1,2 +1,2 @@
-$("#test_send_<%= @index%>").replaceWith(" fl ml5 mt1' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%>");
+$("#test_send_<%= @index%>").replaceWith(" fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%>");
$("#test_result_<%= @index%>").val("<%= @result%>");
\ No newline at end of file
diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb
index 33973b047..acd9c238e 100644
--- a/app/views/layouts/base_users_new.html.erb
+++ b/app/views/layouts/base_users_new.html.erb
@@ -171,11 +171,11 @@
- <% if !@user.user_extensions.nil? && @user.user_extensions.identity == 0 %>
- <% if(get_create_course_count(@user)) == 0 %>
+ <% if @user.user_extensions && @user.user_extensions.identity == 0 %>
+ <% if(get_create_course_count(@user)) != 0 %>
- 创建课程 :
<% end %>
- <% if(get_homework_commons_count(@user)) == 0 %>
+ <% if(get_homework_commons_count(@user)) != 0 %>
- 发布作业 :
<% end %>
<% end %>
@@ -202,11 +202,11 @@
<% end %>
- <% if !@user.user_extensions.nil? && @user.user_extensions.identity == 0 %>
- <% if(get_create_course_count(@user)) == 0 %>
+ <% if @user.user_extensions && @user.user_extensions.identity == 0 %>
+ <% if(get_create_course_count(@user)) != 0 %>
- <%= get_create_course_count(@user) %>
<% end %>
- <% if(get_homework_commons_count(@user)) == 0 %>
+ <% if(get_homework_commons_count(@user)) != 0 %>
- <%= get_homework_commons_count(@user) %>
<% end %>
<% end %>
diff --git a/app/views/users/_user_jour_reply.html.erb b/app/views/users/_user_jour_reply.html.erb
index ee94cb35a..60eda9fcd 100644
--- a/app/views/users/_user_jour_reply.html.erb
+++ b/app/views/users/_user_jour_reply.html.erb
@@ -3,9 +3,9 @@
<%= link_to image_tag(url_to_avatar(reply.user),:width => '32',:height => '32'), user_path(reply.user),:class => "users_pic_sub fl mr5" %>
- <%= link_to "#{reply.user.login} ".html_safe, user_path(reply.user),:class => 'course_name fl c_blue02 ', :target => "_blank"%>
+ <%= link_to "#{reply.user.nickname} ".html_safe, user_path(reply.user),:class => 'course_name fl c_blue02 ', :target => "_blank"%>
回复
- <%= link_to "#{parent_jour.user.login} : ".html_safe, user_path(parent_jour.user),:class => 'course_name fl c_blue02 mr5 ', :target => "_blank"%>
+ <%= link_to "#{parent_jour.user.nickname} : ".html_safe, user_path(parent_jour.user),:class => 'course_name fl c_blue02 mr5 ', :target => "_blank"%>
<%= reply.notes.html_safe %>
diff --git a/app/views/users/_user_jours_new.html.erb b/app/views/users/_user_jours_new.html.erb
index 9a9e14787..0fe301641 100644
--- a/app/views/users/_user_jours_new.html.erb
+++ b/app/views/users/_user_jours_new.html.erb
@@ -1,8 +1,8 @@
-
+
<%= link_to image_tag(url_to_avatar(jour.user),:width => '46',:height => '46'), user_path(jour.user),:class => "users_pic fl" %>
- <%= link_to "#{jour.user.login} : ".html_safe, user_path(jour.user),:class => 'fl c_blue02 f14 fb mb5', :target => "_blank"%>
+ <%= link_to "#{jour.user.nickname} : ".html_safe, user_path(jour.user),:class => 'fl c_blue02 f14 fb mb5', :target => "_blank"%>
diff --git a/config/locales/account/zh.yml b/config/locales/account/zh.yml
index 69edc7aa3..c7c76707d 100644
--- a/config/locales/account/zh.yml
+++ b/config/locales/account/zh.yml
@@ -37,7 +37,7 @@ zh:
label_password_lost: "忘记密码?"
button_login: 登录
# account_controller中判断用户名或密码输入有误的提示信息
- notice_account_invalid_creditentials: "无效的用户名或密码"
+ notice_account_invalid_creditentials: "无效的用户名或密码,注意登录名区分大小写,谢谢!"
# account_controller中判断未激活的提示信息
notice_account_invalid_creditentials_new: "您还未到邮箱激活。如果您丢失帐户,电子邮件验证帮助我们的支持团队验证帐户的所有权,并允许您接收所有您要求的通知。"
diff --git a/db/migrate/20150801034945_change_result_default.rb b/db/migrate/20150801034945_change_result_default.rb
new file mode 100644
index 000000000..1f629aa45
--- /dev/null
+++ b/db/migrate/20150801034945_change_result_default.rb
@@ -0,0 +1,9 @@
+class ChangeResultDefault < ActiveRecord::Migration
+ def up
+ change_column :homework_tests,:result,:integer,:default => nil
+ end
+
+ def down
+ change_column :homework_tests,:result,:integer,:default => 0
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 29aeb1f16..30ca29d12 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20150730130816) do
+ActiveRecord::Schema.define(:version => 20150801034945) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -632,9 +632,9 @@ ActiveRecord::Schema.define(:version => 20150730130816) do
t.text "input"
t.text "output"
t.integer "homework_common_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.integer "result", :default => 0
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "result"
t.text "error_msg"
end
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index c7b01cee1..6ba202b28 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -550,7 +550,7 @@ function add_programing_test(obj) {
"
- " +
"
- " +
"" +
- "测试" +
+ "测试" +
"" +
"
");
}