新建作品功能,以及相关js验证
This commit is contained in:
parent
6ac97f2c34
commit
56723d106f
|
@ -12,6 +12,7 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@stundet_work = StudentWork.new
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module StudentWorkHelper
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
memberships = User.current.memberships.all(:conditions => cond)
|
||||
projects = memberships.map(&:project)
|
||||
not_have_project = []
|
||||
not_have_project << Setting.please_chose
|
||||
not_have_project << 0
|
||||
type = []
|
||||
type << not_have_project
|
||||
projects.each do |project|
|
||||
if project != nil
|
||||
option = []
|
||||
option << project.name
|
||||
option << project.id
|
||||
type << option
|
||||
end
|
||||
end
|
||||
type
|
||||
end
|
||||
end
|
|
@ -4,37 +4,45 @@
|
|||
<div class="Newwork">
|
||||
<div class="hwork_ctt">
|
||||
<div class="hwork_dis" id="tbc_01">
|
||||
<%= form_for(@stundet_work,
|
||||
:html => { :multipart => true },
|
||||
:url => {:controller => 'student_work',
|
||||
:action => 'create',
|
||||
:homework => @homework.id
|
||||
}) do |f|%>
|
||||
<div class="N_con">
|
||||
<p>
|
||||
<label class="fl"><span class="c_red">*</span> 作品名称 :</label>
|
||||
<input id="" type="text" name="" class=" bo mb10 fl" placeholder="作品名称">
|
||||
<a href="#" class="fl ml10 mt3" onclick="show_project();" >项目信息<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于 网络的协作空间,能够为个人 或小组提供分布式的协同交流 和资料管理等方面的。"></a>
|
||||
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
|
||||
<a href="javascript:void(0)" class="fl ml10 mt3" onclick="show_project();" >项目信息<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于 网络的协作空间,能够为个人 或小组提供分布式的协同交流 和资料管理等方面的。"></a>
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<p id="about_project" class="about_project" >
|
||||
<label class="fl"> 关联项目 :</label>
|
||||
<select name="" id="" class=" bo02 mb10">
|
||||
<option value="1">没有可选项目,请直接为本作品创建一个项目</option>
|
||||
<option value="2">M</option>
|
||||
</select>
|
||||
<!--a class=" ml10 mt3 c_orange" href="javascript:void(0)" onClick="show_window();">快速创建</a-->
|
||||
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<label class="fl"><span class="c_red">*</span> 作品描述 :</label>
|
||||
<textarea id="" name="" placeholder="最多3000个汉字(或6000个英文字符)" class="w620 hwork_txt mb10 " ></textarea>
|
||||
<%= f.text_area "description", :class => "w620 hwork_txt ", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexStudentWorkDescription();"%>
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<p>
|
||||
<label> 添加附件 :</label>
|
||||
<input type="submit" name="" value="文件浏览" class="sub_btn" > <span class="c_grey">-文件不超过200MB</span>
|
||||
<label class="fl"> 添加附件 :</label>
|
||||
<%= render :partial => 'attachments/new_form' %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<p class="ml80 ">
|
||||
<a href="#" target="_blank" class="blue_btn fl c_white">提交作品</a><a href="#" target="_blank" class="blue_btn grey_btn fl c_white">重 置</a>
|
||||
<a href="javascript:void(0)" target="_blank" class="blue_btn fl c_white" onclick="new_student_work();">提交作品</a>
|
||||
<%= link_to "返 回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%>
|
||||
<div class="cl"></div>
|
||||
</p>
|
||||
</div><!---创建作业内容结束-->
|
||||
<% end%>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--新建作业结束-->
|
||||
|
|
|
@ -604,3 +604,50 @@ function show_more_reply(contentid, id2, id3) {
|
|||
arrow.attr("src", "/images/jiantou.jpg")
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//学生作品
|
||||
function show_project()
|
||||
{
|
||||
$("#about_project").slideToggle();
|
||||
}
|
||||
|
||||
//验证作品名称
|
||||
function regexStudentWorkName()
|
||||
{
|
||||
var name = $.trim($("#student_work_name").val());
|
||||
|
||||
if(name=="")
|
||||
{
|
||||
$("#student_work_name_span").text("作品名称不能为空");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#student_work_name_span").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function regexStudentWorkDescription()
|
||||
{
|
||||
var name = $.trim($("#student_work_description").val());
|
||||
|
||||
if(name=="")
|
||||
{
|
||||
$("#student_work_description_textarea").text("作品描述不能为空");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#student_work_description_textarea").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//提交新建作品
|
||||
function new_student_work()
|
||||
{
|
||||
if(regexStudentWorkName()&®exStudentWorkDescription())
|
||||
{$("#new_student_work").submit();}
|
||||
}
|
Loading…
Reference in New Issue