Merge branch 'develop' into dev_zanle

This commit is contained in:
lizanle 2015-12-04 10:59:14 +08:00
commit e3c594a7ca
22 changed files with 201 additions and 62 deletions

View File

@ -6,6 +6,14 @@ class ExerciseController < ApplicationController
include ExerciseHelper
def index
publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
publish_exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
if @course.is_public == 0 && !User.current.member_of_course?(@course)
render_403
return
@ -24,6 +32,14 @@ class ExerciseController < ApplicationController
end
def show
publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
publish_exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
unless User.current.member_of_course?(@course)
render_403
return

View File

@ -3,8 +3,8 @@ class StudentWorkController < ApplicationController
include StudentWorkHelper
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work]
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
@ -222,7 +222,7 @@ class StudentWorkController < ApplicationController
def edit
@user = User.current
if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业
if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
render_403
else
respond_to do |format|
@ -284,6 +284,23 @@ class StudentWorkController < ApplicationController
end
end
def delete_work
@work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
if @work
@work.destroy
end
redirect_to user_homeworks_user_path(User.current.id)
end
def retry_work
if @work.destroy
@student_work = StudentWork.new
respond_to do |format|
format.js
end
end
end
#添加评分,已评分则为修改评分
def add_score
@is_last = params[:is_last] == "true"

View File

