新建作品功能,以及相关js验证
This commit is contained in:
parent
6ac97f2c34
commit
56723d106f
|
@ -12,6 +12,7 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@stundet_work = StudentWork.new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
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="Newwork">
|
||||||
<div class="hwork_ctt">
|
<div class="hwork_ctt">
|
||||||
<div class="hwork_dis" id="tbc_01">
|
<div class="hwork_dis" id="tbc_01">
|
||||||
<div class="N_con">
|
<%= form_for(@stundet_work,
|
||||||
<p>
|
:html => { :multipart => true },
|
||||||
<label class="fl"><span class="c_red">*</span> 作品名称 :</label>
|
:url => {:controller => 'student_work',
|
||||||
<input id="" type="text" name="" class=" bo mb10 fl" placeholder="作品名称">
|
:action => 'create',
|
||||||
<a href="#" class="fl ml10 mt3" onclick="show_project();" >项目信息<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于 网络的协作空间,能够为个人 或小组提供分布式的协同交流 和资料管理等方面的。"></a>
|
:homework => @homework.id
|
||||||
</p>
|
}) do |f|%>
|
||||||
<div class="cl"></div>
|
<div class="N_con">
|
||||||
<p id="about_project" class="about_project" >
|
<p>
|
||||||
<label class="fl"> 关联项目 :</label>
|
<label class="fl"><span class="c_red">*</span> 作品名称 :</label>
|
||||||
<select name="" id="" class=" bo02 mb10">
|
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
|
||||||
<option value="1">没有可选项目,请直接为本作品创建一个项目</option>
|
<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>
|
||||||
<option value="2">M</option>
|
<div class="cl"></div>
|
||||||
</select>
|
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
|
||||||
<!--a class=" ml10 mt3 c_orange" href="javascript:void(0)" onClick="show_window();">快速创建</a-->
|
</p>
|
||||||
</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>
|
|
||||||
</p>
|
|
||||||
<div class="cl"></div>
|
|
||||||
<p>
|
|
||||||
<label> 添加附件 :</label>
|
|
||||||
<input type="submit" name="" value="文件浏览" class="sub_btn" > <span class="c_grey">-文件不超过200MB</span>
|
|
||||||
</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>
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</p>
|
<p id="about_project" class="about_project" >
|
||||||
</div><!---创建作业内容结束-->
|
<label class="fl"> 关联项目 :</label>
|
||||||
|
<%= 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>
|
||||||
|
<%= 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 class="fl"> 添加附件 :</label>
|
||||||
|
<%= render :partial => 'attachments/new_form' %>
|
||||||
|
</p>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<p class="ml80 ">
|
||||||
|
<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>
|
</div>
|
||||||
</div><!--新建作业结束-->
|
</div><!--新建作业结束-->
|
||||||
|
|
|
@ -603,4 +603,51 @@ function show_more_reply(contentid, id2, id3) {
|
||||||
information.attr("value", "show_more");
|
information.attr("value", "show_more");
|
||||||
arrow.attr("src", "/images/jiantou.jpg")
|
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