diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 5c64ad332..82f92c2d1 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -27,7 +27,7 @@ class AccountController < ApplicationController if request.get? @login = params[:login] || true if User.current.logged? - redirect_to home_url + redirect_to user_path(User.current) else render :layout => 'login' end @@ -58,7 +58,7 @@ class AccountController < ApplicationController # Lets user choose a new password def lost_password - (redirect_to(home_url); return) unless Setting.lost_password? + (redirect_to(signin_path); return) unless Setting.lost_password? if params[:token] @token = Token.find_token("recovery", params[:token].to_s) if @token.nil? || @token.expired? @@ -110,7 +110,7 @@ class AccountController < ApplicationController # User self-registration def register - (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] + (redirect_to(signin_path); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @user = User.new(:language => current_language.to_s) @@ -187,11 +187,11 @@ class AccountController < ApplicationController # Token based account activation def activate - (redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present? + (redirect_to(signin_path); return) unless Setting.self_registration? && params[:token].present? token = Token.find_token('register', params[:token].to_s) - (redirect_to(home_url); return) unless token and !token.expired? + (redirect_to(signin_path); return) unless token and !token.expired? user = token.user - (redirect_to(home_url); return) unless user.registered? + (redirect_to(signin_path); return) unless user.registered? user.activate if user.save token.destroy @@ -278,7 +278,7 @@ class AccountController < ApplicationController user = User.find_or_initialize_by_identity_url(identity_url) if user.new_record? # Self-registration off - (redirect_to(home_url); return) unless Setting.self_registration? + (redirect_to(signin_path); return) unless Setting.self_registration? # Create on the fly user.login = registration['nickname'] unless registration['nickname'].nil? @@ -365,14 +365,15 @@ class AccountController < ApplicationController def invalid_credentials logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash.now[:error] = l(:notice_account_invalid_creditentials) - render :layout => 'login' + flash[:error] = l(:notice_account_invalid_creditentials) + # render :layout => 'login' + redirect_to signin_path(:login=>true) end def invalid_credentials_new logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash.now[:error] = l(:notice_account_invalid_creditentials_new) - render :layout => 'login' + flash[:error] = l(:notice_account_invalid_creditentials_new) + render signin_path(:login=>true) end # Register a user for email activation. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 10e5e6f06..1c233ed6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -557,12 +557,13 @@ class ApplicationController < ActionController::Base end def redirect_back_or_default(default, options={}) - back_url = params[:back_url].to_s + back_url = '' #params[:back_url].to_s if back_url.present? begin uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) + back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) redirect_to(back_url) return end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 4124472e1..9728ddf11 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -174,7 +174,7 @@ class MyController < ApplicationController logout_user flash.now[:notice] = l(:notice_account_deleted) end - redirect_to home_url + redirect_to signin_path end end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index e47cfc2ff..bedb2541f 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -207,7 +207,7 @@ class SoftapplicationsController < ApplicationController @softapplication.destroy respond_to do |format| - format.html { redirect_to home_url } + format.html { redirect_to signin_path } format.json { head :no_content } end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 555c67d13..0058e6e4c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -352,7 +352,7 @@ class UsersController < ApplicationController homework = HomeworkCommon.new homework.name = params[:homework_common][:name] homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] + homework.end_time = params[:homework_common][:end_time] || Time.now homework.publish_time = Time.now homework.homework_type = 1 homework.late_penalty = 2 @@ -627,14 +627,15 @@ class UsersController < ApplicationController end def show + @page = params[:page] ? params[:page].to_i + 1 : 0 - @type = params[:type] + user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" course_types = "('Message','News','HomeworkCommon','poll')" project_types = "('Message','Issue')" - if @type - case @type + if params[:type].present? + case params[:type] when "course_homework" @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page * 10) when "course_news" @@ -649,11 +650,12 @@ class UsersController < ApplicationController @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) - end + end else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) end # @user_activities = paginateHelper @user_activities,500 + @type = params[:type] respond_to do |format| format.js format.html {render :layout => 'new_base_user'} @@ -1004,6 +1006,12 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") end + elsif params[:type] == "5" #附件 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type ='Principal'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc") + end end @type = params[:type] || 1 @limit = 25 @@ -1060,6 +1068,12 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") end + elsif params[:type] == "5" #用户资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type ='Principal'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc") + end end @type = params[:type] @limit = 25 @@ -1464,6 +1478,12 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") end + elsif params[:type] == "5" #用户资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal'").order("created_on desc") + end end @type = params[:type] @limit = 25 @@ -1516,6 +1536,12 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") end + elsif params[:type] == "5" #用户资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + end end @type = params[:type] @limit = 25 diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6b14db9bb..809f78ddc 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -27,7 +27,8 @@ class WelcomeController < ApplicationController def index # 企业版定制: params[:project]为传过来的参数 - + redirect_to signin_path + return unless params[:organization].nil? @organization = Organization.find params[:organization] # @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all @@ -171,7 +172,7 @@ class WelcomeController < ApplicationController redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :student) else #redirect_to home_path, :alert => l(:label_sumbit_empty) - (redirect_to home_url, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? + (redirect_to signin_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? end } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 709426d41..7f93345b4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2493,4 +2493,14 @@ int main(int argc, char** argv){ return 0; }".html_safe end + + #判断用户是否已经提交了问卷 + def has_commit_poll?(poll_id,user_id) + pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id) + if pu.nil? + false + else + true + end + end end diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 22ee21936..84e12f3b1 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -47,7 +47,7 @@ module PollHelper true end end - + #统计答题百分比,统计结果保留两位小数 def statistics_result_percentage(e, t) e = e.to_f diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 1d0920c1c..284687870 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -10,7 +10,7 @@ class CourseActivity < ActiveRecord::Base #在个人动态里面增加当前动态 def add_user_activity - user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'").first if user_activity user_activity.save else @@ -24,7 +24,7 @@ class CourseActivity < ActiveRecord::Base end def destroy_user_activity - user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index b7fc5e4c2..9bc10bebf 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -25,7 +25,7 @@ class ForgeActivity < ActiveRecord::Base #在个人动态里面增加当前动态 def add_user_activity - user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'").first if user_activity user_activity.save else @@ -39,7 +39,7 @@ class ForgeActivity < ActiveRecord::Base end def destroy_user_activity - user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") user_activity.destroy_all end end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 8bdace544..56f2c5454 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -1,7 +1,7 @@ <%= stylesheet_link_tag 'new_user'%> <%= stylesheet_link_tag 'leftside'%> -
@@ -186,7 +206,7 @@ <%= back_url_hidden_field_tag %>
<%= text_field_tag 'username', params[:username], :tabindex => '1' , - :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称'%> + :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%>
<% if Setting.openid? %> @@ -196,7 +216,7 @@ <% end %>
- <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码'%> + <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%>
<% if Setting.autologin? %> diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index 864509546..70e943e99 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -5,7 +5,7 @@
<%= link_to image_tag(url_to_avatar(journal.user),:width => '46',:height => '46'), user_path(journal.user) %>
-
+
diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 75979d9f3..8c7a41ddc 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -50,7 +50,7 @@
  • 提交 - 取消 + <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
  • <% end%> diff --git a/app/views/homework_common/_new_homework_detail_manual_form.html.erb b/app/views/homework_common/_new_homework_detail_manual_form.html.erb new file mode 100644 index 000000000..88362976e --- /dev/null +++ b/app/views/homework_common/_new_homework_detail_manual_form.html.erb @@ -0,0 +1,74 @@ +
    +
    +
    +
    发布作业
    +
    +
    +
    + +
    +
    + 导入作业 + +
    + +
    +
    +
    +
    + <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor' %> + <% end %> +
    +
    + +
    + + +
    + 高级功能 +
    +
    +
    + +
    + 发布 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'fr mr10 mt3'%> +
    +
    +
    +
    + +
    + + + diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index e48864305..ace881194 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -19,7 +19,7 @@