提交作品

This commit is contained in:
cxt 2016-12-23 16:58:50 +08:00
parent 544702e11f
commit a03c0f68c2
19 changed files with 1162 additions and 22 deletions

View File

@ -5,7 +5,7 @@ class ContestantWorksController < ApplicationController
require 'bigdecimal'
require "base64"
before_filter :find_contestwork, :only => [:new, :index, :create, :new_student_work_project,:student_work_project,:cancel_relate_project,
:search_course_students,:work_canrepeat,:add_group_member,:change_project]
:delete_work,:search_contest_students,:work_canrepeat,:add_group_member,:change_project]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_contest, :only => [:new, :create, :show]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
@ -13,11 +13,80 @@ class ContestantWorksController < ApplicationController
before_filter :is_logged, :only => [:index]
def new
#更新消息
noEvaluation = @contestwork.contest_messages.where("user_id =? and viewed =?", User.current.id, 0)
noEvaluation.update_all(:viewed => true)
@user = User.current
@student_work = ContestantWork.new
respond_to do |format|
format.html{ render :layout => "base_contests"}
end
end
def index
# 作业消息状态更新?
work_messages = ContestMessage.where(:user_id => User.current.id, :viewed => 0, :contest_message_id => @contestwork.id, :contest_message_type => "Work")
work_messages.update_all(:viewed => true)
studentwork_messages = ContestMessage.where(:user_id => User.current.id, :viewed => 0, :contest_id => @contestwork.contest, :contest_message_type => "ContestantWork")
studentwork_messages.update_all(:viewed => true)
# 作品打分消息状态更新
#studentworks_scores = ContestMessage.where("user_id =? and contest_id =? and contest_message_type =? and viewed =?", User.current.id, @contestwork.contest, "StudentWorksScore", 0)
#studentworks_scores.update_all(:viewed => true)
# 作品评论消息状态更新
#journals_for_teacher = ContestMessage.where("user_id =? and contest_id =? and contest_message_type =? and viewed =?", User.current.id, @contestwork.contest, "JournalsForMessage", 0)
#journals_for_teacher.update_all(:viewed => true)
##################################################################################################################
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name].to_s.strip || "",params[:group]
@homework_commons = @contest.works.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
@all_homework_commons = @contest.works.order("created_at desc")
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.admin?
@is_judge = User.current.judge_of_contest?(@contest)
@show_all = false
if @is_teacher || @is_judge
# if @order == 'lastname'
# @stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
# elsif @order == 'student_id'
# @stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
# else
@stundet_works = @contestwork.contestant_works.no_copy.select("contestant_works.*,contestant_works.work_score as score").includes(:user => {:user_extensions => []}, :project => {}, :contestant_work_scores => {}).order("#{@order} #{@b_sort}")
#end
@show_all = true
elsif User.current.member_of_contest?(@contest)
if @contestwork.work_type == 3
pro = @contestwork.contestant_work_projects.where(:user_id => User.current.id).first
if pro.nil?
@stundet_works = []
else
@stundet_works = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => pro.contestant_work_id)
end
else
@stundet_works = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:user_id => User.current.id)
end
else
render_403
return
end
@student_work_count = @contestwork.contestant_works.has_committed.select("contestant_works.*,contestant_works.work_score as score").order("#{@order} #{@b_sort}").count
@score = @b_sort == "desc" ? "asc" : "desc"
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID
@message_student_work_id = params[:student_work_id]
@left_nav_type = 3
@tab = params[:tab].to_i
respond_to do |format|
format.js
format.html
# format.xls {
# filename = "#{@contest.user.lastname.to_s + @contest.user.firstname}_#{@contest.name}_#{@contestwork.name}#{l(:excel_homework_list)}.xls"
# send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
# :filename => filename_for_content_disposition(filename))
# }
end
end
def show
@ -25,7 +94,72 @@ class ContestantWorksController < ApplicationController
end
def create
# 提交作品前先判断是否已经提交
@has_commit = false;
if hsd_committed_work?(User.current.id, @contestwork.id)
@work = ContestantWork.where("user_id =? and work_id =?", User.current.id, @contestwork.id).first
@has_commit = true;
#flash[:notice] = l(:notice_successful_create)
#redirect_to edit_student_work_url(params[:student_work])
respond_to do |format|
format.js
end
return
end
if params[:student_work]
@submit_result = true
student_work = ContestantWork.find(params[:student_work_id]) if params[:student_work_id]
student_work ||= ContestantWork.new
student_work.name = params[:student_work][:name] == "#{@contestwork.name}的作品提交(可修改)" ? "#{@contestwork.name}的作品提交" : params[:student_work][:name]
student_work.description = params[:student_work][:description]
student_work.work_id = @contestwork.id
student_work.user_id = User.current.id
student_work.commit_time = Time.now
student_work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(student_work)
if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project
@student_work_project = @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first
student_work.project_id = @student_work_project.project_id
end
#提交作品时,计算是否迟交
student_work.work_status = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") ? 2 : 1
if student_work.save
if @contestwork.work_type == 3
if @contestwork.work_detail_group.base_on_project
@student_work_project.contestant_work_id = student_work.id
@student_work_project.save
else
stu_project = ContestantWorkProject.new(:work_id => @contestwork.id, :contestant_work_id => student_work.id, :project_id => student_work.project_id, :user_id => student_work.user_id, :is_leader => 1, :contest_id => @contestwork.contest_id)
stu_project.save
end
members = params[:group_member_ids].split(',')
for i in 1 .. members.count-1
stu_work = ContestantWork.new(:name => student_work.name, :description => student_work.description,:user_id =>members[i].to_i, :work_id => @contestwork.id, :project_id => student_work.project_id, :work_status => 3, :commit_time => student_work.commit_time)
if stu_work.save
stu_project = ContestantWorkProject.new(:work_id => @contestwork.id, :contestant_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :contest_id => @contestwork.contest_id)
stu_project.save
end
end
end
@contestwork.update_column(:updated_at, Time.now)
update_contest_activity(@contestwork.class,@contestwork.id)
update_user_activity(@contestwork.class,@contestwork.id)
contest_message = ContestMessage.new(:user_id =>User.current.id,:content=>"new",:contest_message_id=>student_work.id,:contest_id => @contest.id,:contest_message_type=>"ContestantWork", :status => 9) #作品提交记录
contest_message.save
@student_work = ContestantWork.where(work_id: @contestwork.id, user_id: User.current.id).first
respond_to do |format|
format.js
end
return
end
end
@submit_result = false
respond_to do |format|
format.js
end
end
def edit
@ -40,6 +174,72 @@ class ContestantWorksController < ApplicationController
end
def delete_work
@work = ContestantWork.where("user_id =? and work_id =?", User.current.id, @contestwork.id).first
if @work
@work.destroy
if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project
pros = @work.contestant_work_projects.where("is_leader = 0")
pros.each do |pro|
pro.destroy
end
project = @work.contestant_work_projects.where("is_leader = 1").first
project.update_attributes(:contestant_work_id => nil)
elsif @contestwork.work_type == 3 && !@contestwork.work_detail_group.base_on_project
@work.contestant_work_projects.each do |pro2|
pro2.destroy
end
end
end
redirect_to works_path(:contest => @contestwork.contest_id)
end
def retry_work
if @contestwork.work_type == 3
pros = @work.contestant_work_projects.where("is_leader = 0")
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
student_works = @contestwork.contestant_works.where("user_id in #{user_ids}")
student_works.delete_all
pros.delete_all
project = @work.contestant_work_projects.where("is_leader = 1").first
if @contestwork.work_detail_group.base_on_project
project.update_attributes(:contestant_work_id => nil)
else
project.destroy
end
end
@work.destroy
@work.attachments.destroy_all
@work.contest_messages.destroy_all
@student_work = ContestantWork.new
respond_to do |format|
format.js
end
end
#查找竞赛中的参赛者
def search_contest_students
name = ""
unless params[:name].nil?
name = params[:name]
end
if !@contestwork.work_detail_group.base_on_project
all_student_ids = "(" + @contestwork.contest.contestants.map{|student| student.student_id}.join(",") + ")"
else
pro = Project.find @contestwork.contestant_work_projects.where("user_id=?",User.current.id).first.project_id
all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")"
end
all_students = User.where("id in #{all_student_ids}")
student_work_id = @contestwork.contestant_work_projects.where("user_id=? and contestant_work_id is not null",User.current.id).first.nil? ? -1 : @contestwork.contestant_work_projects.where("user_id=?",User.current.id).first.contestant_work_id
@commit_student_ids = @contestwork.contestant_works.where("id != #{student_work_id}").map{|student| student.user_id}
@users = searchstudent_by_name all_students,name
respond_to do |format|
format.js
end
end
def new_student_work_project
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@ -80,6 +280,12 @@ class ContestantWorksController < ApplicationController
end
private
def hsd_committed_work?(user, homework)
sw = ContestantWork.where("user_id =? and work_id =?", user, homework).first
sw.nil? ? result = false : result = true
result
end
#获取题目
def find_contestwork
@contestwork = Work.find params[:work]

