This commit is contained in:
huang 2015-09-02 21:48:27 +08:00
commit 719cbee3ef
12 changed files with 224 additions and 120 deletions

View File

@ -142,10 +142,14 @@ class StudentWorkController < ApplicationController
end
def new
@user = User.current
@student_work = @homework.student_works.where("user_id = ?",User.current.id).first
if @student_work.nil?
@student_work = StudentWork.new
end
respond_to do |format|
format.html{ render :layout => "new_base_user"}
end
end
def create
@ -186,11 +190,12 @@ class StudentWorkController < ApplicationController
end
def edit
@user = User.current
if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
render_403
else
respond_to do |format|
format.html
format.html{ render :layout => "new_base_user"}
end
end
end

View File

@ -1,4 +1,6 @@
# encoding: utf-8
include UserScoreHelper
module StudentWorkHelper
def user_projects_option
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"

View File

@ -23,6 +23,7 @@
<% end %>
<% end %>
</span>
<div class="cl"></div>
<% project = project %>
<span class="add_attachment" style="font-weight:normal;">
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %>

View File

@ -10,6 +10,7 @@
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
.ke-container{height: 80px !important;}
</style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %>
<script >

View File

@ -28,7 +28,6 @@
<%= homework_anonymous_comment(homework)%>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %>
<%#= link_to(l(:button_edit),edit_homework_common_path(homework), :class => "fr mr10 work_edit") %>
<%= link_to(l(:button_edit),"javascript:void(0)", :class => "fr mr10 un_work_edit",:title => "编辑功能正在维护中") %>
<% elsif @is_student%>
<%= student_anonymous_comment homework %>
<%= student_new_homework homework %>

View File

@ -1,52 +1,54 @@
<div class="project_r_h">
<h2 class="project_h2">编辑作品</h2>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= labelled_form_for @work,:html => { :multipart => true } do |f|%>
<div class="N_con">
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="student_work[name]" id="student_work_name" class="bo fl" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
<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="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<div class="cl"></div>
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">编辑作品</div>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= labelled_form_for @work,:html => { :multipart => true } do |f|%>
<div class="N_con">
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="student_work[name]" id="student_work_name" class="bo fl" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
<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="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</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" style="<%= @work.project.nil? ? '' : 'display:block;'%>">
<label class="fl">&nbsp;&nbsp;&nbsp;关联项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project,options_for_select(user_projects_option,@work.project_id), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p id="about_project" class="about_project" style="<%= @work.project.nil? ? '' : 'display:block;'%>">
<label class="fl">&nbsp;&nbsp;&nbsp;关联项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project,options_for_select(user_projects_option,@work.project_id), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p>
<label class="fl">
<span class="c_red">*</span>
&nbsp;作品描述&nbsp;&nbsp;&nbsp;&nbsp;
</label>
<textarea name="student_work[description]" placeholder="最多3000个汉字(或6000个英文字符)" id="student_work_description" class="w620 hwork_txt" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form',:locals => {:container => @work} %>
</p>
<div class="cl"></div>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="edit_student_work(<%= @work.id%>);">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
<p>
<label class="fl">
<span class="c_red">*</span>
&nbsp;作品描述&nbsp;&nbsp;&nbsp;&nbsp;
</label>
<textarea name="student_work[description]" placeholder="最多3000个汉字(或6000个英文字符)" id="student_work_description" class="w620 hwork_txt" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form',:locals => {:container => @work} %>
</p>
<div class="cl"></div>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white mt10" onclick="edit_student_work(<%= @work.id%>);">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white mt10 ml10"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
</div>
</div>
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
</div>

View File

@ -124,7 +124,6 @@
</h4>
<% if @is_teacher%>
<%= homework_anonymous_comment(@homework)%>
<%= link_to(l(:button_edit),"javascript:void(0)", :class => "fr mr10 un_work_edit",:title => "编辑功能正在维护中") %>
<% else%>
<%= student_anonymous_comment @homework %>
<%= student_new_homework @homework %>

View File

@ -17,75 +17,77 @@
});
<% end%>
</script>
<div class="project_r_h">
<h2 class="project_h2">创建作品</h2>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:homework => @homework.id
}) do |f|%>
<div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:homework => @homework.id
}) do |f|%>
<div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<% end%>
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
<% if @homework.homework_type != 2%>
<a href="javascript:void(0)" class="fl ml10 mt3" onclick=" $('#about_project').slideToggle();" >
项目信息
<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<% end%>
<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">&nbsp;&nbsp;&nbsp;选择项目&nbsp;&nbsp;&nbsp;&nbsp;</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>&nbsp;
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<% 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%>
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<% if @homework.homework_type != 2%>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form' %>
</p>
<div class="cl"></div>
<% end%>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white mt10" onclick="new_student_work();">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white mt10 ml10"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
<% if @homework.homework_type != 2%>
<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="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<% end%>
<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">&nbsp;&nbsp;&nbsp;选择项目&nbsp;&nbsp;&nbsp;&nbsp;</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>&nbsp;
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<% 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%>
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<% if @homework.homework_type != 2%>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form' %>
</p>
<div class="cl"></div>
<% end%>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="new_student_work();">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".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 class="cl"></div>
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
<% else %>
@ -125,8 +127,8 @@
</script>
<!-- 模板1结束 -->
<div class="homepageRight">
<div class="HomeWork">
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
@ -201,6 +203,5 @@
<% end %>
<% end %>
</div><!----ProResult end-->
</div><!--homepageRight end-->
<% end %>

