diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index aa8bf28bb..e75646353 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -12,6 +12,7 @@ class StudentWorkController < ApplicationController end def new + @stundet_work = StudentWork.new respond_to do |format| format.html end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb new file mode 100644 index 000000000..467cbcdce --- /dev/null +++ b/app/helpers/student_work_helper.rb @@ -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 \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index dbd549c4c..fc645c26d 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -4,37 +4,45 @@
-
-

- - - 项目信息 -

-
-

- - - -

-
-

- - -

-
-

- -     -文件不超过200MB -

-
-

- 提交作品重  置 + <%= form_for(@stundet_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :homework => @homework.id + }) do |f|%> +

+

+ + <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> + 项目信息 +

+

+

-

-
+

+ + <%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %> +

+
+

+ + <%= f.text_area "description", :class => "w620 hwork_txt ", :maxlength => 3000, :placeholder => "最多3000个汉字", :onkeyup => "regexStudentWorkDescription();"%> +

+

+

+
+

+ + <%= render :partial => 'attachments/new_form' %> +

+
+

+ 提交作品 + <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> +

+

+
+ <% end%>
diff --git a/public/javascripts/course.js b/public/javascripts/course.js index a2bfcfc82..c1f105c1f 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -603,4 +603,51 @@ function show_more_reply(contentid, id2, id3) { information.attr("value", "show_more"); 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();} } \ No newline at end of file