View File

@ -1344,22 +1344,6 @@ class StudentWorkController < ApplicationController
end
private
def searchstudent_by_name users, name
mems = []
if name != ""
name = name.to_s.downcase
users.each do |m|
username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
mems << m
end
end
else
mems = users
end
mems
end
def hsd_committed_work?(user, homework)
sw = StudentWork.where("user_id =? and homework_common_id =? and work_status != 0", user, homework).first
sw.nil? ? result = false : result = true

View File

@ -37,6 +37,21 @@ module ApplicationHelper
# super
# end
# 获取竞赛的管理人员
def contest_managers contest
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
end
# 获取竞赛的评委人员
def contest_judges contest
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
end
# 获取竞赛的参赛人员
def contest_contestants contest
contest.contest_members.select{|cm| cm.roles.to_s.include?("Contestant")}
end
# 获取多种类型的user用户名
def user_message_username user
user.try(:show_name)
@ -4022,6 +4037,22 @@ def visable_contest_work contest
work_num
end
def searchstudent_by_name users, name
mems = []
if name != ""
name = name.to_s.downcase
users.each do |m|
username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
mems << m
end
end
else
mems = users
end
mems
end
def add_reply_adapter obj, options
#modify by nwb
#添加对课程留言的支持

View File

@ -2,13 +2,16 @@ class ContestantWork < ActiveRecord::Base
belongs_to :work
belongs_to :user
belongs_to :project
attr_accessible :commit_time, :description, :is_delete, :name, :work_score, :work_status
attr_accessible :commit_time, :description, :is_delete, :name, :work_score, :work_status, :work_id, :user_id, :project_id
has_many :contestant_work_projects, :dependent => :destroy
has_many :contestant_work_scores, :dependent => :destroy
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
has_many :attachments, :dependent => :destroy
scope :has_committed, lambda{where("work_status != 0 and work_status != 3")}
scope :no_copy, lambda{where("work_status != 3")}
after_create :act_as_message
acts_as_attachable

