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 @@