Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
huang 2016-12-16 16:30:25 +08:00
commit f71ccb6c67
18 changed files with 130 additions and 120 deletions

View File

@ -283,7 +283,6 @@ module Mobile
requires :token, type: String
requires :lastname, type: String
requires :sex, type: Integer
requires :mail, type: String
end
post 'edit_userinfo' do
@ -298,41 +297,11 @@ module Mobile
status = -1
end
if params[:mail].length > 60 then
message = "邮箱地址不能超过60个字符!"
status = -1
end
if !(params[:mail].match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i))
message = "请输入正确的邮箱地址!"
status = -1
end
if status == 0
# 修改邮箱的时候同步修改到gitlab
if user.mail != params[:mail]
g = Gitlab.client
begin
g.edit_user(user.gid, :email => params[:mail])
rescue
Rails.logger.error "sync user's email of gitlab failed!"
end
end
user.mail = params[:mail]
user.lastname = params[:lastname]
user.update_attribute(:lastname, params[:lastname])
se = user.extensions
se.gender = params[:sex]
if user.save && se.save
status = 0
else
message = "该邮箱地址已被使用!"
status = -1
end
se.update_attribute(:gender, params[:sex])
end
if status == 0

View File

@ -830,7 +830,7 @@ class ApplicationController < ActionController::Base
# Returns a string that can be used as filename value in Content-Disposition header
def filename_for_content_disposition(name)
request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident} ? ERB::Util.url_encode(name) : name
request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident|Edge} ? ERB::Util.url_encode(name) : name
end
def api_request?

View File

@ -1831,7 +1831,7 @@ class UsersController < ApplicationController
@message_alls = paginateHelper @message_alls, 20
@unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc").count
# 用户待完成的作业
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
@ -1847,10 +1847,13 @@ class UsersController < ApplicationController
poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}")
@unfinished_poll_count = polls.count - poll_users.count
# 用户待匿评的作品
student_work_evaluations = @user.student_works_evaluation_distributions
student_work_ids = student_work_evaluations.blank? ? "(-1)" : "(" + student_work_evaluations.map{|st| st.student_work_id}.join(",") + ")"
student_work_scores = @user.student_works_scores.where("student_work_id in #{student_work_ids} and reviewer_role = 3")
@anonymous_evaluation_count = student_work_evaluations.count - student_work_scores.count
homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_work_scores = @user.student_works_scores.where("reviewer_role = 3")
anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")"
unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}")
unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")"
@anonymous_evaluation_count = StudentWork.where("student_works.id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").count
# 待评阅的作业 暂不做
# @unreview_homework = 1
@ -1989,7 +1992,7 @@ class UsersController < ApplicationController
# 待完成的作业
def unfinished_homework_list
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
@ -2008,13 +2011,17 @@ class UsersController < ApplicationController
# 待完成的测验
def unfinished_test_list
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2")
exercise_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")"
exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}")
finished_test_ids = exercise_users.blank? ? "(-1)" : "(" + exercise_users.map{|eu| eu.exercise_id }.join(",") + ")"
@unfinished_test = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2 and id not in #{finished_test_ids}")
@unfinished_test_count = @unfinished_test.count
@limit = 20
@unfinished_test_pages = Paginator.new @unfinished_test_count, @limit, params['page'] || 1
@offset ||= @unfinished_test_pages.offset
@unfinished_test = paginateHelper @unfinished_test, @limit
respond_to do |format|
format.js
end
@ -2022,7 +2029,7 @@ class UsersController < ApplicationController
# 待完成的问卷
def unfinished_poll_list
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2")
poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")"
poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}")
@ -2040,12 +2047,20 @@ class UsersController < ApplicationController
# 待匿评的作业
def anonymous_evaluation_list
student_work_evaluations = @user.student_works_evaluation_distributions
student_work_ids = student_work_evaluations.blank? ? "(-1)" : "(" + student_work_evaluations.map{|st| st.student_work_id}.join(",") + ")"
student_work_scores = @user.student_works_scores.where("student_work_id in #{student_work_ids} and reviewer_role = 3")
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_work_scores = @user.student_works_scores.where("reviewer_role = 3")
anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")"
@anonymous_evaluation = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}")
unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}")
unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")"
homework_ids = StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").blank? ? "(-1)" : "(" + StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").map{|st| st.homework_common_id}.join(",") + ")"
@anonymous_evaluation = HomeworkCommon.where("homework_commons.id in #{homework_ids}")
@anonymous_evaluation_count = @anonymous_evaluation.count
@limit = 20
@anonymous_evaluation_pages = Paginator.new @anonymous_evaluation_count, @limit, params['page'] || 1
@offset ||= @anonymous_evaluation_pages.offset
@anonymous_evaluation = paginateHelper @anonymous_evaluation, @limit
respond_to do |format|
format.js
end