View File

@ -4,5 +4,5 @@ class ContestantWorkProject < ActiveRecord::Base
belongs_to :contestant_work
belongs_to :project
belongs_to :user
attr_accessible :is_leader
attr_accessible :is_leader, :contest_id, :work_id, :contestant_work_id, :project_id, :user_id
end

View File

@ -1,5 +1,5 @@
class ContestantWorkScore < ActiveRecord::Base
belongs_to :contestant_work
belongs_to :user
attr_accessible :comment, :reviewer_role, :score
attr_accessible :comment, :reviewer_role, :score, :contestant_work_id, :user_id
end

View File

@ -0,0 +1,125 @@
<% if @contestwork.work_detail_group %>
<div id="popbox02">
<div>
<div class="relateText fl">请从<%= @contestwork.work_detail_group.base_on_project ? '项目成员':'竞赛成员' %>中添加小组成员</div>
</div>
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="clickCanel();"></a></div>
<div class="cl"></div>
<div>
<form class="resourcesSearchBox">
<input type="text" name="serach" placeholder="输入关键字搜索" class="searchResourcePopup" />
</form>
</div>
<ul class="addMemberC fl" id="all_students_list"></ul>
<div class="rightArrow"><img src="/images/course/right-arrow.png" width="16" height="30" /></div>
<ul class="addMemberC fr" id="choose_students_list">
<li id="choose_student_<%=User.current.id %>"><%=User.current.show_name %>
<% unless User.current.user_extensions.student_id == "" %>
(<%=User.current.user_extensions.student_id %>)
<% end %>
</li>
</ul>
<div class="cl"></div>
<div class="courseSendCancel mr15" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK()">确定</a></div>
<div class="cl"></div>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;
function search_stus(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'contestant_works', :action => 'search_contest_students') %>'+'?name='+ e.target.value+'&work='+<%=@contestwork.id %>,
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询
$("input[name='serach']").on('input', function (e) {
throttle(search_stus,window,e);
});
function clickOK() {
var str="";
var show = "合作成员:";
var lists = $("#choose_students_list li");
if(lists.length > 0) {
for(var i=0; i<lists.length; i++) {
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
str += id;
var show_name = $(lists[i]).html();
var index = show_name.indexOf("(");
if (index != -1) {
var name = show_name.substring(0,show_name.indexOf("("));
} else {
var name = show_name;
}
show += name;
if (i == 0) {
show += "(组长)";
}
if (i != lists.length -1) {
str += ",";
show += "、";
}
}
$("#group_member_ids").val(str);
}
hideModal("#popbox02");
$("#group_members_show").show().html(show);
}
function delete_student(id) {
$("#choose_student_"+id).remove();
$("#student_"+id).one("click",function choose_student() {
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
});
}
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'contestant_works', :action => 'search_contest_students') %>'+'?work='+<%=@contestwork.id %>,
type:'get'
});
var ids = $("#group_member_ids").val().split(',');
if (ids.length > 1){
for(var i=1; i<ids.length; i++) {
if($("#choose_student_"+ids[i]).length == 0) {
$.get(
'/student_work/get_user_infor',
{
user_id: ids[i]
},
function (data) {
if (data.valid) {
var link = "<li id='choose_student_"+data.id+"' onclick='delete_student("+data.id+");'>"+data.name;
if (data.student_id != "" ) {
link += "("+data.student_id+")";
}
link += "</li>";
$("#choose_students_list").append(link);
}
else
{
}
}
);
}
}
}
});
</script>
<% end %>

