Merge branch 'szzh' into develop

This commit is contained in:
sw 2015-07-21 15:41:25 +08:00
commit 8b9d9df766
13 changed files with 102 additions and 71 deletions

View File

@ -514,6 +514,8 @@ private
end
def has_login
render_403 unless User.current.logged?
unless @attachment && @attachment.container_type == "PhoneAppVersion"
render_403 unless User.current.logged?
end
end
end

View File

@ -18,28 +18,28 @@ class HomeworkCommonController < ApplicationController
end
def new
@homework_type = "1"
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
@homework.late_penalty = 0
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
if @homework_type == "1"
#匿评作业相关属性
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
@homework_detail_manual.absence_penalty = 0
@homework_detail_manual.evaluation_num = 3
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.homework_detail_manual = @homework_detail_manual
elsif @homework_type == "2"
#编程作业相关属性
@homework_detail_programing = HomeworkDetailPrograming.new
@homework.homework_detail_programing = @homework_detail_programing
end
# @homework_type = "1"
#
# @homework = HomeworkCommon.new
# @homework.safe_attributes = params[:homework_common]
# @homework.late_penalty = 0
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
#
# if @homework_type == "1"
# #匿评作业相关属性
# @homework_detail_manual = HomeworkDetailManual.new
# @homework_detail_manual.ta_proportion = 0.6
# @homework_detail_manual.absence_penalty = 0
# @homework_detail_manual.evaluation_num = 3
# @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
# @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
# @homework.homework_detail_manual = @homework_detail_manual
# elsif @homework_type == "2"
# #编程作业相关属性
# @homework_detail_programing = HomeworkDetailPrograming.new
# @homework.homework_detail_programing = @homework_detail_programing
# end
respond_to do |format|
format.html
end
@ -93,7 +93,7 @@ class HomeworkCommonController < ApplicationController
if homework.homework_type == 2
homework_detail_programing = HomeworkDetailPrograming.new
homework_detail_programing.language = "C++"
homework_detail_programing.language = params[:language]
homework_detail_programing.standard_code = params[:standard_code]
homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6
question = {title:homework.name,content:homework.description}

View File

@ -128,7 +128,7 @@ class StudentWorkController < ApplicationController
solutions = {
student_work_id:stundet_work.id,
src:Base64.encode64(stundet_work.description),
language:1
language:@homework.homework_detail_programing.language
}
uri = URI(url)
body = solutions.to_json

View File

@ -1824,7 +1824,9 @@ module ApplicationHelper
def attachment_candown attachment
candown = false
if attachment.container
if attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
if attachment.container.class.to_s=="PhoneAppVersion"
candown = true
elsif attachment.container.class.to_s != "HomeworkAttach" && attachment.container.class.to_s != "StudentWork" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
project = attachment.container.project
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif attachment.container.is_a?(Project)
@ -1850,8 +1852,7 @@ module ApplicationHelper
candown = true
elsif attachment.container.class.to_s=="StudentWork"
candown = true
elsif attachment.container.class.to_s=="PhoneAppVersion"
candown = true
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses
course = attachment.container.courses.first
candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1)

View File

@ -27,6 +27,19 @@ module HomeworkCommonHelper
type
end
def programing_languages_options
type = []
option = []
option << "C"
option << 1
type << option
option_1 = []
option_1 << "C++"
option_1 << 2
type << option_1
type
end
#缺评扣分
def absence_penalty_option
type = []

View File

@ -7,7 +7,7 @@ class StudentWork < ActiveRecord::Base
has_many :student_works_evaluation_distributions, :dependent => :destroy
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
has_one :student_work_test
has_many :student_work_test
before_destroy :delete_praise

View File

@ -56,9 +56,7 @@
<ul>
<li >
<label class="label02">&nbsp;开发语言:&nbsp;</label>
<select class="fl mb10 h26 w150" >
<option>C</option>
</select>
<%= select_tag :language,options_for_select(programing_languages_options,homework.homework_detail_programing.language), {:class => "fl mb10 h26 w70"} %>
<div class="cl"></div>
</li>

View File

@ -1,17 +1,27 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= hidden_field_tag "course",@course.id%>
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
<%#= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<div class="hwork_new" id="hwork_new">
<%= form_for("new_homework_common",:url => next_step_homework_common_index_path) do |f|%>
<input type="hidden" name="course" value="<%= @course.id%>">
<h3 class="c_blue f16 mb10">
请选择将要发布的作业类型
</h3>
<input type="radio" class="mb10 fl" name="homework_common_type" value="1" id="homework_detail_manual_radio" checked/>
<span class="ml5 fl">
人工评分的作业(支持匿名互评、灵活设置评分比例)
</span>
<div class="cl"></div>
<input type="radio" class="mb20 fl" name="homework_common_type" value="2" id="homework_detail_programing_radio"/>
<span class="ml5 fl">
自动评测的编程作业支持C/C++程序的自动评分)
</span>
<div class="cl"></div>
<a href="javascript:void(0);" class=" orange_btn" onclick="$(this).parent().submit();">
下一步
</a>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>

View File

