From b1463f08644ab8000b847515e9141d91bc4cf7bc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 9 Sep 2015 16:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E4=BD=9C=E4=B8=9A=E4=BD=9C=E5=93=81=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/views/student_work/new.html.erb | 251 ++++++++-------------------- public/javascripts/new_user.js | 94 ++++++++++- public/stylesheets/new_user.css | 9 +- 4 files changed, 172 insertions(+), 184 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f4a70117f..4c78c03df 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2359,7 +2359,7 @@ module ApplicationHelper link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' else if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 - link_to "修改作品", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" + link_to "作品已交", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" elsif homework.homework_type == 2 #编程作业不能修改作品 link_to "作品已交", student_work_index_path(:homework => homework.id),:class => 'c_blue',:title => "编程作业不可修改作品" else diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index f0f4d8e7c..703447756 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,8 +1,8 @@ + <% content_for :header_tags do %> <%= javascript_include_tag 'homework','baiduTemplate' %> <% end %> -<% if @homework.homework_type == 1 %> -
-
-
提交作品
-
-
-
-
- <%= form_for(@student_work, - :html => { :multipart => true }, - :url => {:controller => 'student_work', - :action => 'create', - :homework => @homework.id - }) do |f|%> -
- <% if @homework.homework_type == 1%> -
- 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息 -
- <% end%> -

- - <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> - <% if @homework.homework_type != 2%> - - 项目信息 - - - <% end%> -

-

-

-
-

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

-
-

- - <% if @homework.homework_type == 2 && @homework.homework_detail_programing%> - <%= f.text_area "description", :class => "w620 hwork_txt h400", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => @homework.homework_detail_programing.language == "1" ? c_stantard_code_student : c_stantard_code_student_%> - <% else %> - <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%> - <% end%> -

-

-

-
- <% if @homework.homework_type != 2%> -

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

-
- <% end%> -

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

-

-
- <% end%> -
-
-
-
-
-<% else %> +
+
提交作品
+
+
+
- - - +
+ +
+
+ <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :homework => @homework.id + }) do |f|%> +
+ 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息 +
+
-
-
-
提交作品
+
+ <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %> +
+

+
+
+ <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%> +
+

-
-
-
<%= @homework.name %>
截止时间:<%= @homework.end_time %> -
- <%= @homework.user.show_name %> -

<%= @homework.description %>
-输入 2 1 1 4 4 2 3 6 5
-输出 15
-

-
-

注:迟交扣2分,缺评一个作品扣2

-
-
- <%= form_for(@student_work, - :html => { :multipart => true }, - :url => {:controller => 'student_work', - :action => 'create', - :student_work_id => @student_work.id, - :homework => @homework.id - }, - :method => :post) do |f|%> -
- 请使用 <%= @homework.language_name %> 语言编写 -
-
- <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %> -
-
- <%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"请贴入你的代码", rows: 10 %> -
- - <% end %> -
-
-
- <% @student_work.student_work_tests.each_with_index do |test, index| %> -
-

第<%= @student_work.student_work_tests.count - index%>次测试

<%= test.created_at.to_s(:db) %> -
-
- <% if test.status.to_i == -2 %> -
<%= test.results.first %>
- <% else %> -
-
    - <% test.results.each_with_index do |x, i| %> -
  • 测试<%=i+1%> - <% if x["status"].to_i != 0 %> - 测试错误! - 您的输出: - <%=x["result"]%> - 正确输出: - <%=x["output"]%> -
    -
  • - <% else %> - 测试正确! -
    - - <% end %> - <% end %> -