View File

@ -85,10 +85,8 @@ module UsersHelper
# 作业类型提示
def homework_type_tip homework_type
case homework_type
when 0
"普通作业"
when 1
"匿评作业"
"普通作业"
when 2
"编程作业"
when 3

View File

@ -44,7 +44,9 @@ class Poll < ActiveRecord::Base
def act_as_course_activity
if self.polls_type == "Course"
if self.polls_status == 2 #问卷是发布状态
if CourseActivity.where(:course_id => self.polls_group_id, :user_id => self.user_id, :course_act_id => self.id, :course_act_type => 'Poll').count == 0
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
end
elsif self.polls_status == 1 #问卷是新建状态
self.course_acts.destroy_all
end

View File

@ -10,41 +10,41 @@
</tr>
</thead>
<tbody>
<%# @anonymous_evaluation.student_common.each do |ae| %>
<% @anonymous_evaluation.each do |ae| %>
<tr>
<th>
<li class="homepageTabTitle">
1 <%#= link_to ae.name.to_s, "", :target => "_blank", :class => "homepageTabTitle fl ml5" %>
<%= link_to ae.name.to_s, student_work_index_url(:homework => ae.id, :tab => 2), :target => "_blank", :class => "homepageTabTitle fl ml5" %>
</li>
</th>
<th>
<li class="homepageTabProjectName ml5">
1 <%#= link_to uh.course.try(:name),"", :target => "_blank", :class => "homepageTabTitle ml5"%>
<%= link_to ae.course.try(:name),"", :target => "_blank", :class => "homepageTabTitle ml5"%>
<li>
</th>
<th>
<li class="homepageTabAuthor ml5" >
<%= 1111 %>
<%= homework_type_tip(ae.homework_type) %>
</li>
</th>
<th>
<li class="homepageTabTime ml5" >
1
<!-- <%# if uh.end_time > Time.now.to_i %>
<span class="c_red"><%#= (uh.end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%#= ((uh.end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%#= (((uh.end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分
<%# else %>
<% end_time = ae.end_time.to_time.to_i + 24*60*60 - 1 %>
<% if end_time > Time.now.to_i %>
<span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分
<% else %>
<span class="c_red">已截止</span>
<%# end %>-->
<% end %>
</li>
</th>
</tr>
<%# end %>
<% end %>
</tbody>
</table>
<ul class="pages" style="width: auto;display: table;margin-left: auto;margin-right: auto; padding-top: 10px">
<%#= pagination_links_full @unfinished_homework_pages, @unfinished_homeworks_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
<%= pagination_links_full @anonymous_evaluation_pages, @anonymous_evaluation_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
</div>
</div>

View File

