分组作业的动态显示及关联项目

This commit is contained in:
cxt 2015-12-09 16:33:48 +08:00
parent 53f9141cf1
commit 4e04df7a8a
8 changed files with 76 additions and 6 deletions

View File

@ -3,7 +3,7 @@ class StudentWorkController < ApplicationController
include StudentWorkHelper include StudentWorkHelper
require 'bigdecimal' require 'bigdecimal'
require "base64" 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,:delete_work,:new_student_work_project,:student_work_project] 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,:new_student_work_project,:student_work_project,:cancel_relate_project]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_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 :author_of_work, :only => [:edit, :update, :destroy]
@ -579,6 +579,18 @@ class StudentWorkController < ApplicationController
end end
end end
def cancel_relate_project
relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first
if relate_pro.destroy
@user_activity_id = params[:user_activity_id].to_i
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
respond_to do |format|
format.js
end
end
end
private private
def hsd_committed_work?(user, homework) def hsd_committed_work?(user, homework)
sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first

View File

@ -2465,10 +2465,13 @@ module ApplicationHelper
link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue"
else else
projects = cur_user_projects_for_homework homework projects = cur_user_projects_for_homework homework
if projects.nil? works = cur_user_works_for_homework homework
if works.nil? && projects.nil?
link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目'
elsif works.nil?
link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目'
else else
link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class => "c_blue", :title=> '取消关联项目' link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue"
end end
end end
end end

View File

@ -87,6 +87,7 @@ class Project < ActiveRecord::Base
# end # end
#ADDED BY NIE #ADDED BY NIE
has_one :project_score, :dependent => :destroy
has_many :project_infos, :dependent => :destroy has_many :project_infos, :dependent => :destroy
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy

View File

@ -0,0 +1,7 @@
<% if @user_activity_id != -1 %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% else%>
$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>");
init_activity_KindEditor_data(<%= @homework.id%>,"","87%");
<% end %>

View File

@ -3,6 +3,6 @@ hideModal("#popbox02");
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
<% else%> <% else%>
$("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>");
init_activity_KindEditor_data(<%= @homework_common_id%>,"","87%"); init_activity_KindEditor_data(<%= @homework.id%>,"","87%");
<% end %> <% end %>

View File

@ -86,6 +86,25 @@
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %> <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% if activity.homework_type == 3 && !activity.student_work_projects.empty? %>
<div class="mt10">
<div class="fl proRelateWrap mr10">
<img src="/images/course/proRelated.png" width="25" height="25" class="borderRadius mt7 ml7" title="已关联项目" />
</div>
<% activity.student_work_projects.each do |pro| %>
<div class="mr10 mb10 fl">
<% project = Project.find pro.project_id %>
<% if project.is_public || project.user_id == User.current.id %>
<%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %>
<% else %>
<%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %>
<% end %>
<p class="c_red tac" title="综合评分"><%=project.project_score.score.to_i %></p>
</div>
<% end %>
</div>
<% end %>
<div class="cl"></div>
<% if is_teacher%> <% if is_teacher%>
<% comment_status = activity.homework_detail_manual.comment_status %> <% comment_status = activity.homework_detail_manual.comment_status %>
<div class="homepagePostSetting"> <div class="homepagePostSetting">

View File

@ -44,8 +44,16 @@
<span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span> <span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span>
<% end%> <% end%>
<% end%> <% end%>
<div class="cl"></div>
<% if homework_common.homework_type == 3%>
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
<% end %>
<div class="homepagePostSubmitContainer"> <div class="homepagePostSubmitContainer">
<% if homework_common.homework_type == 3%>
<div class="homepagePostSubmit">
<%= relate_project(homework_common,is_teacher,is_in_course,-1,-1) %>
</div>
<% end %>
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %> <%= user_for_homework_common homework_common,is_teacher %>
</div> </div>
@ -82,6 +90,25 @@
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? %>
<div class="mt10">
<div class="fl proRelateWrap mr10">
<img src="/images/course/proRelated.png" width="25" height="25" class="borderRadius mt7 ml7" title="已关联项目" />
</div>
<% homework_common.student_work_projects.each do |pro| %>
<div class="mr10 mb10 fl">
<% project = Project.find pro.project_id %>
<% if project.is_public == 1 %>
<%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %>
<% else %>
<%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %>
<% end %>
<p class="c_red tac" title="综合评分"><%=project.project_score.score.to_i %></p>
</div>
<% end %>
</div>
<% end %>
<div class="cl"></div>
<% if is_teacher%> <% if is_teacher%>
<% comment_status = homework_common.homework_detail_manual.comment_status%> <% comment_status = homework_common.homework_detail_manual.comment_status%>
<div class="homepagePostSetting"> <div class="homepagePostSetting">

View File

@ -221,6 +221,7 @@ RedmineApp::Application.routes.draw do
post 'student_work_project' post 'student_work_project'
get 'new_student_work_project' get 'new_student_work_project'
get 'search_user_projects' get 'search_user_projects'
get 'cancel_relate_project'
get 'delete_work' get 'delete_work'
get 'destroy_score_reply' get 'destroy_score_reply'
get 'student_work_absence_penalty' get 'student_work_absence_penalty'