This commit is contained in:
huang 2015-12-11 18:12:25 +08:00
commit a791c39b4b
11 changed files with 42 additions and 26 deletions

View File

@ -270,6 +270,9 @@ class StudentWorkController < ApplicationController
user_activity.updated_at = Time.now
user_activity.save
end
course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
course_message.save
@student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
respond_to do |format|
format.js
@ -299,10 +302,11 @@ class StudentWorkController < ApplicationController
@submit_result = true
@work.name = params[:student_work][:name]
@work.description = params[:student_work][:description]
@work.project_id = params[:student_work][:project]
@work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@work)
if @work.save
course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"edit",:course_message_id=>@work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
course_message.save
=begin
respond_to do |format|
format.html {
@ -687,6 +691,7 @@ class StudentWorkController < ApplicationController
end
all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")"
all_students = User.where("id in #{all_student_ids}")
@commit_student_ids = @homework.student_work_projects.map{|student| student.user_id}
@users = searchstudent_by_name all_students,name
respond_to do |format|
format.js

View File

@ -2455,7 +2455,7 @@ module ApplicationHelper
link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束"
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
link_to "修改作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue'
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
link_to "修改作品(#{homework.student_works.count})", edit_student_work_path(work.id),:class => 'c_blue'
else
link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品"

View File

@ -1,5 +1,5 @@
class CourseMessage < ActiveRecord::Base
# status说明 status在课程不同的类型区分不同的功能
# status说明 status在课程不同的类型区分不同的功能 status = 9 作品的提交记录
# HomeworkCommonstatus
# nil发布了作业 1作业截止时间到了提醒2:开启匿评; 3关闭匿评 4匿评开始失败
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status
@ -19,7 +19,7 @@ class CourseMessage < ActiveRecord::Base
def add_user_message
#unless self.course_message_type == 'JoinCourseRequest'
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? && self.status != 9
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
#end

View File

@ -1,8 +1,7 @@
<% if @is_destroy%>
$("#attachment_<%= @attachment.id%>").remove();
if(document.getElementById("uploadReviseBox")) {
$("#uploadReviseBox").removeClass('disable_link');
$("#choose_revise_attach").attr("onclick","_file.click();");
if(document.getElementById("revise_attachment_div_<%= @attachment.id%>")) {
$("#revise_attachment_div_<%= @attachment.id%>").remove();
}
<%else%>
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');

View File

@ -33,6 +33,19 @@
}).mouseleave(function(){
$("#work_click_<%= exercise.id%>").hide();
});
$(function(){
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
$("#show_student_result_div").on('click',show_result);
<% else %>
$("#show_student_result_div").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_name_id").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_id_id").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_class_id").attr("title","截止日期未到,暂不能查看学生答题结果");
<% end %>
});
function show_result() {
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
}
</script>
<ul class="hworkListRow" id="student_work_<%= exercise.id%>">
<li class="hworkList340 width530">
@ -40,22 +53,16 @@
<li class="hworkPortrait mt15 mr10">
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40"),user_activities_path(exercise.user)) %>
</li>
<div onclick="" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
<div id="show_student_result_div" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
<li>
<ul class="mt10 fl">
<li class="hworkStName mr15 mt16" title="姓名">
<% name = exercise.user.show_name %>
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
<%= link_to name,show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>
<% else %>
<span title="截止日期未到,暂不能查看学生答题结果。"><%=name%></span>
<%#= link_to name,'',:title=>"截止日期未到,暂不能查看学生答题结果。" %>
<% end %>
<li class="hworkStName mr15 mt16" title="姓名" id="student_name_id">
<%=exercise.user.show_name %>
</li>
<li class="hworkStID mr10 mt16" title="学号">
<li class="hworkStID mr10 mt16" title="学号" id="student_id_id">
<%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%>
</li>
<li class="hworkStID mt16" title="班级">
<li class="hworkStID mt16" title="班级" id="student_class_id">
--
</li>
</ul>
@ -63,7 +70,7 @@
</div>
</ul>
</li>
<li class="hworkList130 c_grey student_work_<%= exercise.id%>" onclick="" style="cursor: pointer;">
<li class="hworkList130 c_grey student_work_<%= exercise.id%>">
<% if exercise.created_at%>
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>&nbsp;
<% end %>

View File

@ -1,6 +1,6 @@
<ul class="hworkUl">
<li class="hworkList340 hworkH30 <%= @homework.homework_type == 2 ? '' : 'width385'%>">
<span class="c_dark f14 fb fl <%= @homework.homework_type == 2 ? 'mr90 ml50' : 'mr140 ml50'%>">作品名称</span>
<span class="c_dark f14 fb fl <%= @homework.homework_type == 2 ? 'mr90 ml50' : 'mr150 ml50'%>">作品名称</span>
<% if @homework.homework_type != 3 %>
<span class="c_dark f14 fb fl mr50">姓名</span>
<span class="c_dark f14 fb fl">学号</span>

View File

@ -12,7 +12,7 @@
<li class="hworkPortrait mt15 mr10">
<%= image_tag(url_to_avatar(student_work.user),width:"40", height: "40") %>
</li>
<li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>">
<li class="hworkName mt15 mr15 width255 student_work_<%= student_work.id%>">
<% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
<div>
<%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
@ -40,7 +40,7 @@
<li class="hworkPortrait mt15 mr10">
<%= image_tag(url_to_avatar(""),width:"40", height: "40") %>
</li>
<li class="hworkName mt15 mr15 width285 student_work_<%= student_work.id%>">
<li class="hworkName mt15 mr15 width255 student_work_<%= student_work.id%>">
<div>
<%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
</div>

View File

@ -4,7 +4,7 @@
<div class="resubAtt mb15">
<span class="resubTitle">追加修订附件</span>
</div>
<div class="mb10">
<div class="mb10" id="revise_attachment_div_<%=revise_attachment.id %>">
<span class="tit_fb"> 追加附件:</span>
<%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 2} %>
<span class="tit_fb">追加时间:</span><%=format_time revise_attachment.created_on.to_s %>&nbsp;&nbsp;(<%=revise_attachment_status @homework,revise_attachment %>)
@ -15,7 +15,7 @@
<span class="resubTitle">追加修订附件</span>
</div>
<% if revise_attachment %>
<div class="mb10">
<div class="mb10" id="revise_attachment_div_<%=revise_attachment.id %>">
<span class="tit_fb"> 追加附件:</span>
<%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 1} %>
<span class="tit_fb">追加时间:</span><%=format_time revise_attachment.created_on.to_s %>

View File

@ -18,7 +18,7 @@ $("#all_students_list").empty();
}
}
}
<% if user.id.to_i != User.current.id.to_i %>
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
@ -29,5 +29,9 @@ $("#all_students_list").empty();
$("#choose_students_list").append(li);
});
}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该学生已加入其它分组");
}
<% end %>
<% end %>

View File

@ -55,7 +55,7 @@
<% end %>
<div class="cl"></div>
<span class="fl fontGrey2" id="relate_project_show">
<% if @homework %>
<% if @homework && @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
<% unless @homework.student_work_projects.where("user_id = #{User.current.id}").empty? %>
<% project = Project.find @homework.student_work_projects.where("user_id = #{User.current.id}").first.project_id %>
关联项目:<%=project.name %>

View File

@ -83,6 +83,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re
.width180{width: 180px;}
.width525{width: 525px;}
.width285{width: 285px;}
.width255{width: 255px;}
.width530{width: 530px;}
.mr95{margin-right: 95px;}
.mr140 {margin-right: 140px;}