View File

@ -0,0 +1,56 @@
<div class="mt10">
<span id="attachments_fields" class="attachments_fields">
<% if defined?(container) && container && container.saved_attachments %>
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<div class="cl"></div>
<% end %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<div class="cl"></div>
<% end %>
<% end %>
</span>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => ie8? ? '' : 'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:style => ie8? ? '' : 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js',:project =>nil),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:lebel_file_uploding => l(:lebel_file_uploding),
:delete_all_files => l(:text_are_you_sure_all)
} %>
</div>
<div class="cl"></div>
<div class="mt5 fl">
<!-- , user_import_resource_user_path(User.current.id,:homework_id=>container.id) -->
<a href="javascript:void(0);" id="upload_file_local" class="AnnexBtn fl mt3 mr15" onclick="$('#_file').click();" title="请选择文件上传">上传附件</a>
</div>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>

View File

@ -0,0 +1,24 @@
<div id="popbox02">
<div class="ni_con">
<div><p align='center' style='margin-top: 35px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
编&nbsp;&nbsp;辑
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
取&nbsp;&nbsp;消
</a>
</div>
</div>
</div>
<script type="text/javascript">
function clickOK() {
window.location.href = '<%= edit_contestant_work_path(@work.id)%>';
}
function clickCanel() {
hideModal('#popbox02');
window.location.href = '<%= contestant_works_path(:work => @contestwork.id)%>';
}
</script>

View File

