From 56723d106fdec3ee360301eb9f867a8c1ece645b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 May 2015 11:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BD=9C=E5=93=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3js?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 1 + app/helpers/student_work_helper.rb | 21 +++++++ app/views/student_work/new.html.erb | 68 ++++++++++++---------- public/javascripts/course.js | 47 +++++++++++++++ 4 files changed, 107 insertions(+), 30 deletions(-) create mode 100644 app/helpers/student_work_helper.rb 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"%> +
+ +