-
- <% end %> - <% end %> -
+
+ <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> +
-<% end %> +
+ 确定 + + <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> +
+
+ <% end%> +
+
diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index fdf739bd0..9ffbf8b93 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -177,4 +177,96 @@ function regexStudentWorkDescription() $("#student_work_description_textarea").text(""); return true; } -} \ No newline at end of file +} + +//textarea自适应高度 +(function($){ + + $.fn.autoResize = function(options) { + + // Just some abstracted details, + // to make plugin users happy: + var settings = $.extend({ + onResize : function(){}, + animate : true, + animateDuration : 150, + animateCallback : function(){}, + extraSpace : 20, + limit: 1000 + }, options); + + // Only textarea's auto-resize: + this.filter('textarea').each(function(){ + + // Get rid of scrollbars and disable WebKit resizing: + var textarea = $(this).css({resize:'none','overflow-y':'hidden'}), + + // Cache original height, for use later: + origHeight = textarea.height(), + + // Need clone of textarea, hidden off screen: + clone = (function(){ + + // Properties which may effect space taken up by chracters: + var props = ['height','width','lineHeight','textDecoration','letterSpacing'], + propOb = {}; + + // Create object of styles to apply: + $.each(props, function(i, prop){ + propOb[prop] = textarea.css(prop); + }); + + // Clone the actual textarea removing unique properties + // and insert before original textarea: + return textarea.clone().removeAttr('id').removeAttr('name').css({ + position: 'absolute', + top: 0, + left: -9999 + }).css(propOb).attr('tabIndex','-1').insertBefore(textarea); + + })(), + lastScrollTop = null, + updateSize = function() { + + // Prepare the clone: + clone.height(0).val($(this).val()).scrollTop(10000); + + // Find the height of text: + var scrollTop = Math.max(clone.scrollTop(), origHeight) + settings.extraSpace, + toChange = $(this).add(clone); + + // Don't do anything if scrollTip hasen't changed: + if (lastScrollTop === scrollTop) { return; } + lastScrollTop = scrollTop; + + // Check for limit: + if ( scrollTop >= settings.limit ) { + $(this).css('overflow-y','hidden'); + return; + } + // Fire off callback: + settings.onResize.call(this); + + // Either animate or directly apply height: + settings.animate && textarea.css('display') === 'block' ? + toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback) + : toChange.height(scrollTop); + }; + + // Bind namespaced handlers to appropriate events: + textarea + .unbind('.dynSiz') + .bind('keyup.dynSiz', updateSize) + .bind('keydown.dynSiz', updateSize) + .bind('change.dynSiz', updateSize); + + }); + + // Chain: + return this; + + }; + + + +})(jQuery); \ No newline at end of file diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index df6d4d632..780fb72b7 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -895,6 +895,8 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r .HomeWorkBox{ background:#f6f6f6; padding:10px; margin:10px 0;} .c_grey{ color:#888888;} .HomeWorkP{ width:690px; font-size:14px;} +.HomeWorkP p{background-color: transparent !important;} +.HomeWorkP div{background-color: transparent !important;} .H150{ height:150px;} .ProResult{width:748px; background-color:#fff; border:1px solid #dddddd;border-bottom:none; } .ProResultTop{ height:38px; line-height:38px; border-bottom:1px solid #dddddd; background:#f2f2f2; padding:0 10px;} @@ -903,10 +905,11 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r .W200{ width:200px;} .ProResultTable{ color:#888888;} .T_C{ text-align:center;} -.SearchIcon{background:url(../images/homepage_icon.png) 676px -393px no-repeat; } -.SearchIcon:hover{background:url(../images/homepage_icon.png) 676px -419px no-repeat; } +.SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; } +.SearchIcon:hover{background:url(../images/homepage_icon2.png) 676px -419px no-repeat; } a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} +a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;} a.FilesName{ max-width:540px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;} a.FilesName02{ max-width:665px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis; display:block;} .ProResultUl span { display:block; float:left;} @@ -1001,7 +1004,7 @@ blockquote { } /* 创建作品 work */ -.Newwork{ width:668px; height:418px;} +.Newwork{ width:668px;} .N_top{ float:right; margin-left:390px; } .N_con{ color:#484747; font-weight:bold; width:660px; margin-top:10px; } .N_con p{ }