基于项目的分组作业没有显示项目详情
This commit is contained in:
parent
d1bfdde261
commit
16c51e1eaa
|
@ -597,14 +597,14 @@ class StudentWorkController < ApplicationController
|
|||
@student_work_project.student_work_id = student_work.id
|
||||
@student_work_project.save
|
||||
elsif @homework.homework_detail_group.base_on_project == 0
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => student_work.project_id, :user_id => student_work.user_id, :is_leader => 1)
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => student_work.project_id, :user_id => student_work.user_id, :is_leader => 1, :course_id => @homework.course_id)
|
||||
stu_project.save
|
||||
end
|
||||
members = params[:group_member_ids].split(',')
|
||||
for i in 1 .. members.count-1
|
||||
stu_work = StudentWork.new(:name => student_work.name, :description => student_work.description,:user_id =>members[i].to_i, :homework_common_id => @homework.id,:project_id => student_work.project_id, :late_penalty => student_work.late_penalty,:work_status => 3, :commit_time => student_work.commit_time)
|
||||
if stu_work.save
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0)
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||
stu_project.save
|
||||
end
|
||||
end
|
||||
|
@ -662,7 +662,7 @@ class StudentWorkController < ApplicationController
|
|||
for i in 1 .. members.count-1
|
||||
stu_work = StudentWork.new(:name => @work.name, :description => @work.description,:user_id=> members[i].to_i, :homework_common_id => @homework.id, :project_id => @work.project_id, :late_penalty => @work.late_penalty,:work_status => 3, :commit_time => @work.commit_time)
|
||||
if stu_work.save
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => @work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0)
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => @work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||
stu_project.save
|
||||
end
|
||||
end
|
||||
|
@ -1095,6 +1095,7 @@ class StudentWorkController < ApplicationController
|
|||
@project.project_id = params[:projectName].to_i
|
||||
@project.user_id = User.current.id
|
||||
@project.is_leader = 1
|
||||
@project.course_id = @homework.course_id
|
||||
if @project.save
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
|
@ -1180,7 +1181,7 @@ class StudentWorkController < ApplicationController
|
|||
unless work
|
||||
stu_work = StudentWork.new(:name => student_work.name, :description => student_work.description,:user_id =>params[:member_id][i].to_i, :homework_common_id => @homework.id,:project_id => student_work.project_id, :late_penalty => student_work.late_penalty,:work_status => 3, :commit_time => Time.now)
|
||||
if stu_work.save
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => params[:member_id][i].to_i, :is_leader => 0)
|
||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => params[:member_id][i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||
stu_project.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,6 +49,7 @@ class Course < ActiveRecord::Base
|
|||
#has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy
|
||||
has_many :news, :dependent => :destroy, :include => :author
|
||||
has_one :course_status, :class_name => "CourseStatus", :dependent => :destroy
|
||||
has_many :student_work_projects, :dependent => :destroy
|
||||
|
||||
has_many :homework_commons, :dependent => :destroy
|
||||
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
||||
|
|
|
@ -965,8 +965,12 @@ class User < Principal
|
|||
#是否具有老师角色
|
||||
def has_teacher_role(course)
|
||||
member = course.members.where("user_id = #{self.id}").first
|
||||
role = MemberRole.where("member_id = #{member.id} and role_id in (3, 7, 9)")
|
||||
!role.blank?
|
||||
if !member.nil?
|
||||
role = MemberRole.where("member_id = #{member.id} and role_id in (3, 7, 9)")
|
||||
!role.blank?
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
#是否具有学生角色
|
||||
|
@ -991,6 +995,13 @@ class User < Principal
|
|||
# Admin users are authorized for anything else
|
||||
return true if admin?
|
||||
|
||||
course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")"
|
||||
courses = Course.where("id in #{course_ids}")
|
||||
courses.each do |course|
|
||||
if self.has_teacher_role(course)
|
||||
return true
|
||||
end
|
||||
end
|
||||
roles = roles_for_project(context)
|
||||
return false unless roles
|
||||
roles.any? {|role|
|
||||
|
|
|
@ -13,10 +13,8 @@
|
|||
<div class="pr">
|
||||
<span class="fl ml25 fontGrey2">关联项目:</span>
|
||||
<div class="fl projectName">
|
||||
<% if student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? %>
|
||||
<% if student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.allowed_to?(:as_teacher, @homework.course) %>
|
||||
<%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %>
|
||||
<% elsif User.current.allowed_to?(:as_teacher, @homework.course) %>
|
||||
<%= link_to student_work.project.name, applied_join_project_path(:object_id => student_work.project.id, :is_teacher => 1), :remote => true, :method => "post", :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称" %>
|
||||
<% else %>
|
||||
<span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<div class="syllabus_courses_box">
|
||||
<% projects.each do |project|%>
|
||||
<% allow_visit = project.is_public || User.current.member_of?(project) || User.current.admin? || User.current.allowed_to?(:as_teacher, @homework.course) %>
|
||||
<div class="syllabus_courses_list" style="cursor: default">
|
||||
<div class="sy_courses_open">
|
||||
<h3>
|
||||
<% if allow_visit %>
|
||||
<%= link_to "#{project.name}", project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
|
||||
<% else %>
|
||||
<a href="javascript:void(0)" class="new_project_title fl" title="私有项目不可访问"><%=project.name %></a>
|
||||
<% end %>
|
||||
</h3>
|
||||
<span class="<%= project.is_public? ? 'syllabus_class_open' : 'syllabus_class_private' %> fl ml10 mt3 syllabus_class_property"><%= project.is_public? ? '公开' : '私有' %></span>
|
||||
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="fl sy_p_grey" style="margin-left: 0">更新时间:<%= format_date(project.updated_on) %></p>
|
||||
<div class=" fr">
|
||||
<p class="list-info fr grayTxt">
|
||||
<%= link_to project.members.count, allow_visit ? member_project_path(project) : 'javascript:void(0)', :class => "c_blue" %><span class="mr5">成员 |</span>
|
||||
<%= link_to project.project_score.issue_num, allow_visit ? project_issues_path(project) : 'javascript:void(0)', :class => "c_blue" %><span class="mr5">问题 |</span>
|
||||
<%= link_to project.project_score.attach_num, allow_visit ? file_project_path(project) : 'javascript:void(0)', :class => "c_blue" %><span>资源</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div><!--syllabus_courses_box end-->
|
|
@ -4,6 +4,7 @@
|
|||
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
|
||||
<% end %>
|
||||
<% is_group_project_homework = @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
@ -12,12 +13,14 @@
|
|||
$("#Container").css("width","1000px");
|
||||
<% if @tab == 2%>
|
||||
$("#student_work_tab2").click();
|
||||
<% elsif @tab == 3 %>
|
||||
$("#student_work_tab3").click();
|
||||
<% end %>
|
||||
sd_create_editor_from_data(<%= @homework.id %>, null, "100%", "<%= @homework.class.to_s %>");
|
||||
});
|
||||
|
||||
function HoverLi(n){
|
||||
for(var i=1;i<=2;i++){
|
||||
for(var i=1;i<=3;i++){
|
||||
$('#student_work_tab'+i).removeClass('selected');
|
||||
$('#student_work_con'+i).addClass('undis');
|
||||
}
|
||||
|
@ -156,7 +159,14 @@
|
|||
<li onclick="HoverLi(2);" id="student_work_tab2">
|
||||
<a href="javascript:void(0);" class="fontGrey3">作品列表</a>
|
||||
</li>
|
||||
<li style="width:515px;"> </li>
|
||||
<% if is_group_project_homework %>
|
||||
<li onclick="HoverLi(3);" id="student_work_tab3">
|
||||
<a href="javascript:void(0);" class="fontGrey3">关联项目列表</a>
|
||||
</li>
|
||||
<li style="width:415px;"> </li>
|
||||
<% else %>
|
||||
<li style="width:515px;"> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<div id="student_work_con1">
|
||||
|
@ -176,6 +186,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
|
||||
<div class="undis" id="student_work_con3">
|
||||
<% project_ids = @homework.student_work_projects.blank? ? "(-1)" : "(" + @homework.student_work_projects.map{|pro| pro.project_id}.join(",") + ")" %>
|
||||
<% projects = Project.where("id in #{project_ids}") %>
|
||||
<%= render :partial => "student_work/relate_projects", :locals => {:projects => projects}%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -36,8 +36,8 @@
|
|||
</div>
|
||||
<% elsif activity.homework_type == 3 && activity.homework_detail_group%>
|
||||
<% if activity.homework_detail_group.base_on_project == 1 %>
|
||||
<div class="homepagePostDeadline mr15">
|
||||
项目(<%=activity.student_work_projects.where("is_leader = 1").count %>)
|
||||
<div class="homepagePostSubmit mr15">
|
||||
<%=link_to "项目(#{activity.student_work_projects.where('is_leader = 1').count})",student_work_index_url_in_org(activity.id, 3),:class => "c_blue" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="homepagePostDeadline mr15">
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class AddCourseIdToSwp < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :student_work_projects, :course_id, :integer
|
||||
count = StudentWorkProject.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
StudentWorkProject.page(i).per(30).each do |swp|
|
||||
if swp.homework_common && swp.homework_common.course
|
||||
swp.update_column("course_id", swp.homework_common.course_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -547,14 +547,6 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
|
|||
.merge-discussion-input {margin:0 -10px; padding:10px; background-color:#f8f8f8;}
|
||||
.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; padding:5px;}
|
||||
|
||||
/*新版项目列表新增*/
|
||||
.new_project_title{ font-size:16px; color:#333; max-width:480px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.icons_project_list{ width:8px; height:8px; border:2px solid #fff; background:#3b94d6;-webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;-webkit-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);-moz-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5); }
|
||||
.icons_project_favorite {background: url(/images/syllabus/sy_icons_star.png) 0px 0px no-repeat; width:20px; height:20px; display:block; float:left;}
|
||||
.icons_project_star{background: url(/images/syllabus/sy_icons_star.png) 0px -27px no-repeat; width:20px; height:20px; display:block; float:left;}
|
||||
.new_projectlist_more{ text-align:center;}
|
||||
.new_projectlist_more a:hover{ color:#3b94d6;}
|
||||
|
||||
/*发布新样式*/
|
||||
.publish-icon {background:url("/images/new_project/icons_issue.png") 0px -82px no-repeat; width:18px; height:18px; display:block;}
|
||||
.publish-icon:hover {background:url("/images/new_project/icons_issue.png") -25px -82px no-repeat;}
|
||||
|
|
|
@ -1529,4 +1529,12 @@ a.syllabusbox_a_blue{
|
|||
/*模拟title*/
|
||||
.simulation-title {position:absolute; background-color:#fff; padding:5px 10px; z-index:99; white-space:nowrap; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); display:none; color:#666; border:1px solid #666; line-height:1;}
|
||||
/*项目创建*/
|
||||
.project_new_input {border: 1px solid #ddd;height: 20px;width: 794px;background: #fff;padding: 5px;}
|
||||
.project_new_input {border: 1px solid #ddd;height: 20px;width: 794px;background: #fff;padding: 5px;}
|
||||
|
||||
/*新版项目列表新增*/
|
||||
.new_project_title{ font-size:16px; color:#333; max-width:480px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.icons_project_list{ width:8px; height:8px; border:2px solid #fff; background:#3b94d6;-webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;-webkit-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);-moz-box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5);box-shadow: 0px 2px 5px rgba(146, 153, 169, 0.5); }
|
||||
.icons_project_favorite {background: url(/images/syllabus/sy_icons_star.png) 0px 0px no-repeat; width:20px; height:20px; display:block; float:left;}
|
||||
.icons_project_star{background: url(/images/syllabus/sy_icons_star.png) 0px -27px no-repeat; width:20px; height:20px; display:block; float:left;}
|
||||
.new_projectlist_more{ text-align:center;}
|
||||
.new_projectlist_more a:hover{ color:#3b94d6;}
|
Loading…
Reference in New Issue