commit
eb84434b50
@ -0,0 +1,5 @@
|
|||||||
|
class CourseContributorScore < ActiveRecord::Base
|
||||||
|
attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num, :resource_num, :user_id, :total_score
|
||||||
|
belongs_to :course
|
||||||
|
belongs_to :user
|
||||||
|
end
|
@ -0,0 +1,47 @@
|
|||||||
|
<% course_file_num = visable_attachemnts_incourse(@course).count%>
|
||||||
|
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||||
|
<% if show_nav?(@course.homework_commons.count) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10"%>
|
||||||
|
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(@course.news.count) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||||
|
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(course_file_num) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||||
|
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||||
|
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||||
|
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||||
|
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(course_feedback_count) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10" %>
|
||||||
|
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}", :id => "course_jour_count"%>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(course_poll_count) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10"%>
|
||||||
|
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||||
|
<div class="subNav">
|
||||||
|
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10"%>
|
||||||
|
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
@ -0,0 +1,99 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<link href="css/public.css" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="css/org.css" rel="stylesheet" type="text/css" />
|
||||||
|
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
|
||||||
|
<script type="text/javascript" src="js/bootstrap.js"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
var popupHeight = $(".resourceSharePopup").outerHeight(true);
|
||||||
|
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
||||||
|
|
||||||
|
|
||||||
|
$(".resourcePopupClose").click(function(){
|
||||||
|
$(".resourceSharePopup").css("display","none");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="resourceSharePopup">
|
||||||
|
<div>
|
||||||
|
<div class="relateText fl">请选择关联到组织的课程</div>
|
||||||
|
</div>
|
||||||
|
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose"></a></div>
|
||||||
|
<div class="fl">
|
||||||
|
<%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %>
|
||||||
|
<input type="text" name="courses" placeholder="搜索您已加入的课程的名称" class="searchCourse" />
|
||||||
|
<div id="search_courses_result_list" class="mb8"></div>
|
||||||
|
<div class="courseSendSubmit">
|
||||||
|
<a href="javascript:void(0);" onclick="org_join_courses(<%= organization_id %>);" class="sendSourceText">关联</a>
|
||||||
|
</div>
|
||||||
|
<div class="courseSendCancel"><a href="javascript:void(0);" onclick="cancel_join_courses();" class="sendSourceText">取消</a></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var lastSearchCondition = '';
|
||||||
|
var page = 1;
|
||||||
|
var count = 0;
|
||||||
|
var maxPage = 0;
|
||||||
|
function search_courses(e){
|
||||||
|
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastSearchCondition = $(e.target).val().trim();
|
||||||
|
$.ajax({
|
||||||
|
url: '<%= url_for(:controller => 'organizations', :action => 'search_courses') %>'+'?name='+ e.target.value,
|
||||||
|
type:'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function throttle(method,context,e){
|
||||||
|
clearTimeout(method.tId);
|
||||||
|
method.tId=setTimeout(function(){
|
||||||
|
method.call(context,e);
|
||||||
|
},500);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询组织
|
||||||
|
$("input[name='courses']").on('input', function (e) {
|
||||||
|
throttle(search_courses,window,e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$.ajax({
|
||||||
|
url: '<%= url_for(:controller => 'organizations', :action => 'search_courses') %>',
|
||||||
|
type:'get'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
function cancel_join_courses() {
|
||||||
|
$("#join_courses_form input:checked").attr("checked", false);
|
||||||
|
//$("#search_courses_result_list").html("");
|
||||||
|
}
|
||||||
|
function org_join_courses(orgId) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/organizations/"+orgId + "/join_courses?" + $("#join_courses_form").serialize(),
|
||||||
|
type: "post",
|
||||||
|
success: function (data) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/organizations/" + orgId + "/search_courses?name=" + $("input[name='courses']").val().trim(),
|
||||||
|
type: "get"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,95 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<link href="css/public.css" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="css/org.css" rel="stylesheet" type="text/css" />
|
||||||
|
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
|
||||||
|
<script type="text/javascript" src="js/bootstrap.js"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
var popupHeight = $(".resourceSharePopup").outerHeight(true);
|
||||||
|
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
||||||
|
|
||||||
|
|
||||||
|
$(".resourcePopupClose").click(function(){
|
||||||
|
$(".resourceSharePopup").css("display","none");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="resourceSharePopup">
|
||||||
|
<div>
|
||||||
|
<div class="relateText fl">请选择关联到组织的项目</div>
|
||||||
|
</div>
|
||||||
|
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose"></a></div>
|
||||||
|
<div class="fl">
|
||||||
|
<%=form_tag url_for(:controller => 'organizations', :action => 'join_projects', :organization_id => organization_id),:method => 'post', :id => 'join_projects_form', :remote => true,:class=>"resourcesSearchBox" do %>
|
||||||
|
<input type="text" name="projects" placeholder="搜索您已加入的项目的名称" class="searchCourse" />
|
||||||
|
<div id="search_projects_result_list" class="mb8"></div>
|
||||||
|
<div class="courseSendSubmit">
|
||||||
|
<a href="javascript:void(0);" onclick="org_join_projects(<%= organization_id %>);" class="sendSourceText">关联</a>
|
||||||
|
</div>
|
||||||
|
<div class="courseSendCancel"><a href="javascript:void(0);" onclick="cancel_join_projects();" class="sendSourceText">取消</a></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var lastSearchCondition = '';
|
||||||
|
var page = 1;
|
||||||
|
var count = 0;
|
||||||
|
var maxPage = 0;
|
||||||
|
function search_projects(e){
|
||||||
|
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastSearchCondition = $(e.target).val().trim();
|
||||||
|
$.ajax({
|
||||||
|
url: '<%= url_for(:controller => 'organizations', :action => 'search_projects') %>'+'?name='+ e.target.value,
|
||||||
|
type:'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function throttle(method,context,e){
|
||||||
|
clearTimeout(method.tId);
|
||||||
|
method.tId=setTimeout(function(){
|
||||||
|
method.call(context,e);
|
||||||
|
},500);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询组织
|
||||||
|
$("input[name='projects']").on('input', function (e) {
|
||||||
|
throttle(search_projects,window,e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$.ajax({
|
||||||
|
url: '<%= url_for(:controller => 'organizations', :action => 'search_projects') %>',
|
||||||
|
type:'get'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
function cancel_join_projects() {
|
||||||
|
$("#join_projects_form input:checked").attr("checked", false);
|
||||||
|
//$("#search_projects_result_list").html("");
|
||||||
|
}
|
||||||
|
function org_join_projects(orgId) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/organizations/"+orgId + "/join_projects?" + $("#join_projects_form").serialize(),
|
||||||
|
type: "post",
|
||||||
|
success: function (data) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/organizations/" + orgId + "/search_projects?name=" + $("input[name='projects']").val().trim(),
|
||||||
|
type: "get"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,3 @@
|
|||||||
|
$('#topnav_course_menu').hide();
|
||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_course_menu', :locals => {:organization_id => @organization.id}) %>');
|
||||||
|
$('#ajax-modal').show();
|
@ -0,0 +1,5 @@
|
|||||||
|
$("#homepageLeftMenuCourses").html("");
|
||||||
|
$("#homepageLeftMenuCourses").append("<ul>");
|
||||||
|
$("#homepageLeftMenuCourses").append("<%= escape_javascript(render :partial => 'layouts/org_courses',
|
||||||
|
:locals=>{:courses=>@organization.courses.reorder('created_at').limit(5),:org_id=>@organization.id,:page=> 1}) %>");
|
||||||
|
$("#homepageLeftMenuCourses").append("</ul>");
|
@ -0,0 +1,3 @@
|
|||||||
|
$('#topnav_project_menu').hide();
|
||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_project_menu', :locals => {:organization_id => @organization.id}) %>');
|
||||||
|
$('#ajax-modal').show();
|
@ -0,0 +1,5 @@
|
|||||||
|
$("#homepageLeftMenuProjects").html("");
|
||||||
|
$("#homepageLeftMenuProjects").append("<ul>");
|
||||||
|
$("#homepageLeftMenuProjects").append("<%= escape_javascript(render :partial => 'layouts/org_projects',
|
||||||
|
:locals=>{:projects=>@organization.projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=> 1}) %>");
|
||||||
|
$("#homepageLeftMenuProjects").append("</ul>");
|
@ -0,0 +1,9 @@
|
|||||||
|
$("#search_courses_result_list").html("");
|
||||||
|
$("#search_courses_result_list").append('<ul class="ml5">');
|
||||||
|
|
||||||
|
<% @courses.each do |course|%>
|
||||||
|
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='courseNames[]' value='<%=course.id%>'/><span class='search_org fl'> <%=course.name %> </span></label></li><div class='cl mt5'></div>";
|
||||||
|
$("#search_courses_result_list").append(link );
|
||||||
|
<%end %>
|
||||||
|
$("#search_courses_result_list").append('</ul>')
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
$("#search_projects_result_list").html("");
|
||||||
|
$("#search_projects_result_list").append('<ul class="ml5">');
|
||||||
|
|
||||||
|
<% @projects.each do |project|%>
|
||||||
|
link = "<li><label><input type='checkbox'class='mr5 fl mt3' name='projectNames[]' value='<%=project.id%>'/><span class='search_org fl'> <%=project.name %> </span></label></li><div class='cl mt5'></div>";
|
||||||
|
$("#search_projects_result_list").append(link );
|
||||||
|
<%end %>
|
||||||
|
$("#search_projects_result_list").append('</ul>')
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<div class="project_r_h">
|
||||||
|
<div class="fl"><h2 class="project_h2_repository"><%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %></h2></div>
|
||||||
|
</div>
|
||||||
|
<%= form_for('forked',:url => {:controller => 'repositories', :action => 'forked'},:method => "post") do |f| %>
|
||||||
|
<input type="text" name="repo_name"/>
|
||||||
|
<button type="submit">确定</button>
|
||||||
|
<% end %>
|
||||||
|
<%= @project.id %>
|
||||||
|
<%= @repository.id %>
|
||||||
|
<%= User.current %>
|
@ -0,0 +1,24 @@
|
|||||||
|
<div id="popbox02">
|
||||||
|
<div class="ni_con">
|
||||||
|
<div><p align='center' style='margin-top: 35px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="ni_btn mt10">
|
||||||
|
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||||
|
编 辑
|
||||||
|
</a>
|
||||||
|
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||||
|
取 消
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function clickOK() {
|
||||||
|
window.location.href = '<%= edit_student_work_path(@work.id)%>';
|
||||||
|
}
|
||||||
|
function clickCanel() {
|
||||||
|
hideModal('#popbox02');
|
||||||
|
window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>';
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,18 @@
|
|||||||
|
class DeleteUselessOrgActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
OrgActivity.all.each do |act|
|
||||||
|
if act.container_type == 'Course'
|
||||||
|
if CourseActivity.where("course_act_type=? and course_act_id =? and course_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0
|
||||||
|
act.destroy
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if act.container_type == 'Project' and ForgeActivity.where("forge_act_type=? and forge_act_id =? and project_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0
|
||||||
|
act.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,16 @@
|
|||||||
|
class CreateCourseContributorScores < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :course_contributor_scores do |t|
|
||||||
|
t.integer :course_id
|
||||||
|
t.integer :user_id
|
||||||
|
t.integer :message_num
|
||||||
|
t.integer :message_reply_num
|
||||||
|
t.integer :news_reply_num
|
||||||
|
t.integer :resource_num
|
||||||
|
t.integer :journal_num
|
||||||
|
t.integer :journal_reply_num
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddTotalScoreToCourseContributorScore < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :course_contributor_scores, :total_score, :integer
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,36 @@
|
|||||||
|
class AddCourseContributorTotalScore < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
# course_count = Course.all.count / 30 + 1
|
||||||
|
# transaction do
|
||||||
|
# for i in 1 ... course_count do i
|
||||||
|
Course.all.each do |course|
|
||||||
|
if course.course_activities.count > 1
|
||||||
|
course.student.each do |s|
|
||||||
|
puts course.id
|
||||||
|
puts course.name
|
||||||
|
puts s.student_id
|
||||||
|
# board_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?",s.student_id, course.id, "Message").count * 2
|
||||||
|
board_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is null;").count * 2
|
||||||
|
message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null").count * 1
|
||||||
|
common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1
|
||||||
|
# attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
|
||||||
|
attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id};").count * 5
|
||||||
|
journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.student_id, course.id, "Course").count * 1
|
||||||
|
# journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
|
||||||
|
# journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1
|
||||||
|
total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count
|
||||||
|
if total !=0
|
||||||
|
CourseContributorScore.create(:course_id => course.id, :user_id => s.student_id, :message_num => board_count, :message_reply_num => message_reply_count,
|
||||||
|
:news_reply_num => common_reply_count, :resource_num => attachment_count, :journal_num => journal_count, :journal_reply_num => 0, :total_score => total)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,60 +1,63 @@
|
|||||||
#coding=utf-8
|
#coding=utf-8
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
module Trustie
|
module Trustie
|
||||||
module Gitlab
|
module Gitlab
|
||||||
|
|
||||||
module ManageMember
|
module ManageMember
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.class_eval {
|
base.class_eval {
|
||||||
before_create :add_gitlab_member
|
before_create :add_gitlab_member
|
||||||
before_destroy :delete_gitlab_member
|
before_destroy :delete_gitlab_member
|
||||||
after_save :change_gitlab_member
|
after_save :change_gitlab_member
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_gitlab_member
|
def change_gitlab_member
|
||||||
if isGitlabProject?
|
if isGitlabProject?
|
||||||
@g ||= ::Gitlab.client
|
@g ||= ::Gitlab.client
|
||||||
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_gitlab_member
|
def add_gitlab_member
|
||||||
if isGitlabProject?
|
if isGitlabProject?
|
||||||
@g ||= ::Gitlab.client
|
@g ||= ::Gitlab.client
|
||||||
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
if self.member.user.gid.nil?
|
||||||
end
|
add_user(self.member.user)
|
||||||
end
|
end
|
||||||
|
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||||
def delete_gitlab_member
|
end
|
||||||
if isGitlabProject?
|
end
|
||||||
if member.roles.count <=1
|
|
||||||
@g ||= ::Gitlab.client
|
def delete_gitlab_member
|
||||||
@g.remove_team_member(project.gpid, self.member.user.gid)
|
if isGitlabProject?
|
||||||
end
|
if member.roles.count <=1
|
||||||
end
|
@g ||= ::Gitlab.client
|
||||||
end
|
@g.remove_team_member(project.gpid, self.member.user.gid)
|
||||||
|
end
|
||||||
private
|
end
|
||||||
def project
|
end
|
||||||
self.member.project
|
|
||||||
end
|
private
|
||||||
|
def project
|
||||||
def repository
|
self.member.project
|
||||||
unless project.nil?
|
end
|
||||||
project.repository
|
|
||||||
end
|
def repository
|
||||||
end
|
unless project.nil?
|
||||||
|
project.repository
|
||||||
def isGitlabProject?
|
end
|
||||||
unless repository.nil?
|
end
|
||||||
repository && repository.gitlab?
|
|
||||||
end
|
def isGitlabProject?
|
||||||
end
|
unless repository.nil?
|
||||||
|
repository && repository.gitlab?
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :course_contributor_score do
|
||||||
|
course_id 1
|
||||||
|
user_id 1
|
||||||
|
message_num 1
|
||||||
|
message_reply_num 1
|
||||||
|
news_reply_num 1
|
||||||
|
resource_num 1
|
||||||
|
journal_num 1
|
||||||
|
journal_reply_num 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe CourseContributorScore, :type => :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue