Merge branch 'develop' into weixin_guange

This commit is contained in:
yuanke 2016-08-23 10:24:46 +08:00
commit 55512f9eb2
16 changed files with 271 additions and 36 deletions

View File

@ -287,6 +287,30 @@ module Mobile
end
end
desc "获取课程动态"
params do
requires :id, type: Integer
requires :token, type: String
end
post 'activities' do
authenticate!
user = current_user
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
activities = UserActivity.where("(container_type = 'Course' and container_id = #{params[:id]} and act_type in #{course_types})").order('updated_at desc')
page = params[:page] ? params[:page] : 0
all_count = activities.count
activities = activities.limit(10).offset(page * 10)
count = activities.count
present :data, activities, with: Mobile::Entities::Activity,user: user
present :all_count, all_count
present :count, count
present :page, page
present :status, 0
end
desc "课程作业列表"
params do
requires :token, type: String

View File

@ -33,11 +33,6 @@ class QualityAnalysisController < ApplicationController
projects_date = open(@sonar_address + "/api/projects/index").read
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first
logger.info("###########################6666666666666")
logger.info("job_name is ###########################{job_name}")
logger.info("@client_jenkins is ###########################{@client_jenkins}")
logger.info("@client_jenkins job is ###########################{@client_jenkins.job}")
logger.info("@client_jenkins result is ###########################{@client_jenkins.job.exists?(job_name)}")
if @client_jenkins.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank?
aa = @client_jenkins.job.delete("#{job_name}")
quality_an.delete unless quality_an.blank?

View File

@ -386,9 +386,9 @@ update
project_score.update_column(:changeset_num, @changesets_all_count)
end
# unless @changesets_latest_coimmit.blank?
# update_commits_date(@project, @changesets_latest_coimmit)
# end
unless @changesets_latest_coimmit.blank?
update_commits_date(@project, @changesets_latest_coimmit)
end
@creator = @project.owner.to_s
gitlab_address = Redmine::Configuration['gitlab_address']

View File

@ -868,6 +868,7 @@ class StudentWorkController < ApplicationController
update_org_activity(@homework.class,@homework.id)
if @work.save
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
@count = @homework.student_works.has_committed.count
respond_to do |format|
format.js
end

View File

@ -2172,7 +2172,7 @@ module ApplicationHelper
candown = User.current.member_of_org?(org) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
elsif attachment.container.is_a?(OrgDocumentComment)
org = attachment.container.organization
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
candown = org.allow_guest_download || User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course

View File

@ -1,6 +1,11 @@
# encoding: utf-8
module QualityAnalysisHelper
def sonar_time sonar_name
sonar = open(@sonar_address + "/api/resources/index?resource=#{sonar_name}&depth=0").read
sonar =JSON.parse(sonar).first['date']
end
def sqale_rating_status val
arr = []
if val <= 5

View File

@ -82,7 +82,6 @@
<% end %>
<% if all_count > (page.to_i+1) * 10%>
<input type="hidden" value="<%= page%>" id="course_page_num">
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_course" onclick="show_more_course('<%= user_courses4show_user_path(user.id,:page => page)%>');">
<span class="user_icons_moreclass"></span>
</a>

View File

@ -59,7 +59,6 @@
<% end %>
<% if all_count > (page.to_i+1) * 10%>
<input type="hidden" value="<%= page%>" id="project_page_num">
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_project" onclick="show_more_project('<%= user_projects4show_user_path(user.id,:page => page)%>');">
<span class="user_icons_moreclass"></span>
</a>

View File

@ -21,7 +21,7 @@
<li class="analysis-result-version fl fontBlue2 hidden" title="<%= qa.branch %>"><%= qa.branch %></li>
<li class="analysis-result-loc fl fontBlue2 hidden" title="<%= qa.language %>"><%= qa.language %></li>
<li class="analysis-result-debt fl fontBlue2 hidden" title="<%= qa.path %>"><%= qa.path %></li>
<li class="analysis-result-time fl fontBlue2 hidden" title="<%= qa.updated_at %>"><%= format_time(qa.updated_at) %></li>
<li class="analysis-result-time fl fontBlue2 hidden" title="<%= sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name) %>"><%= format_time(sonar_time(qa.sonar_name).blank? ? qa.created_at : sonar_time(qa.sonar_name)) %></li>
<% if User.current.try(:login) == qa.author_login || User.current.admin? || is_project_manager?(User.current.id, @project.id) %>
<li class="analysis-result-edit fl fontBlue2 hidden" title="<%= qa.path %>">
<%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true, :class => "fontBlue2" %><span style="color: #888"> / </span>

View File

@ -2,7 +2,7 @@
<span class="c_dark f14 fb fl mr15">
作品
<font class="f12 c_red">
(<%= @student_work_count%>人已交)
(<span id="student_work_count"><%= @student_work_count%></span>人已交)
</font>
<%# my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
<% my_work = cur_user_works_for_homework @homework %>

View File

@ -17,3 +17,5 @@ $("#score_list_<%= @work.id%>").removeAttr("style");
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work, :index => 1}) %>");
$("#work_num_<%= @work.id%>").html(num);
<% end%>
$("#student_work_count").html("<%=@count %>");

View File

@ -16,7 +16,139 @@
<!--<div class="slice3 fl"></div>-->
<!--<div class="cl"></div>-->
<div class="class-search-wrap">
<div ng-class="{'undis': !showActivities}">
<div ng-repeat="act in course_activities">
<div ng-if="act.container_type=='Course' ">
<div ng-if="act.act_type=='HomeworkCommon'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div dataID = "{{act.act_id}}" ng-click="goDetail('homework',act.act_id, act.id)" id="act_{{act.id}}">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-dynamic-author hidden fl">
<span>{{act.author.real_name}}</span>
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
<div class="cl"></div>
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【作业】{{act.subject|safeHtml}}</div>
<div class="post-content c-grey3 mt10 mb10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml" ellipsis-show></div>
<span class="mr15 f12 c-grey2">迟交扣分:{{act.homework_common_detail.late_penalty}}分</span> <span ng-if="!act.homework_common_detail.anonymous_comment" class="f12 c-grey2">匿评开启时间:{{act.homework_common_detail.evaluation_start}}</span><br />
<span ng-if="!act.homework_common_detail.anonymous_comment" class="mr15 f12 c-grey2">缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品</span> <span ng-if="!act.homework_common_detail.anonymous_comment" class="f12 c-grey2">匿评关闭时间:{{act.homework_common_detail.evaluation_end}}</span>
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
</div>
<div class="fr mr25 f13">
<a ng-if="!act.reply_count" ng-click="goDetail('homework',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
<a ng-if="act.reply_count" ng-click="goDetail('homework',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<div ng-if="act.act_type=='News'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div dataID = "{{act.act_id}}" ng-click="goDetail('course_notice',act.act_id, act.id)" id="act_{{act.id}}">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-dynamic-author hidden fl">
<span>{{act.author.real_name}}</span>
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
<div class="cl"></div>
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【通知】{{act.subject|safeHtml}}</div>
<div class="post-content c-grey3 mt10 mb10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml" ellipsis-show></div>
</div>
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
</div>
<div class="fr mr25 f13">
<a ng-if="!act.reply_count" ng-click="goDetail('course_notice',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
<a ng-if="act.reply_count" ng-click="goDetail('course_notice',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<div ng-if="act.act_type=='Message'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div dataID = "{{act.act_id}}" ng-click="goDetail('course_discussion',act.act_id, act.id)" id="act_{{act.id}}">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-dynamic-author hidden fl">
<span>{{act.author.real_name}}</span>
<img ng-if="act.author.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="act.author.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
<div class="cl"></div>
<div class="post-dynamic-title c-grey3 hidden mt12 fb">【帖子】{{act.subject|safeHtml}}</div>
<div class="post-content c-grey3 mt10 mb10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml" ellipsis-show></div>
</div>
<!--<a herf="javascript:void(0);" class="c-grey2 f13 fr mt5 mb10 post-more mr20 undis" text-auto-height>点击展开</a>-->
<div class="cl"></div>
</div>
<div class="post-dynamic-from hidden fl c-grey3">来源: <span class="c-blue">{{act.course_project_name}}</span></div>
<div class="fr f13">
<div ng-if="!act.praise_count" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span></span></div>
<div ng-if="act.praise_count && !act.has_praise" ng-click="addPraise(act);"><img src="/images/wechat/w_praise.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
<div ng-if="act.has_praise" ng-click="decreasePraise(act);"><img src="/images/wechat/w_praised.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span>{{act.praise_count}}</span></div>
</div>
<div class="fr mr25 f13">
<a ng-if="!act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">回复</span></a>
<a ng-if="act.reply_count" ng-click="goDetail('course_discussion',act.act_id, act.id)"><img src="/images/wechat/w_reply.png" width="20" style="vertical-align:top; margin-top:2px;" class="mr5" /><span style="vertical-align:top;">{{act.reply_count}}</span></a>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
<div ng-if="act.act_type=='Course'">
<div class="post-container">
<div class="post-wrapper">
<div class="post-main">
<div class="post-avatar fl mr10"><img ng-src="{{replaceUrl(act.author.img_url)}}" width="30" height="30" class="border-radius img-circle" /></div>
<div class="post-title hidden mb5"><span class="c-grey3 f13 fb mr10">{{act.author.real_name}}</span>创建了<span class="c-grey3 f13 fb ml10">{{act.course_project_name}} | 班级</span></div>
<div class="post-title hidden"><span class="mr10">{{act.latest_update}}</span></div>
<div class="cl"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div ng-if="course_has_more">
<div id="more_course_activities" class="more-events mt10" ng-click="getActivities(course_activities_page+1);">更多</div>
</div>
</div>
<div ng-class="['class-search-wrap',{'undis': current_tab != 1}]">
<div class="class-search-inner"> <img src="/images/wechat/search.png" width="18" class="class-search-icon" />
<input class="class-detail-search" ng-model="searchText" placeholder="输入关键词进行搜索" />
</div>

