Merge branch 'cxt_course' into yuanke_1

Conflicts:
	db/schema.rb
This commit is contained in:
yuanke 2016-04-23 13:22:28 +08:00
commit 81cd30cbda
11 changed files with 64 additions and 30 deletions

View File

@ -504,6 +504,7 @@ class StudentWorkController < ApplicationController
end
@score = @b_sort == "desc" ? "asc" : "desc"
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID
@message_student_work_id = params[:student_work_id]
respond_to do |format|
@ -920,8 +921,6 @@ class StudentWorkController < ApplicationController
student_work.late_penalty = @homework.late_penalty
student_work.save
end
@homework.save
end
if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s
@ -944,7 +943,6 @@ class StudentWorkController < ApplicationController
homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing
@homework.teacher_priority = teacher_priority
@homework.save
homework_detail_manual.save if homework_detail_manual
homework_detail_programing.save if homework_detail_programing
@ -953,6 +951,8 @@ class StudentWorkController < ApplicationController
student_work.save
end
end
@homework.save
if params[:student_path]
redirect_to student_work_index_url(:homework => @homework.id)
else

View File

@ -2990,8 +2990,12 @@ def homework_common_index_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s
end
def student_work_index_url_in_org(homework_id)
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
def student_work_index_url_in_org(homework_id, is_focus = '')
if is_focus != ''
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&is_focus=" + is_focus.to_s
else
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
end
end
def course_url_in_org(course_id)

View File

@ -66,11 +66,16 @@
</div>
<% end %>
<% end %>
<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
<div class="homepagePostSubmit">
<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
<%= user_for_homework_common activity,is_teacher %>
</div>
<% work = cur_user_works_for_homework activity %>
<% if activity.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(activity.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if activity.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit">
<%= link_to "模拟答题", Setting.protocol + "://" + Setting.host_name + "/users/new_user_commit_homework?homework_id="+activity.id.to_s + "&is_test=true", class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -119,6 +119,11 @@
<div class="cl"></div>
</div>
<script type="text/javascript">
$(function(){
<% if defined?(is_focus) && is_focus.to_i == 1 %>
$("#upload_revise_attachment").click();
<% end %>
});
function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');
showModal('ajax-modal', '452px');

View File

@ -30,7 +30,7 @@
<% end %>
<div class="cl"></div>
<div class="mb10 mt5">
<a href="javascript:void(0);" onclick="show_upload();" class="blueCir ml5" title="请选择文件上传">上传附件</a>
<a href="javascript:void(0);" id="upload_revise_attachment" onclick="show_upload();" class="blueCir ml5" title="请选择文件上传">上传附件</a>
</div>
<% end %>
<% end %>
<% end %>

View File

@ -107,6 +107,9 @@
<script type="text/javascript">
$(function(){
showNormalImage('student_work_img_<%=work.id %>');
<% if defined?(is_focus) && is_focus.to_i == 1 %>
$("#upload_revise_attachment").click();
<% end %>
});
function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');

View File

@ -7,6 +7,7 @@
<% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
<% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %>
<span class="f12 c_red">您尚未提交作品</span>
<%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %>
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span>
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
@ -58,7 +59,7 @@
<% end %>
<% unless work.nil? %>
<% if @homework.homework_type == 2 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>work,:score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
var program_name = "text/x-csrc";
var language = <%= @homework.language %>;
@ -82,11 +83,11 @@
value: $("#work-src_<%= work.id%>").text()
});
<% elsif @homework.homework_type == 1 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
<% elsif @homework.homework_type == 3 %>
<% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %>
<% if pro && pro.student_work_id == work.id %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc"),:is_focus => @is_focus}) %>");
<% end %>
<% end %>
$('#score_<%= work.id%>').peSlider({range: 'min'});

View File

@ -71,7 +71,12 @@
<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
<%= user_for_homework_common activity,is_teacher %>
</div>
<% work = cur_user_works_for_homework activity %>
<% if activity.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(activity.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if activity.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -70,6 +70,12 @@
<div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %>
</div>
<% work = cur_user_works_for_homework homework_common %>
<% if homework_common.end_time < Date.today && !is_teacher && !work.nil? %>
<div class="homepagePostSubmit">
<%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
</div>
<% end %>
<% if homework_common.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>

View File

@ -0,0 +1,21 @@
class AlterHomeworkEndTime < ActiveRecord::Migration
def up
homeworks = HomeworkCommon.where("id in (3229, 3234, 3235, 3236)");
unless homeworks.empty? || homeworks.nil?
homeworks.each do |hw|
hw.end_time = hw.end_time + 4
hm = hw.homework_detail_manual
hm.comment_status = 1
hw.student_works.each do |stu|
stu.late_penalty = 0
stu.save
end
hm.save
hw.save
end
end
end
def down
end
end

View File

@ -11,11 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160405021915) do
ActiveRecord::Schema.define(:version => 20160419074016) do
ActiveRecord::Schema.define(:version => 20160421011543) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -338,17 +334,6 @@ ActiveRecord::Schema.define(:version => 20160419074016) do
t.boolean "diff_all"
end
create_table "code_tests", :force => true do |t|
t.integer "homework_id"
t.integer "wait_time", :default => 0
t.integer "language"
t.integer "status"
t.integer "time_used", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "student_work_id", :default => 0
end
create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false
@ -1695,7 +1680,6 @@ ActiveRecord::Schema.define(:version => 20160419074016) do
t.integer "status", :default => 9
t.text "results"
t.text "src"
t.integer "uwait_time", :default => 0
end
create_table "student_works", :force => true do |t|