@ -7,6 +7,8 @@
#out{}
#in{width:10px; height:20px;background:#15BCCF;color:white;text-align:center;}
#font_color{background:yellow;text-align:center;color:white;}
td.redBox {border:1px solid #b0b0b0; width:80px; background-color:#EAEAEA; }
td.redBox2 {border:1px solid #b0b0b0; width:120px; }
</style>
<div style="padding-left: 200px;">
<div id='out'>
@ -42,31 +44,33 @@
</div>
</div>
<div id="show_content_div" style="display: none;padding-top: 10px;">
<p class="fr f14 ">语言:<span style="color: red">Java</span> 总文件数:<span style="color: red">361</span> 代码行数:<span style="color: red">48662</span></p>
<div id="show_content_div" style="display: none;padding-top: 0px;">
<p class="fr f14 " style="padding-right: 32px;">语言:<span style="color: red">Java</span> 总文件数:<span style="color: red">361</span> 代码行数:<span style="color: red">48662</span></p>
<div style="padding-left: 35px;padding-top: 30px;">
<% @dts.each do |dt| %>
<% @dts.each do |dt| %>
<table width="600" border="2" style="padding-top: 10px; padding-left: 30px;">
<tr>
<td align="center" bgcolor="#999999" style="width: 80px"><strong>错误变量</strong></td>
<td style="width: 120px"><%= dt.Variable %></td>
<td align="center" bgcolor="#999999" style="width: 80px"><strong>起始行</strong></td>
<td style="width: 120px"><%= dt.StartLine %></td>
<td align="center" bgcolor="#999999" style="width: 80px"><strong>IP行</strong></td>
<td><%= dt.IPLine %></td>
</tr>
<tr>
<td align="center" bgcolor="#999999"><strong>缺陷代码</strong></td>
<td colspan="5"><%= dt.IPLineCode %></td>
</tr>
<tr>
<td align="center" bgcolor="#999999"><strong>错误描述</strong></td>
<td colspan="5"><%= dt.Description %></td>
</tr>
<tr>
<td align="center" bgcolor="#999999"><strong>文件</strong></td>
<td colspan="5"><%= dt.File %></td>
</tr>
</table>
<% end %>
<table width="600" border="0" style="padding-left: 30px; border-spacing:0; border-collapse:collapse; border: 1px solid #b0b0b0;">
<tr>
<td align="center" class="redBox">错误变量</td>
<td class="redBox2"> &nbsp;<%= dt.Variable %></td>
<td align="center" class="redBox">起始行</td>
<td class="redBox2"> &nbsp;<%= dt.StartLine %></td>
<td align="center" class="redBox">IP行</td>
<td class="redBox2"> &nbsp;<%= dt.IPLine %></td>
</tr>
<tr>
<td align="center" class="redBox">缺陷代码</td>
<td colspan="5" class="redBox2"> &nbsp;<%= dt.IPLineCode %></td>
</tr>
<tr>
<td align="center" class="redBox">错误描述</td>
<td colspan="5" class="redBox2">&nbsp;<%= dt.Description %></td>
</tr>
<tr>
<td align="center" class="redBox">文件</td>
<td colspan="5" class="redBox2"> &nbsp;<%= dt.File %></td>
</tr>
</table>
<% end %>
</div>
</div>

View File

@ -0,0 +1,3 @@
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_project_dts) %></h2>
</div>

View File

@ -42,6 +42,6 @@
</div>
<div id="show_content_div" style="display: none;padding-top: 0px; ">
<p class="pl10 f14 "><span style="color: #7f7f7f;font-size: 14px; ">点击进入</span>
<span><a href="http://rubyblog.forge.trustie.net/myblog" target="_Blank" style="color: #15BCCF;font-size: 14px;">云化部署平台</a></span></p>
<p class="pl10 f14 "><span style="color: #7f7f7f;font-size: 14px; ">所部署服务的网址</span>
<span><a href="http://publify.forge.trustie.net" target="_Blank" style="color: #15BCCF;font-size: 14px;">http://publify.forge.trustie.net</a></span></p>
</div>

View File

@ -48,7 +48,6 @@
<%= test.output%>
</td>
<td class="td_50 c_red"><%= test.student_work_test.nil? ? "正在编译" : test.student_work_test.status_to_s%></td>
<td class="td_50 "><%= test.student_work_test.nil? ? "0" : test.student_work_test.test_score%></td>
<input type="hidden" value="<%= test.student_work_test.result if test.student_work_test%>">
</tr>
<% end%>

View File

@ -396,8 +396,9 @@ RedmineApp::Application.routes.draw do
get 'invite_members', :action=> 'invite_members'
get 'invite_members_by_mail', :action=> 'invite_members_by_mail'
# get 'dts_repos', :aciton => 'dts_repos'
get 'send_mail_to_member', :action => 'send_mail_to_member'
match 'user_watcherlist', :to => 'projects#watcherlist', :via => :get, :as => "watcherlist" #add by huang
match 'user_watcherlist', :to => 'projects#watcherlist', :via => :get, :as => "watcherlist"
#end
post 'modules'
post 'archive'