Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
3abd2d4be6
|
@ -199,7 +199,7 @@ class BoardsController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.js {render "show.js.erb"}
|
||||
format.html {
|
||||
if @project
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
|
|
|
@ -24,7 +24,7 @@ class CommentsController < ApplicationController
|
|||
before_filter :authorize, :except => [:destroy]
|
||||
|
||||
def create
|
||||
raise Unauthorized unless @news.commentable?
|
||||
#raise Unauthorized unless @news.commentable?
|
||||
if !@news.org_subfield_id.nil?
|
||||
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
|
||||
end
|
||||
|
|
|
@ -315,6 +315,14 @@ class HomeworkCommonController < ApplicationController
|
|||
#加入到题库
|
||||
def add_to_homework_bank
|
||||
if params[:type] && (params[:type].to_i == 1 || params[:type].to_i == 3)
|
||||
if params[:type].to_i == 3
|
||||
old_banks = HomeworkBank.where(:homework_common_id => @homework.id)
|
||||
unless old_banks.blank?
|
||||
old_banks.each do |bank|
|
||||
bank.update_attributes(:quotes => (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
homework_bank = add_to_homework_bank_f @homework
|
||||
homework_bank.save
|
||||
@homework.update_attributes(:homework_bank_id => homework_bank.id)
|
||||
|
|
|
@ -1317,12 +1317,20 @@ class StudentWorkController < ApplicationController
|
|||
@homework.update_column('anonymous_comment', @homework.anonymous_comment == 0 ? 1 : 0)
|
||||
homework_detail_manual = @homework.homework_detail_manual
|
||||
homework_detail_programing = @homework.homework_detail_programing
|
||||
if homework_detail_programing
|
||||
homework_detail_manual.update_column('ta_proportion', 0.4)
|
||||
homework_detail_programing.update_column('ta_proportion', 0.6)
|
||||
if @homework.anonymous_comment == 1
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.4 : 1.0
|
||||
else
|
||||
homework_detail_manual.update_column('ta_proportion', 1.0)
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.3 : 0.6
|
||||
end
|
||||
if @homework.homework_type == 2 && homework_detail_programing
|
||||
if @homework.anonymous_comment == 1
|
||||
homework_detail_programing.ta_proportion = 0.6
|
||||
else
|
||||
homework_detail_programing.ta_proportion = 0.5
|
||||
end
|
||||
end
|
||||
homework_detail_manual.save
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
@homework.student_works.each do |student_work|
|
||||
set_final_score @homework,student_work
|
||||
student_work.save
|
||||
|
|
|
@ -1499,6 +1499,7 @@ class UsersController < ApplicationController
|
|||
if params[:add_to_bank]
|
||||
homework_bank = add_to_homework_bank_f homework
|
||||
homework_bank.save
|
||||
homework.update_attributes(:homework_bank_id => homework_bank.id)
|
||||
end
|
||||
redirect_to homework_common_index_path(:course => homework.course_id)
|
||||
end
|
||||
|
|
|
@ -4119,7 +4119,7 @@ end
|
|||
|
||||
def add_to_homework_bank_f homework
|
||||
homework_bank = HomeworkBank.new(:name => homework.name, :description => homework.description, :user_id => homework.user_id, :homework_type => homework.homework_type,
|
||||
:quotes => 0, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id)
|
||||
:quotes => 1, :is_public => homework.course.is_public, :applicable_syllabus => homework.course.syllabus.title, :homework_common_id => homework.id)
|
||||
if homework.homework_type == 2 && homework.homework_detail_programing
|
||||
homework_bank.language = homework.homework_detail_programing.language
|
||||
homework.homework_tests.each_with_index do |homework_test|
|
||||
|
|
|
@ -36,6 +36,17 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
after_update :update_activity
|
||||
after_save :act_as_course_activity
|
||||
after_destroy :delete_kindeditor_assets
|
||||
before_destroy :update_homework_bank_quotes
|
||||
|
||||
#删除时更新题库中的引用数
|
||||
def update_homework_bank_quotes
|
||||
old_banks = HomeworkBank.where(:homework_common_id => self.id)
|
||||
unless old_banks.blank?
|
||||
old_banks.each do |bank|
|
||||
bank.update_attributes(:quotes => (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, :homework_common_id => nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#作业类型
|
||||
def homework_type_ch
|
||||
|
|
|
@ -103,6 +103,19 @@ class News < ActiveRecord::Base
|
|||
user.allowed_to?(:comment_news, project)
|
||||
end
|
||||
|
||||
def news_object
|
||||
object = self.project
|
||||
if object == nil && self.has_attribute?('course_id')
|
||||
object = self.course
|
||||
if object.nil? && self.has_attribute?('contest_id')
|
||||
object = self.contest
|
||||
elsif object.nil? && self.has_attribute?('org_subfield_id')
|
||||
object = self.org_subfield
|
||||
end
|
||||
end
|
||||
object
|
||||
end
|
||||
|
||||
def recipients
|
||||
project.users.select {|user| user.notify_about?(self)}.map(&:mail)
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class CommentService
|
|||
if @course.nil?
|
||||
raise 'news in unknown course'
|
||||
end
|
||||
raise Unauthorized unless @news.commentable?(current_user)
|
||||
#raise Unauthorized unless @news.commentable?(current_user)
|
||||
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
|
||||
raise '403'
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<% if @news.commentable? %>
|
||||
<% if User.current.admin? || ((object.kind_of? Contest) && User.current.member_of_contest?(object)) || ((object.kind_of? Course) && User.current.member_of_course?(object)) || ((object.kind_of? OrgSubfield) && User.current.member_of_org?(object.organization)) %>
|
||||
<div class="talkWrapMsg" nhname="about_talk_reply">
|
||||
<em class="talkWrapArrow"></em>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
:class => 'fr mr20 undis',
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:title => l(:button_delete)
|
||||
) if ((object.kind_of? Organization) ? (User.current.admin_of_org?(object) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
|
||||
) if ((object.kind_of? OrgSubfield) ? (User.current.admin_of_org?(object.organization) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
<em></em>
|
||||
<font></font>
|
||||
作品最终评分为
|
||||
<span class="c_red"> <%= score %> </span>分<br/>
|
||||
<span class="c_red"> <%= student_work.final_score %> </span>分<br/>
|
||||
迟交扣分
|
||||
<span class="c_red">
|
||||
<%= student_work.late_penalty %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<ul>
|
||||
<li class="clear">
|
||||
<label class="label"><span class="c_red f12">*</span> 序号 : </label>
|
||||
<%= f.text_field :position, :no_label => true, :placeholder => "请输入序号(整数)", :onkeyup => "this.value=this.value.replace(/\D/g,'')", :onafterpaste => "this.value=this.value.replace(/\D/g,'')" %>
|
||||
<%= f.text_field :position, :no_label => true, :placeholder => "请输入序号(整数)" %>
|
||||
</li>
|
||||
<li class="clear">
|
||||
<label class="label"><span class="c_red f12">*</span> 标题 : </label>
|
||||
|
@ -41,9 +41,17 @@
|
|||
<input onclick="issue_create();" class="sy_btn_blue mr5 fr" onfocus="this.blur()" id="issue_confirm" style="width: 28px;color: #FFF" value="保存">
|
||||
</li>
|
||||
</ul>
|
||||
<script>
|
||||
<script type="text/javascript">
|
||||
function issue_create(){
|
||||
training_task_desc_editor.sync();
|
||||
$('#project_training_form').submit();
|
||||
}
|
||||
$(function(){
|
||||
$("#training_task_position").bind('keyup', function (){
|
||||
this.value=this.value.replace(/\D/g,'')
|
||||
});
|
||||
$("#training_task_position").bind('afterpaste',function(){
|
||||
this.value=this.value.replace(/\D/g,'')
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
<%= render :partial => 'users/news_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'News', :activity_id => activity.id} %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if activity.commentable? %>
|
||||
<% object = activity.news_object %>
|
||||
<% if User.current.admin? || ((object.kind_of? Contest) && User.current.member_of_contest?(object)) || ((object.kind_of? Course) && User.current.member_of_course?(object)) || ((object.kind_of? OrgSubfield) && User.current.member_of_org?(object.organization)) %>
|
||||
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
|
||||
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
|
||||
<div class="homepagePostReplyInputContainer mb10">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<span class="f12 c_red mt5 fr">温馨提示:请至少输入一组样例供学生参考。</span>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% if edit_mode && homework.is_program_homework? %>
|
||||
<% if edit_mode && homework.is_program_homework? && homework.homework_samples.count > 0 %>
|
||||
<% homework.homework_samples.each_with_index do |sample, index| %>
|
||||
<div class="mt10" style="margin-left:57px;">
|
||||
<label class="fl fontGrey2 mr10 mt5 w20" name="sample_inputs_label"><%= index+1 %> </label>
|
||||
|
|
|
@ -15,6 +15,8 @@ homework_description_editor.html("<%= escape_javascript(@homework.description.ht
|
|||
<% elsif @homework_detail_group %>
|
||||
$("#homeworkSetting").removeClass("undis");
|
||||
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_group_attr', :locals => {:edit_mode => true, :homework=>@homework, :not_allow_select => false}) %>");
|
||||
<% else %>
|
||||
$("#homeworkSetting").addClass("undis");
|
||||
<% end %>
|
||||
document.getElementById("homework_type_option").options[<%=@homework.homework_type %>].selected = true;
|
||||
$("#select_type_nitice").hide();
|
||||
|
|
|
@ -11,7 +11,7 @@ class HomeworkBankMigration < ActiveRecord::Migration
|
|||
course.homework_commons.each do |homework|
|
||||
unless homework.user.homework_banks.select("name").to_s.include?(homework.name)
|
||||
homework_bank = HomeworkBank.create(:user_id => homework.user_id, :name => homework.name, :description => homework.description, :homework_type => homework.homework_type,
|
||||
:quotes => homework.quotes, :is_public => course.is_public, :applicable_syllabus => course.syllabus.title, :homework_common_id => homework.id, :created_at => homework.created_at)
|
||||
:quotes => 1, :is_public => course.is_public, :applicable_syllabus => course.syllabus.title, :homework_common_id => homework.id, :created_at => homework.created_at)
|
||||
if homework.homework_type == 2 && homework.homework_detail_programing
|
||||
homework_bank.update_attributes(:language => homework.homework_detail_programing.language, :standard_code => homework.homework_detail_programing.standard_code)
|
||||
homework.homework_tests.each do |test|
|
||||
|
|
Loading…
Reference in New Issue