View File

@ -38,7 +38,6 @@ function edit_user_introduction(url){
function show_more_course(url){
$.get(
url,
{ page: $("#course_page_num").val() },
function (data) {
}
);
@ -48,7 +47,6 @@ function show_more_course(url){
function show_more_project(url){
$.get(
url,
{ page: $("#project_page_num").val() },
function (data) {
}

View File

@ -2,7 +2,6 @@
function show_more_course(url){
$.get(
url,
{ page: $("#course_page_num").val() },
function (data) {
}
);

View File

@ -5,6 +5,39 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
var courseid = $routeParams.id;
var tag = $routeParams.tag;
vm.course_activities_page = rms.get('course_activities_page') || 0;
vm.course_activities = rms.get("course_activities") || [];
vm.course_has_more = rms.get("course_has_more");
vm.course = rms.get("course") || null;
var getClassActivities = function(page){
$http({
method: 'POST',
url: apiUrl + "courses/activities?id=" + courseid,
data:{token:auth.token(),page:page}
}).then(function successCallback(response) {
console.log(response.data);
if(response.data.status == 0){
vm.class_activities_page = response.data.page;
if(response.data.page > 0)
{
vm.course_activities = vm.class_activities.concat(response.data.data);
}
else{
vm.course_activities = response.data.data;
vm.course_activities_page = 0;
vm.course_has_more = (response.data.count + response.data.page * 10) < response.data.all_count;
}
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
}, function errorCallback(response) {
});
};
var getUsers = function(){
if(vm.teachers.length<=0){
@ -35,7 +68,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
}
)
}
}
};
var getResources = function(){
if(vm.resources.length<=0){
@ -46,7 +79,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.resources_tag = true;
});
}
}
};
var getHomeworks = function(){
if(vm.homeworks.length <=0){
@ -56,7 +89,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.homeworks_tag = true;
});
}
}
};
var getExercises = function(){
if(vm.exercises.length <=0){
@ -66,7 +99,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.exercises_tag = true;
});
}
}
};
vm.isTeacher = false;
@ -75,6 +108,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.currentTab = index;
vm.searchText = '';
vm.showActivities = false;
vm.showClassMate = false;
vm.showResources = false;
vm.showHomework = false;
@ -84,35 +118,43 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.exercises_tag = false;
if(vm.isTeacher){
if(index == 1){ //课件
if(index == 1){
getClassActivities(0);
vm.showActivities = true;
}
else if(index == 2){ //课件
getResources();
vm.showResources = true;
} else if(index==2){ //作业
}
else if(index==3){ //作业
getHomeworks();
vm.showHomework = true;
} else if(index==3){ //小测验
getExercises();
vm.showTestcase = true;
} else if(index==4){ //学生管理
}
else if(index==4){ //学生管理
getUsers();
vm.showClassMate = true;
}
} else {
if(index == 2){
if(index == 1){
getClassActivities(0);
vm.showActivities = true;
}
else if(index == 3){
getUsers();
vm.showClassMate = true;
} else if(index==1){
}
else if(index==2){
getResources();
vm.showResources = true;
}
}
rms.save("tab_num",index);
}
};
vm.tabRecord = rms.get('tab_num') || 1;
vm.course = {};
// vm.course = {};
vm.students = [];
vm.teachers = [];
vm.reviewers = []; //待审批
@ -126,6 +168,11 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.alertService = alertService.create();
vm.invite = function(){
rms.save('course_activities_page',vm.course_activities_page);
rms.save("course_activities",vm.course_activities);
rms.save("course_has_more",vm.course_has_more);
rms.save("course",vm.course);
$location.path("/invite_code").search({id: courseid});
};
@ -133,7 +180,7 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.myresource_sendIndex = index;
rms.save('myresource_sendIndex',index);
$location.path("/send_class_list").search({id: r.id});
}
};
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response) {
@ -161,12 +208,12 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
var resetMenu = function(is_teacher){
vm.isTeacher = is_teacher;
if(is_teacher){
vm.menus = ["课件", "作业", "测验", "成员管理"];
vm.menus = ["动态", "课件", "作业", "成员管理"];
} else {
vm.menus = ['课件', "我的同学"];
vm.menus = ['动态','课件', "我的同学"];
}
}
};
vm.onSetting = function(user){
rms.save('current_edit_member', user);
@ -178,8 +225,41 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
rms.save('current_course', vm.course);
$location.path("/review_class_member").search({id: courseid,user_id: user.id});
}
};
//跳到详情页
vm.goDetail = function(type, act_id,id){
rms.save("yoffset", document.documentElement.scrollTop || document.body.scrollTop);
rms.save('course_activities_page',vm.course_activities_page);
rms.save("course_activities",vm.course_activities);
rms.save('course_has_more', vm.course_has_more);
rms.save("course",vm.course);
// $location.path('/'+type+'/'+act_id);
$location.path("/"+type).search({id: act_id});
};
vm.addPraise = function(act){
for(var i in vm.course_activities){
if(vm.course_activities[i].act_id == act.act_id){
vm.course_activities[i].praise_count += 1;
vm.course_activities[i].has_praise = true;
break;
}
}
common.addCommonPraise(act);
};
vm.decreasePraise = function(act){
for(var i in vm.course_activities){
if(vm.course_activities[i].act_id == act.act_id){
vm.course_activities[i].praise_count -= 1;
vm.course_activities[i].has_praise = false;
break;
}
}
common.decreaseCommonPraise(act);
};
}]);

View File

@ -114,6 +114,7 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut
//跳到详情页
vm.goDetail = function(type, act_id,id){
rms.save("yoffset", document.documentElement.scrollTop || document.body.scrollTop);
rms.save('project_activities_page',vm.project_activities_page);
rms.save("project_activities",vm.project_activities);
rms.save('project_has_more', vm.project_has_more);
rms.save("project",vm.project);