@ -35,6 +35,5 @@
$("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>");
$("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>");
/*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/
document.getElementById("exercise_description").innerHTML = <%=exercise.exercise_description.html_safe %>;
}
</script>

View File

@ -0,0 +1,30 @@
<div class="fl">
<div class="cl"></div>
<span style="font-weight:normal;">
<a href="javascript:void(0);" class="blueCir ml5" onclick="$('#_file<%=work.id %>').click();">上传附件</a>
<%#= button_tag "上传附件", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'blueCir ml5' %>
<%= file_field_tag 'attachments[dummy][file]',
:id => "_file#{work.id}",
:class => 'file_selector',
:multiple => true,
:onchange => "addReviseFiles(this, '#{work.id}');",
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:lebel_file_uploding => l(:lebel_file_uploding),
:delete_all_files => l(:text_are_you_sure_all),
:containerid => "#{work.id}"
} %>
</span>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>
</div>

View File

@ -61,6 +61,31 @@
</li>
</ul>
<!--<div class="resubAtt">
<span class="resubTitle">追加修订附件</span>
</div>
<div class="mt15">
<span class="tit_fb"> 追加附件:</span>
<a href="javascript:void(0);" class="link_file fl" >socket实验-123456-王强revise.zip</a>
<span id="attachments_fields<%= work.id%>" xmlns="http://www.w3.org/1999/html">
<span id="attachments_p<%= work.id %>">-->
<%#= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
<%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<!--<span class="ispublic-label"><%#= l(:field_is_public)%>:</span>-->
<%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
<%#= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%#= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<!--</span>
</span>
<span class="ml5">(123KB)</span><br />
<span class="tit_fb">追加时间:</span>2015-12-03 11:00&nbsp;&nbsp;(此时其他同学作品尚未公开)
</div>
<div class="mt5">
<%#= render :partial => 'student_work/revise_attachments', :locals => {:work => work } %>
<a href="javascript:void(0);" class="blueCir ml5" title="请选择文件上传">上传附件</a>
</div>
<div class="cl"></div>-->
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= work.student_works_scores.empty? ? 'padding:0px;' : ''%>">
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">

View File

@ -19,9 +19,10 @@
</p>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px; margin-left: 55px;" >
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
确&nbsp;&nbsp;定
</a>
<%= link_to("重试", retry_work_student_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
</div>
</div>
</div>

View File

@ -11,7 +11,7 @@
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
"<a href='/student_work/"+ <%=@student_work.id%> +"/retry_work' class='upload_btn' data-remote='true'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
<% else %>

View File

@ -99,7 +99,7 @@
</div>
<div class="mt5 fl">
<a href="javascript:void(0);" class="RalationIcon fl mt3" onclick="show_project();">关联项目</a>
<a href="javascript:void(0);" class="RalationIcon fl mt3" onclick="show_project();">关联项目</a>
</div>
<div class="cl"></div>
@ -111,9 +111,9 @@
</div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">确定</a>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">提交</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
<%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%>
</div>
<div class="cl"></div>
<% end%>

View File

@ -0,0 +1,2 @@
hideModal('#popbox02');
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false})%>");

View File

@ -97,7 +97,7 @@
</div>
</script>
<div class="BluePopupBox" id="BluePopupBox" style="display:none">
<%= render :partial => 'users/user_programing_attr', :locals => {:edit_mode => edit_mode, :homework=>homework} %>
</div><!----BluePopupBox end-->

View File

@ -206,11 +206,13 @@ RedmineApp::Application.routes.draw do
resources :student_work do
member do
post 'add_score'
get 'retry_work'
get 'praise_student_work'
get 'forbidden_anonymous_comment'
end
collection do
post 'add_score_reply'
get 'delete_work'
get 'destroy_score_reply'
get 'student_work_absence_penalty'
get 'absence_penalty_list'

View File

@ -0,0 +1,9 @@
# encoding: utf-8
class AddAttachmentType < ActiveRecord::Migration
def up
Attachmentstype.create(typeId:3,typeName:'修订附件')
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151130033906) do
ActiveRecord::Schema.define(:version => 20151203030635) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :force => true do |t|
t.string "IPLineCode"
t.string "Description"
t.string "Num"
t.string "Variable"
t.string "TraceInfo"
t.string "Method"
create_table "dts", :primary_key => "Num", :force => true do |t|
t.string "Defect", :limit => 50
t.string "Category", :limit => 50
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description"
t.text "PreConditions", :limit => 2147483647
t.text "TraceInfo", :limit => 2147483647
t.text "Code", :limit => 2147483647
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@ -735,6 +738,17 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
create_table "homework_detail_groups", :force => true do |t|
t.integer "homework_common_id"
t.integer "min_num"
t.integer "max_num"
t.integer "base_on_project"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id"
create_table "homework_detail_manuals", :force => true do |t|
t.float "ta_proportion"
t.integer "comment_status"
@ -891,16 +905,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"

View File

@ -1,21 +0,0 @@
namespace :delete_evalution do
desc "delete evaluation"
task :delete => :environment do
homework = HomeworkCommon.where("id = 844").first
homework_detail_manual = homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 3)
student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first
student_work_score.destroy
student_work_9203 = StudentWork.where("id = 28088").first
student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first
student_work_9203.update_column("student_score",91)
student_work_9203.update_column("final_score",91)
student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework_detail_manual.absence_penalty)
work_ids = "(" + homework.student_works.map(&:id).join(",") + ")"
homework.student_works.each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
end
end

View File

@ -0,0 +1,18 @@
#coding=utf-8
namespace :exercise_publish do
desc "publish exercise and end exercise"
task :publish => :environment do
exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
end
end
task :end => :environment do
exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
exercises.each do |exercise|
exercise.update_column('exercise_status', 3)
end
end
end

View File

@ -52,7 +52,7 @@ namespace :homework_evaluation do
#自动关闭匿评的任务
task :end_evaluation => :environment do
homework_detail_manuals = HomeworkDetailManual.where("evaluation_end <= '#{Date.today}'")
homework_detail_manuals = HomeworkDetailManual.where("evaluation_end = '#{Date.today}'")
homework_detail_manuals.each do |homework_detail_manual|
homework_common = homework_detail_manual.homework_common
if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 2 #开启匿评状态才可关闭匿评

View File

@ -22,7 +22,7 @@ namespace :homework_publishtime do
end
task :end => :environment do
homework_commons = HomeworkCommon.where("end_time < '#{Date.today}'")
homework_commons = HomeworkCommon.where("end_time = '#{Date.today}'")
homework_commons.each do |homework|
if homework.anonymous_comment == 1
homework_detail_manual = homework.homework_detail_manual

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -19,7 +19,7 @@ $(function(){
return false;
}
return true;
}
};
var test_program = function(cb){
var homework_id = $('#test-program-btn').attr('data-homework-id');
@ -171,7 +171,7 @@ $(function(){
$("input[name=homework_type]").after(html);
}
return valid;
}
};
$("#BluePopupBox a.BlueCirBtn").live('click', function(){
if(saveProgramAnswers()){

View File

@ -1175,4 +1175,25 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
.rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;word-wrap: normal; word-break: normal;}
.rankPortrait {border-radius:50%; width:35px; height:35px;}
.numIntro {position:absolute; text-align:left; z-index:999; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); border:1px solid #eaeaea; background-color:#ffffff; padding:3px 5px; left:15px; color:#585858; white-space: nowrap;}
.font_cus {font-family: "微软雅黑","宋体"; font-size: 12px; line-height: 1.5;}
.font_cus {font-family: "微软雅黑","宋体"; font-size: 12px; line-height: 1.5;}
/*20151130课程项目集成Tim*/
a.testBtn{background: url(/images/course/hwork_icon.png) -2px -5px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;}
.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;}
.popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;}
a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.addMemberC {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:227px; background-color:#f1f1f1; min-height:150px; padding-top:10px;}
.addMemberC li {padding-left:10px; line-height:18px;}
.addMemberC li:hover {cursor:pointer; background-color:#cccccc;}
.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;}
.rightArrow {margin:50px 15px 0px 15px; float:left;}
.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;}
.resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;}
.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;}
a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.blueCir{ background:#3598db; color:#fff;}

View File

@ -1349,3 +1349,19 @@ span.author { font-size: 0.9em; color: #888; }
.pageCell:hover {border:1px solid #3498db; z-index:10;}
.pageCellActive {background-color:#3498db; border:1px solid #3498db !important; position:relative; color:#ffffff;}
/*20151130课程项目集成Tim*/
a.testBtn{background: url(/images/course/hwork_icon.png) -2px -5px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;}
.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;}
.popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;}
a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
.addMemberC {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:227px; background-color:#f1f1f1; min-height:150px; padding-top:10px;}
.addMemberC li {padding-left:10px; line-height:18px;}
.addMemberC li:hover {cursor:pointer; background-color:#cccccc;}
.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;}
.rightArrow {margin:50px 15px 0px 15px; float:left;}
.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;}