@ -0,0 +1,44 @@
<div id="popbox02">
<div class="ni_con">
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
<p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
<div class="fb fl dis">作品描述:</div>
<div id="worksDescription" class="upload_img fl" style="max-width: 330px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>
<span class="fl c_red"><%= "无附件"%></span>
<% else %>
<div class="fl grey_c">
<% @student_work.attachments.each_with_index do |attachment,i| %>
<div id="attachment_<%= attachment.id%>">
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
<div class="cl"></div>
</div>
<% end -%>
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
</div>
<% end %>
</p>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
确&nbsp;定
</a>
<%= link_to("重 试", retry_work_contestant_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
</div>
</div>
</div>
<script type="text/javascript">
function clickOK() {
window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/contestant_work?work=" + "<%= @contestwork.id%>&tab=2"
}
</script>

View File

@ -0,0 +1,96 @@
<div class="homepagePostPortrait">
<%=link_to image_tag(url_to_avatar(homework.user),width:"50px", height: "50px"), user_activities_path(homework.user_id)%>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4">
<%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%>
</div>
<div class="homepagePostTitle hidden fl m_w505">
<% index = get_work_index(homework, is_teacher) %>
<%= link_to "<span class='fontBlue2'>题目#{index + 1}</span>".html_safe + homework.name,contestant_works_path(:work => homework.id),:class => "postGrey"%>
</div>
<%=get_cw_status(homework).html_safe %>
<div class="cl"></div>
<% if homework.work_type == 3 && work.work_detail_group.base_on_project %>
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
<% elsif homework.work_type == 3 && !homework.work_detail_group.base_on_project%>
<span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
<% end %>
<% is_pro = homework.homework_type == 2 && is_teacher %>
<% is_base_group = homework.homework_type == 3 && (homework.homework_detail_group.base_on_project == 1 || !(cur_user_works_for_homework(homework).nil?)) && !is_teacher %>
<div class="mt8 mb5">
<%= render :partial => 'users/homework_opr', :locals => {:activity => homework, :is_teacher => is_teacher, :hw_status => 5, :user_activity_id => homework.id} %>
<% if is_pro || is_base_group %>
<div class="cl"></div>
<% end %>
<% if !homework.publish_time.nil? %>
<div class="homepagePostDeadline <%= (is_pro || is_base_group) ? 'mt8' : '' %>">
<%= l(:label_publish_time)%><%= homework.publish_time%>&nbsp;00:00
</div>
<% end %>
<% if !homework.end_time.nil? %>
<div class="homepagePostDeadline ml15 <%= (is_pro || is_base_group) ? 'mt8' : '' %>">提交截止时间:<%= homework.end_time.to_s %>&nbsp;23:59</div>
<% end %>
<div class="cl"></div>
</div>
<div class="homeworkInfo" id="homeworkInformation">
<div class="">
<div class="homeworkDetail upload_img break_word list_style" id="homeworkDetail">
<div id="homework_description">
<%= homework.description.html_safe %>
</div>
</div>
<% if is_pro %>
<div class="mt10"> <span class="fontGrey3">测试集:<%=homework.homework_tests.count %>组</span>
<table class="mt5 test-set-table">
<tr>
<th width="25">&nbsp;</th>
<th width="290" style="max-width:290px;">测试集输入</th>
<th width="290" style="max-width:290px;">测试集输出</th>
</tr>
<% homework.homework_tests.each_with_index do |test, i| %>
<tr>
<td class="test_td_min"><%=i+1 %></td>
<td><pre style="max-width:290px; word-wrap:break-word; white-space:pre-wrap;"><%=test.input %></pre></td>
<td><pre style="max-width:290px; word-wrap:break-word; white-space:pre-wrap;"><%=test.output %></pre></td>
</tr>
<% end %>
</table>
</div>
<% end %>
<div class="cl"></div>
<div class="mt5">
<% if homework.homework_detail_manual%>
<% if homework.homework_detail_manual.comment_status == 1%>
<% end_time = homework.end_time.to_time.to_i + 24*60*60 - 1 %>
<% if end_time >= Time.now.to_i %>
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
<% else %>
<div class="fontGrey2 db fr c_red">提交已截止</div>
<% end %>
<% elsif homework.homework_detail_manual.comment_status == 2%>
<% end_time = homework.homework_detail_manual.evaluation_end.to_time.to_i + 24*60*60 - 1 %>
<% if end_time >= Time.now.to_i %>
<div class="fontGrey2 db fr">匿评剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60)%></span> 天
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
<% else %>
<div class="fontGrey2 db fr c_red">匿评已截止</div>
<% end %>
<% end%>
<% end%>
<div class="cl"></div>
</div>
</div>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework} %>
</div>
<%= render :partial => "users/homework_base_info", :locals =>{:activity => homework, :user_activity_id =>homework.id, :is_teacher => is_teacher, :hw_status => 5} %>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,24 @@
<% if @has_commit %>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'has_commit_work') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
<% elsif @submit_result%>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'work_information') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='/student_work/"+ <%=@student_work.id%> +"/retry_work' class='upload_btn' data-remote='true'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
<% else %>
window.location.href = '<%= new_contestant_work_path(:work => @contestwork.id)%>';
<% end %>
function clickCanel() {
hideModal('#popbox02');
window.location.href = '<%= contestant_works_path(:work => @contestwork.id)%>';
}

View File