@ -14,7 +14,7 @@
<tr>
<th>
<li class="homepageTabTitle">
<%= link_to uh.name.to_s, student_work_index_path( :homework => uh.id), :target => "_blank", :class => "homepageTabTitle fl ml5" %>
<%= link_to uh.name.to_s, student_work_index_path( :homework => uh.id, :tab => 1), :target => "_blank", :class => "homepageTabTitle fl ml5" %>
</li>
</th>
<th>
@ -29,10 +29,11 @@
</th>
<th>
<li class="homepageTabTime ml5" >
<% if uh.end_time > Time.now.to_i %>
<span class="c_red"><%= (uh.end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%= ((uh.end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((uh.end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分
<% end_time = uh.end_time.to_time.to_i + 24*60*60 - 1 %>
<% if end_time > Time.now.to_i %>
<span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分
<% else %>
<span class="c_red">已截止</span>
<% end %>

View File

@ -18,7 +18,7 @@
<th>
<li class="homepageTabProjectName ml5">
<% if up.polls_type == "Course" %>
<%= Course.find(up.polls_group_id).name %>
<%= link_to Course.find(up.polls_group_id).name, course_path(Course.find(up.polls_group_id)) %>
<% end %>
<li>
</th>

View File

@ -3,7 +3,7 @@
<table class="sy_new_table clear" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>作业标题</th>
<th>测验标题</th>
<th style="width:160px">来源</th>
<th style="width:80px">测验时长</th>
<th style="width:160px">截止剩余时间</th>
@ -14,7 +14,7 @@
<tr>
<th>
<li class="homepageTabTitle">
<%= link_to ut.exercise_name.to_s, "", :target => "_blank", :class => "homepageTabTitle fl ml5" %>
<%= link_to ut.exercise_name.to_s, exercise_index_path(:course_id => ut.course_id), :target => "_blank", :class => "homepageTabTitle fl ml5" %>
</li>
</th>
<th>
@ -24,7 +24,11 @@
</th>
<th>
<li class="homepageTabAuthor ml5" >
<% if ut.time.to_i == -1 %>
不限时
<% else %>
<%= ut.time %>
<% end %>
</li>
</th>
<th>
@ -43,7 +47,7 @@
</tbody>
</table>
<ul class="pages" style="width: auto;display: table;margin-left: auto;margin-right: auto; padding-top: 10px">
<%#= pagination_links_full @unfinished_homework_pages, @unfinished_homeworks_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
<%= pagination_links_full @unfinished_test_pages, @unfinished_test_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
</div>
</div>

View File

@ -20,7 +20,7 @@
</th>
<th>
<li class="homepageTabProjectName ml5">
<%= ui.project.try(:name) %>
<%= link_to ui.project.try(:name), project_path(ui.project_id) %>
<li>
</th>
<th>

View File

@ -109,8 +109,7 @@
<!--
<div id="show_more_activities" class="loadMore mt10 f_grey">点击展开更多<%#=link_to "", user_activities_path(@user.id,:type => type,:page => page),:id => "more_activities_link",:remote => "true",:class => "none" %></div>
-->
<%= link_to "点击展开更多", action == "project_community" ? user_project_community_path(@user.id, :type => type, :page => page) : user_course_community_path(@user.id, :type => type,:page => page),
:id => "show_more_activities", :remote => "true", :class => "loadMore mt10 f_grey" %>
<%= link_to "点击展开更多", user_activities_path(@user.id,:type => type,:page => page), :id => "show_more_activities", :remote => "true", :class => "loadMore mt10 f_grey"%>
<% end%>
<!--

View File

@ -9,3 +9,16 @@
<div class="resources">
<%= render :partial => 'users/new_user_message', :locals => { :message_alls => @message_alls } %>
</div>
<script>
$(function(){
$(".messageInformationContents").each(function(){
var parentWidth = $(this).parent().width();
var eq0Width = $(this).parent().children().eq(0).width();
var eq1Width = $(this).parent().children().eq(1).width();
var classWidth = parentWidth - eq0Width - eq1Width;
$(this).css("max-width",classWidth + "px");
});
//$(".messageInformationContents").width()
});
</script>

View File

@ -0,0 +1,14 @@
class DeleteCourseActivities < ActiveRecord::Migration
def up
course_acts = CourseActivity.where(:course_id => 844, :user_id => 10096, :course_act_id => 436, :course_act_type => 'Poll')
if course_acts.count > 1
course_acts.limit(course_acts.count - 1).each do |act|
act.delete
end
end
end
def down
end
end

View File

@ -26,10 +26,10 @@
</div>
</div>
<div class="course-list-row f13 c-grey3 mt10">
<span class="fl ml15 c-grey3">邮箱</span>
<input class="new-class-input ml25" type="email" name="email" ng-model="mail" placeholder="请输入您的邮箱地址" maxlength="60" />
</div>
<!--<div class="course-list-row f13 c-grey3 mt10">-->
<!--<span class="fl ml15 c-grey3">邮箱</span>-->
<!--<input class="new-class-input ml25" type="email" name="email" ng-model="mail" maxlength="60" disabled />-->
<!--</div>-->
<div ng-show="regFrm.$submitted || regFrm.email.$touched">
<span class="f12 c-red ml65" ng-show="regFrm.email.$error.required">电子邮箱地址不能为空</span>
<span class="f12 c-red ml65" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>

View File

@ -64,18 +64,13 @@ app.controller('EditUserInfoController', ['$scope', 'config','$http', 'auth','$l
return;
}
if(vm.mail == ""){
vm.alertService_1.showMessage('提示', '邮箱不能为空');
return;
}
// if(!(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.test(vm.mail))){
// vm.alertService_1.showMessage('提示', '邮箱不合法');
// return;
// }
$http.post(config.apiUrl + "users/edit_userinfo",
{token: auth.token(),lastname: vm.lastname, sex: vm.sex, mail: vm.mail}
{token: auth.token(),lastname: vm.lastname, sex: vm.sex}
).then(function(response){
if(response.data.status == 0)
{

View File

@ -95,7 +95,7 @@ div#menu ul ul ul li a{ width:185px; overflow:hidden; white-space: nowrap; text-
.homepageNewsList {width:710px; height:49px; line-height:49px; vertical-align:middle; border-bottom:1px dashed #eaeaea;}
.homepageNewsPortrait {width:40px; display:block; margin-top:7px;}
.homepageNewsPublisher { max-width:100px; font-size:12px; color:#269ac9; display:block; /*padding-left:5px;*/ overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; }
.homepageNewsType {padding-left: 5px; font-size:12px; color:#888888; display:block;}
.homepageNewsType {max-width: 200px; padding-left: 5px; font-size:12px; color:#888888; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
.homepageNewsTypeHomework {width:160px; padding-left: 5px; font-size:12px; color:#888888; display:block; overflow:hidden; height:49px;word-break:break-all; word-wrap:break-word; text-overflow:ellipsis;}
.homepageNewsPubType {auto-width:230px; font-size:12px; color:#888888; display: block;}
.homepageNewsPubTypeHomework {width:270px; font-size:12px; color:#888888; display: block; white-space:nowrap;}
@ -680,8 +680,8 @@ a.user_editinfo{border-top:1px solid #e5e5e5; height:30px; line-height:30px; tex
.messageMediumContents{ width:420px; max-width:450px; margin-right:10px; font-size:14px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.messageOperateContents {width:100px; max-width:125px; margin-left:10px; font-size:14px; color:red; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.messageApplyContents{ width:200px; max-width:250px; margin-right:10px; font-size:14px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.longMessageWidth { max-width: 610px; float:left; }
.shortMessageWidth { max-width: 540px; float:left; }
.longMessageWidth { width: 610px; float:left; }
.shortMessageWidth { width: 530px; float:left; }
.messageInformationContents{ margin-right:10px; font-size:14px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height:49px; float:left; }
.homepageBackground{ background-color:#90C5EC; flex:1; text-align: center }
.homepageClickBackground{ background-color:#3b94d6; flex:1; text-align: center }