Merge branch 'szzh' into develop
This commit is contained in:
commit
cf1b78b42b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
<% end %>
|
||||
<% if @state %>
|
||||
<% if @state == 0 %>
|
||||
alert("加入成功");
|
||||
hideModal($("#popbox02"));
|
||||
$("#try_join_course_link").replaceWith("<a href='<%=url_for(:controller => 'homework_common', :action => 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品</a>");
|
||||
<% elsif @state == 1 %>
|
||||
alert("密码错误");
|
||||
<% elsif @state == 2 %>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
|
||||
<li >
|
||||
<label class="label02"> 标准代码: </label>
|
||||
<textarea name="standard_code" class=" w547 h150 mb10 fl"><%= homework.homework_detail_programing.standard_code%></textarea>
|
||||
<textarea name="standard_code" class=" w547 h150 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code%></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
|
||||
|
@ -96,8 +96,16 @@
|
|||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<a class="blue_btn fl ml5 mt1" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
|
||||
<input type="hidden" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" />
|
||||
<% if homework_test.result && !homework_test.result.to_s.empty?%>
|
||||
<% if homework_test.result == 0%>
|
||||
<a class="green_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">成功</a>
|
||||
<% else%>
|
||||
<a class="red_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">错误</a>
|
||||
<% end%>
|
||||
<% else%>
|
||||
<a class="blue_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
|
||||
<% end%>
|
||||
<input type="hidden" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" value="<%= homework_test.result%>"/>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -115,7 +123,7 @@
|
|||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<a class="blue_btn fl ml5 mt1" onclick="programing_test('0')" id="test_send_0">测试</a>
|
||||
<a class="blue_btn fl ml5 mt programing_test" onclick="programing_test('0')" id="test_send_0">测试</a>
|
||||
<input type="hidden" id="test_result_0" name="result[0]" />
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
|
@ -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("");
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -1,2 +1,2 @@
|
|||
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
|
||||
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
|
||||
$("#test_result_<%= @index%>").val("<%= @result%>");
|
|
@ -171,11 +171,11 @@
|
|||
|
||||
<div class="leftbox">
|
||||
<ul class="leftbox_ul_left">
|
||||
<% 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 %>
|
||||
<li>创建课程 :</li>
|
||||
<% end %>
|
||||
<% if(get_homework_commons_count(@user)) == 0 %>
|
||||
<% if(get_homework_commons_count(@user)) != 0 %>
|
||||
<li>发布作业 :</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -202,11 +202,11 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
<ul class="leftbox_ul_right c_dgrey">
|
||||
<% 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 %>
|
||||
<li><%= get_create_course_count(@user) %></li>
|
||||
<% end %>
|
||||
<% if(get_homework_commons_count(@user)) == 0 %>
|
||||
<% if(get_homework_commons_count(@user)) != 0 %>
|
||||
<li><%= get_homework_commons_count(@user) %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
<div class="mes_box02" id = '<%= reply.id %>'>
|
||||
<%= link_to image_tag(url_to_avatar(reply.user),:width => '32',:height => '32'), user_path(reply.user),:class => "users_pic_sub fl mr5" %>
|
||||
<div class=" mes_box02_info fl">
|
||||
<%= 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"%>
|
||||
<span class="fl c_grey"> 回复 </span>
|
||||
<%= 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"%>
|
||||
<div class="cl">
|
||||
<%= reply.notes.html_safe %>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="message_list" id="<%= jour.id %>" nhname="rec" data-id="<%= jour.id %>">
|
||||
<div class="message_list break_word" id="<%= jour.id %>" nhname="rec" data-id="<%= jour.id %>">
|
||||
<%= link_to image_tag(url_to_avatar(jour.user),:width => '46',:height => '46'), user_path(jour.user),:class => "users_pic fl" %>
|
||||
<div class="fl ml5 mes_box mb10" >
|
||||
<div>
|
||||
<%= 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"%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
|
|
|
@ -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: "您还未到邮箱激活。如果您丢失帐户,电子邮件验证帮助我们的支持团队验证帐户的所有权,并允许您接收所有您要求的通知。"
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ function add_programing_test(obj) {
|
|||
"</li><li ><label class='fl f14 ml10'> 输出: </label><input type='text' class='fl h26 w190 mb10' name='output[" + now +"]' />" +
|
||||
"</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
|
||||
"<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
|
||||
"<a class='blue_btn fl ml5 mt1' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
|
||||
"<a class='blue_btn fl ml5 mt1 programing_test' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
|
||||
"<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]'/>" +
|
||||
"</li><div class='cl'></div></div>");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue