分组作业动态

This commit is contained in:
cxt 2015-12-09 10:29:54 +08:00
parent a9f6e817b4
commit 53f9141cf1
9 changed files with 91 additions and 44 deletions

View File

@ -551,21 +551,19 @@ class StudentWorkController < ApplicationController
#创建作业的关联项目
def student_work_project
projects = cur_user_projects_for_homework @homework
if projects.nil?
@project = StudentWorkProject.new
@project.homework_common_id = @homework.id
@project.project_id = (Project.find params[:project_id]).id
@project.user_id = User.current.id
if @project.save
@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
@project = StudentWorkProject.new
@project.homework_common_id = @homework.id
@project.project_id = (Project.find params[:projectName].to_i).id
@project.user_id = User.current.id
if @project.save
@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
#查找学生创建的项目列表
@ -574,7 +572,11 @@ class StudentWorkController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
project_ids = Project.where("user_id = #{User.current.id} and ")
@project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'")
@first = params[:first].to_i
respond_to do |format|
format.js
end
end
private

View File

@ -2462,13 +2462,13 @@ module ApplicationHelper
def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity
if User.current.member_of_course?(homework.course)
if is_teacher
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
projects = cur_user_projects_for_homework homework
if projects.nil?
link_to "关联项目(#{homework.student_work_projects.count})", 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=> '请选择分组作业关联的项目'
else
link_to "已关联项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue"
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=> '取消关联项目'
end
end
end

View File

@ -1,11 +1,13 @@
<div id="popbox02" style="">
<span class="f16 fontBlue">关联项目</span>
<a href="javascript:void(0);" class="popClose" onclick="clickCanel();"></a>
<%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:course_id=>@course_id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %>
<input type="text" name="serach_project" placeholder="输入项目名称进行搜索" class="searchResourcePopup" />
<span id="no_search_result" style="display: none">您当前尚未参与任何项目,请先加入项目再关联。</span>
<div id="search_project_list"></div>
<ul class="mb10 maxHeight100">
<%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course,:course_activity =>@course_activity),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %>
<input type="text" name="project" placeholder="输入项目名称进行搜索" class="searchResourcePopup mb10" />
<div class="cl"></div>
<p id="no_search_result" class="c_red" style="width:220px;display: none">您当前尚未参与任何项目,请先加入项目再关联。</p>
<ul id="search_project_list" class="maxHeight100"></ul>
<p id="notes" class="c_red"></p>
<!--<ul class="mb10 maxHeight100">
<li>
<label>
<input name="checkMenu" type="radio" class="courseSendCheckbox"/>
@ -26,23 +28,23 @@
<input name="checkMenu" type="radio" class="courseSendCheckbox"/>
<span class="sendCourseName">项目四</span></label>
</li>
</ul>
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText">确定</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
</ul>-->
<div class="courseSendSubmit mt10"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK();">确定</a></div>
<div class="courseSendCancel mt10"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
<div class="cl"></div>
<% end %>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;
function search_orgs(e){
function search_pros(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'student_work', :action => 'search_public_orgs_not_in_course') %>'+'?name='+ e.target.value+'&page='+page,
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?name='+ e.target.value,
type:'get'
});
}
@ -55,29 +57,24 @@
}
//查询组织
$("input[name='orgs']").on('input', function (e) {
throttle(search_orgs,window,e);
$("input[name='project']").on('input', function (e) {
throttle(search_pros,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_public_orgs_not_in_course') %>'+'?page=1',
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?first=1',
type:'get'
});
});
function cancel_join_orgs() {
$("#join_orgs_for_course input:checked").attr("checked", false);
}
function course_join_org(courseId) {
$.ajax({
url: "/org_courses?" + $("#join_orgs_for_course").serialize() + "&course_id=" + courseId,
type: "post",
success: function (data) {
$.ajax({
url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true&name=" + $("input[name='orgs']").val().trim(),
type: "get"
});
}
});
function clickOK() {
var radio = $("input[name='projectName']:checked");
if(radio.length < 1) {
$("#notes").html("请先选择一个项目");
return false;
} else {
$("#student_work_relate_project").submit();
}
}
</script>

View File

@ -0,0 +1,9 @@
<% if @first == 1 && @project_ids.empty? %>
$("#no_search_result").show();
<% else %>
$("#search_project_list").html("");
<% @project_ids.each do |project|%>
link = "<li><label><input type='radio' class='courseSendCheckbox' name='projectName' value='<%=project.id%>'/><span class='sendCourseName'> <%=project.name %> </span></label></li>";
$("#search_project_list").append(link );
<% end %>
<% end %>

View File

@ -0,0 +1,8 @@
hideModal("#popbox02");
<% 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_common_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%");
<% end %>

View File

@ -44,6 +44,10 @@
<span class="green_homework_btn_cir ml5" title="目前教师和教辅正在评阅">教师评阅中</span>
<% end%>
<% end%>
<div class="cl"></div>
<% if activity.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">
<% if activity.homework_type == 3%>
<div class="homepagePostSubmit">

View File

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

View File

@ -1197,6 +1197,17 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-
.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;}
.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;}
.borderRadius {border-radius:5px;}
.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;}
.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;}
.mt7 {margin-top:7px;}
.ml7 {margin-left:7px;}
.tac {text-align:center;}
.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;}
.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;}
.mr150 {margin-right:150px;}
/*上传资源弹窗*/
.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}

View File

@ -1366,3 +1366,18 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-
.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;}
.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;}
.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;}
.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;}
.borderRadius {border-radius:5px;}
.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;}
.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;}
.mt7 {margin-top:7px;}
.ml7 {margin-left:7px;}
.tac {text-align:center;}
.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;}
.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;}
.mr150 {margin-right:150px;}