View File

@ -8,6 +8,7 @@
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
.ke-container{height: 80px !important;}
</style>
<div >
<div class="homepageRightBanner mb10">

View File

@ -1,6 +1,6 @@
function init_editor(params){
var editor = params.kindutil.create(params.textarea, {
resizeType : 0,minWidth:"1px",width:"100%",minHeight:"28px",
resizeType : 1,minWidth:"1px",width:"100%",height:"80px",
items:['emoticons'],
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});

View File

@ -131,4 +131,50 @@ function search_homework_by_name(url){
function (data) {
}
);
}
//提交新建作品
function new_student_work()
{
if(regexStudentWorkName()&&regexStudentWorkDescription())
{$("#new_student_work").submit();}
}
function edit_student_work(id)
{
if(regexStudentWorkName()&&regexStudentWorkDescription())
{$("#edit_student_work_" + id).submit();}
}
//验证作品名称
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;
}
}

View File

@ -187,7 +187,7 @@ a:hover.grey_n_btn{ background:#717171; color:#fff;}
.green_btn{ background:#28be6c; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;}
a.green_btn{background:#28be6c;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;}
a:hover.green_btn{ background:#14ad5a;}
.blue_btn{ background:#64bdd9; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;}
.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;}
a.blue_btn{background:#64bdd9;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;}
a:hover.blue_btn{ background:#329cbd;}
a.orange_btn{ background:#ff5722;color:#fff; font-weight:normal; padding:2px 10px; text-align:center; }
@ -954,3 +954,50 @@ blockquote {
background-color: #e8e8e8;
}
/* 创建作品 work */
.Newwork{ width:668px; height:418px;}
.N_top{ float:right; margin-left:390px; }
.N_con{ color:#484747; font-weight:bold; width:660px; margin-top:10px; }
.N_con p{ }
.w430{ width:470px;}
.w557{ width:557px;}
.w350{ width:350px;}
.h400{height: 400px !important;}
.w620{ width:480px; height:160px; border:1px solid #CCC;}
.bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; }
.bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; }
.hwork_txt{ width:560px; padding-left:5px; background:#fff;}
a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:10px;}
a:hover.tijiao{ background:#0f99a9;}
.members_left{ float:left; width:410px; margin-right:20px; text-align:center;}
.members_left{}
.members_left ul li{ height:30px; border-bottom:1px solid #E4E4E4; width:410px; padding-top:10px; }
.members_left ul li a{ float:left; text-align:center;}
.members_left ul li span{ float:left; text-align:center; color:#484747;}
.w150{ text-align:center; width:150px;min-height: 10px;}
.f_b{ font-weight: bold;}
.members_right label{ margin-left:15px;}
.N_search{ height:20px; border:1px solid #999;}
/* 创建作品 homework */
.hwork_new{ color:#4c4c4c;}
.c_red{ color:#F00;}
.hwork_input{ border:1px solid #64bdd9; height:22px; width:88%; background:#fff; margin-bottom:10px; padding:5px;}
.hwork_input02{ border:1px solid #64bdd9; height:15px; width:140px; background:#fff; margin-bottom:10px; padding:5px;}
.hwork_text{ border:1px solid #64bdd9; height:100px;width:555px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
.hwork_new ul li{ }
.ml21{ margin-left:21px;}
.ml9{ margin-left:9px;}
.hwork_ttl{height:24px;}
.hwork_ctt{height:auto; padding-left:10px;clear:both;}
.hwork_tb_{ border-bottom:3px solid #e4e4e4; text-align:center;}
.hwork_tb_ ul{height:24px;}
.hwork_tb_ li{float:left;height: 24px;width: auto; padding:0 10px;cursor:pointer;}
.hwork_normaltab { color:#15bccf ; border-bottom:3px solid #e4e4e4; }
.hwork_hovertab { color:#656767; font-weight:bold; border-bottom:3px solid #15bccf; }
.hwork_dis{display:block; }
.hwork_undis{display:none;}
.project_none{ display:none;}
.about_project{ overflow:hidden;display:none;}
.project_r_h{ width:670px; height:40px; background:#eaeaea; margin-bottom:10px;}
.project_r_h02{ width:920px; height:40px; background:#eaeaea; margin-bottom:10px;}