@ -0,0 +1,190 @@
<% content_for :header_tags do %>
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
<%= javascript_include_tag "resizeable_table" %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<% is_group_project_homework = @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
$("#Container").css("width","1000px");
<% if @tab == 2%>
$("#student_work_tab2").click();
<% elsif @tab == 3 %>
$("#student_work_tab3").click();
<% end %>
sd_create_editor_from_data(<%= @contestwork.id %>, null, "100%", "<%= @contestwork.class.to_s %>");
});
function HoverLi(n){
for(var i=1;i<=3;i++){
$('#student_work_tab'+i).removeClass('selected');
$('#student_work_con'+i).addClass('undis');
}
$('#student_work_tab'+n).addClass('selected');
$('#student_work_con'+n).removeClass('undis');
}
$("#moreProject_<%=@contestwork.id %>").click(function(){
$("#relatePWrap_<%=@contestwork.id %>").toggleClass('relatePWrap');
$("#relatePWrap_<%=@contestwork.id %>").css("height","auto");
$(this).hide();
});
$("#hideProject_<%=@contestwork.id %>").click(function(){
$("#relatePWrap_<%=@contestwork.id %>").toggleClass('relatePWrap');
$("#moreProject_<%=@contestwork.id %>").show();
});
// 匿评弹框提示
<%# if @is_evaluation && !@stundet_works.empty?%>
// $(function(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
// showModal('ajax-modal', '500px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
// $('#ajax-modal').parent().css("top","").css("left","");
// $('#ajax-modal').parent().addClass("anonymos");
// });
<%# end%>
// function set_score_rule_submit() {
// if($("#late_penalty_num").val() == ""){
// $("#late_penalty_num").val("0");
// }
// if($("#absence_penalty_num").val() == ""){
// $("#absence_penalty_num").val("0");
// }
// $('#muban_popup_box').find('form').submit();
// hideModal();
// }
// //设置评分规则
// function set_score_rule(){
<!--<%# if @homework.homework_type == 2 %>-->
<!--<%# if @homework.anonymous_comment == 0 %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 570, 355);
<!--<%# else %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 285);
<!--<%# end %>-->
<!--<%# else %>-->
<!--<%# if @homework.anonymous_comment == 0 %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_non_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 325);
<!--<%# else %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_none_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 225);
<!--<%# end %>-->
<!--<%# end %>-->
// }
</script>
<div class="homepageRight mt0 ml10">
<div class="resources" id="homework_page_right">
<div class="hworkListBanner">
<div id="menu_r" class="fl">
<ul class="menu_r">
<li>
<a href="javascript:void(0);" class="parent">
<% if @is_teacher %>
<% hcommons = @all_homework_commons %>
<% else %>
<% hcommons = @homework_commons %>
<% end %>
<% hcommons.each_with_index do |homework_common,index |%>
<% if homework_common.id == @contestwork.id %>
<%="作业 #{hcommons.count - index}" %>
<% end %>
<% end%>
</a>
<ul>
<% hcommons.each_with_index do |homework_common,index |%>
<li class="pr10">
<%= link_to "作业#{hcommons.count - index}#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%>
<%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
</li>
<% end%>
</ul>
</li>
<!---level1 end--->
</ul>
<!---menu_r end--->
</div>
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
<% if @is_teacher%>
<div class="fr mt5">
<ul class="">
<li class="pr export_icon_li">
<a href="javascript:void(0);" class="export_icon linkBlue2">导出</a>
<ul class="hworkMenu" style="top: 30px; left: -100px;">
<!--<li>-->
<!--<%#= link_to "导出作业成绩", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :group => @group, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>-->
<!--</li>-->
<li>
<% if @contestwork.contestant_works.empty?%>
<%= link_to "导出作业附件", "javascript:void(0)", class: "hworkExport resourcesGrey", :onclick => "alert('没有学生提交作业,无法下载附件')" %>
<% else%>
<%= link_to "导出作业附件", zipdown_assort_path(obj_class: @contestwork.class, obj_id: @contestwork, format: :json),
remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %>
<% end%>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
<div class="cl"></div>
</div>
<ul class="homework-detail-tab mb10 mt15 fb">
<li class="selected" id="student_work_tab1" onclick="HoverLi(1);">
<a href="javascript:void(0);" class="fontGrey3">题目信息</a>
</li>
<li onclick="HoverLi(2);" id="student_work_tab2">
<a href="javascript:void(0);" class="fontGrey3">作品列表</a>
</li>
<% if is_group_project_homework %>
<li onclick="HoverLi(3);" id="student_work_tab3">
<a href="javascript:void(0);" class="fontGrey3">关联项目列表</a>
</li>
<li style="width:415px;">&nbsp;</li>
<% else %>
<li style="width:515px;">&nbsp;</li>
<% end %>
</ul>
<div id="student_work_con1">
<div class="homepagePostBrief" id="homework_post_brief">
<%= render :partial => 'work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher} %>
</div>
<%= render :partial => 'users/contest_work_post_reply', :locals => {:activity => @contestwork, :user_activity_id => @contestwork.id, :hw_status => 3, :is_teacher => @is_teacher} %>
<div class="cl"></div>
</div>
<div class="undis" id="student_work_con2">
<div class="hworkListContainer">
<div class="ctt2">
<div class="dis" id="homework_student_work_list">
<%= render :partial => "student_work/student_work_list"%>
</div>
</div>
</div>
</div>
<% if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
<div class="undis" id="student_work_con3">
<% student_work_ids = @contestwork.contestant_works.has_committed.blank? ? "(-1)" : "(" + @contestwork.contestant_works.has_committed.map{|st| st.id}.join(",") + ")" %>
<% student_work_projects = @contestwork.contestant_work_projects.where("contestant_work_id in #{student_work_ids} or contestant_work_id is null") %>
<% project_ids = student_work_projects.blank? ? "(-1)" : "(" + student_work_projects.map{|pro| pro.project_id}.join(",") + ")" %>
<% projects = Project.where("id in #{project_ids}").order("updated_on desc") %>
<%= render :partial => "student_work/relate_projects", :locals => {:projects => projects}%>
</div>
<% end %>
</div>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,310 @@
<!-- 此界面只用来新建匿评作业作品 -->
<% content_for :header_tags do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<script type="text/javascript">
$(function(){
if(is_IE()){
$("#_notice_box").show();
$("#uploadReviseBox").addClass('disable_link');
$("#upload_file_local").attr("title","IE无法上传");
$("#upload_file_local").attr("onclick","return false;");
$("#resource_repo_upload").attr("title","IE无法上传");
$("#resource_repo_upload").attr("href","javascript:void(0)");
}
});
<% if @contestwork.work_detail_group %>
$(function(){
$('span.group_detail_info').text('分组人数:<%=@contestwork.work_detail_group.min_num %>-<%=@contestwork.work_detail_group.max_num %> 人');
});
<% end %>
// //快速创建项目的弹框
// function new_project(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/new_project') %>');
// showModal('ajax-modal', '800px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
// $('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed").css("border","3px solid #269ac9");
// }
// // 点击 checkbox选中引用的资源的时候保存该资源的id到session里去
// function store_seleted_resource(dom){
// if(dom.attr('checked') == 'checked' ){
// $.get(
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=y&res_id='+dom.val()
// )
// }else {
// $.get(
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=n&res_id='+dom.val()
// )
// }
// }
// 添加组成员
function show_group_member() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'choose_group_member',:locals => {:homework=>@contestwork}) %>');
showModal('ajax-modal', '528px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("addMemberCP");
}
// 关联项目
function show_project() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'relate_project',:locals => {:homework=>@contestwork}) %>');
showModal('ajax-modal', '320px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("groupPopUp");
}
// 作品校验
function popupRegex(){
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
}
function nh_check_field(params){
var result=true;
if(!regexStudentWorkName()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
params.contentmsg.html('作品描述不能为空');
}else{
params.contentmsg.html('');
}
}
if(!result) {
return result;
}
}
if($("#group_member_ids").length > 0) {
result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())));
}
return result;
}
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
popupRegex();
return true;
}else{
$(this)[0].submit();
$("#ajax-indicator").hide();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterBlur:function(){
if(this.isEmpty()) {
this.edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
}
},
afterFocus: function(){
var edit = this.edit;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
edit.html('');
}
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(editor2,'student_work_<%=@contestwork.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='student_work_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form);
params.contentmsg = $("#student_work_description_textarea");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
editor2 = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
$("#ajax-indicator").hide();
});
params.textarea.data('init', 1);
}
});
});
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner mb10 ml10">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="cl"></div>
<div class="_notice_box text_c none mb10" style="height: 20px; padding: 4px 4px; line-height: 20px;" id="_notice_box">注意暂不支持IE浏览器的上传请更换浏览器</div>
<div class="HomeWork" id="users_setting">
<div class="HomeWorkBox">
<div class="">
<div class="homepagePostTitle fl m_w530 hidden">
<%= @contestwork.name%>(竞赛名称)
</div>
<span class="fr c_grey">
截止时间:<%= @contestwork.end_time%>
</span>
<div class="cl"></div>
<a href="javascript:void(0);" class="c_blue">
<%= link_to @contestwork.user.show_name, user_activities_path(@contestwork.user_id), :class => "c_blue"%>
</a>
<div class="cl"></div>
<div class="HomeWorkP break_word">
<%= @contestwork.description.html_safe %>
</div>
<div>
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @contestwork.attachments} %>
<div class="cl"></div>
</div>
</div>
</div><!----HomeWorkBox end-->
<div class="cl"></div>
<div class="HomeWorkCon mt15" nhname='student_work_form'>
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'contestant_works',
:action => 'create',
:work => @contestwork.id
},:remote=>true ) do |f| %>
<div class="cl"></div>
<% if @contestwork.work_type == 3 %>
<span id="min_num_member" style="display: none"><%=@contestwork.work_detail_group.min_num %></span>
<span id="max_num_member" style="display: none"><%=@contestwork.work_detail_group.max_num %></span>
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
<% end %>
<div>
<input type="text" name="student_work[name]" id="student_work_name" class="InputBox fl W700" maxlength="200" onkeyup="regexStudentWorkName();" placeholder="请输入作品名称" value="<%=@contestwork.name %>的作品提交(可修改)">
<div class="cl"></div>
<p id="student_work_name_span" class="c_red mb10"></p>
</div>
<div class="mt10">
<textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"></textarea>
<%#= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
<!--<script>
var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用
</script>-->
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red mb10"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div>
<div class="mt10 mb10">
<span class="fl fontGrey2 group_detail_info"></span>
<div class="cl"></div>
<span class="fl fontGrey2" id="group_members"></span>
<div class="cl"></div>
<% if @contestwork && @contestwork.work_type == 3 %>
<sapn class="fl fontGrey2" id="group_members_show">
合作成员:<%= User.current.show_name %>(组长)
</sapn>
<span id="student_work_group_textarea" class="ml10 c_red fl"></span>
<% end %>
<div class="cl"></div>
<span class="fl fontGrey2" id="relate_project_show">
<% if @contestwork && @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
<% unless @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").empty? %>
<% project = Project.find @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first.project_id %>
关联项目:<%= project.name %>
<% end %>
<% end %>
</span>
</div>
<div class="cl"></div>
<div id="homework_attachments">
<%= render :partial => 'contestant_work_attachment', :locals => {:container => @student_work} %>
</div>
<div id="group_member">
</div>
<div id="relate_project">
</div>
<% if @contestwork.work_type == 3 %>
<div class="fl mt5">
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="请添加小组的其他成员" onclick="show_group_member();">合作成员</a>
</div>
<% end %>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">提交</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消", delete_work_contestant_works_path(:work =>@contestwork.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
</div>
<div class="cl"></div>
<% end%>
</div><!----HomeWorkCon end-->
</div>
</div>

View File

@ -0,0 +1,3 @@
hideModal('#popbox02');
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'contestant_work_attachment', :locals => {:container => @work})%>");
$("#group_member_ids").val("<%=User.current.id %>");

View File

@ -0,0 +1,42 @@
$("#all_students_list").empty();
<% @users.each do |user|%>
var link = "<li id='student_<%=user.id %>'><%=user.show_name %>";
<% unless user.user_extensions.student_id == "" %>
link += "(<%=user.user_extensions.student_id %>)";
<% end %>
link += "</li>";
$("#all_students_list").append(link);
var str = $("#group_member_ids").val();
var choose_str = "";
var lists = $("#choose_students_list li");
if(lists.length > 0) {
for(var i=0; i<lists.length; i++) {
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
choose_str += id;
if (i != lists.length -1) {
choose_str += ",";
}
}
}
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.contestant_of_contest?(@contest) %>
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
li += " onclick='delete_student(<%=user.id %>);'";
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
$("#choose_students_list").append(li);
});
}
<% elsif !user.contestant_of_contest?(@contest) %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该项目成员不是本竞赛的参赛者");
}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该成员已加入其它分组");
}
<% end %>
<% end %>

View File

@ -2,7 +2,7 @@ hideModal("#popbox02");
<% if @hw_status == 5 %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'contestant_works/work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher}) %>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_homework', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% end %>
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");

View File

@ -590,10 +590,12 @@ RedmineApp::Application.routes.draw do
post 'student_work_project'
get 'new_student_work_project'
get 'cancel_relate_project'
get 'delete_work'
get 'search_contest_students'
end
member do
get 'retry_work'
end
end