Merge branch 'develop' into hjq_new_course

Conflicts:
	app/models/course_contributor_score.rb
	app/views/organizations/_org_course_homework.html.erb
	app/views/users/_homework_search_input.html.erb
	app/views/users/_show_user_homeworks.html.erb
	app/views/users/_user_homework_detail.html.erb
	app/views/users/_user_homework_form.html.erb
	app/views/users/user_homework_type.js.erb
	app/views/users/user_homeworks.html.erb
	app/views/users/user_homeworks.js.erb
This commit is contained in:
huang 2016-03-05 03:17:47 +08:00
commit 6ceb4f4549
37 changed files with 2058 additions and 1868 deletions

View File

@ -32,18 +32,20 @@ class AdminController < ApplicationController
end end
def projects def projects
=begin
@status = params[:status] || 1 @status = params[:status] || 1
scope = Project.status(@status).order('id asc') scope = Project.status(@status)
scope = scope.like(params[:name]) if params[:name].present? scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.where(project_type: Project::ProjectType_project).all @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all
=end
@projects = Project.like(@name).order('created_on desc')
render :action => "projects", :layout => false if request.xhr? render :action => "projects", :layout => false if request.xhr?
end end
def courses def courses
@name = params[:name] @name = params[:name]
@courses = Course.like(@name) @courses = Course.like(@name).order('created_at desc')
respond_to do |format| respond_to do |format|
format.html format.html
end end

View File

@ -422,11 +422,12 @@ class UsersController < ApplicationController
end end
def choose_user_course def choose_user_course
homework = HomeworkCommon.find params[:homework].to_i
if !params[:search].nil? if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} @course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
else else
@course = @user.courses.select { |course| @user.allowed_to?(:as_teacher,course)} @course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
end end
@search = params[:search] @search = params[:search]
#这里仅仅是传递需要发送的资源id #这里仅仅是传递需要发送的资源id
@ -531,7 +532,15 @@ class UsersController < ApplicationController
elsif params[:type] == "2" #我的题库 elsif params[:type] == "2" #我的题库
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
end end
if params[:property] && params[:property] == "1"
@homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
elsif params[:property] && params[:property] == "2"
@homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
elsif params[:property] && params[:property] == "3"
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
end
@type = params[:type] @type = params[:type]
@property = params[:property]
@limit = 15 @limit = 15
@is_remote = true @is_remote = true
@hw_count = @homeworks.count @hw_count = @homeworks.count
@ -559,10 +568,21 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("created_at desc")
elsif params[:type] == "2" #课程资源 elsif params[:type] == "2" #课程资源
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
end end
if params[:property] && params[:property] == "1"
@homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
elsif params[:property] && params[:property] == "2"
@homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
elsif params[:property] && params[:property] == "3"
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
end
@type = params[:type] @type = params[:type]
@limit = 15 @limit = 15
@is_remote = true @is_remote = true
@ -1518,9 +1538,20 @@ class UsersController < ApplicationController
#@user.save_attachments(params[:attachments],User.current) #@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal # Container_type为Principal
Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2
@attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids)
elsif params[:status] == "4"
@attachments = get_attch_resources params[:id]
elsif params[:status] == "5"
@attachments = get_principal_resources params[:id]
else
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids)
end
elsif params[:type] == "2" # 课程资源 elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:type] == "3" # 项目资源 elsif params[:type] == "3" # 项目资源
@ -1530,10 +1561,21 @@ class UsersController < ApplicationController
elsif params[:type] == "5" #用户资源 elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id] @attachments = get_principal_resources params[:id]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids)
elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids)
elsif params[:status] == "4"
@attachments = get_attch_resources_public
elsif params[:status] == "5"
@attachments = get_principal_resources_public
else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids)
end end
@type = params[:type] || 1 end
@status = params[:status]
@type = params[:type]
@limit = 25 @limit = 25
@is_remote = true @is_remote = true
@atta_count = @attachments.count @atta_count = @attachments.count
@ -1558,9 +1600,20 @@ class UsersController < ApplicationController
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2
@attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids)
elsif params[:status] == "4"
@attachments = get_attch_resources params[:id]
elsif params[:status] == "5"
@attachments = get_principal_resources params[:id]
else
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids)
end
elsif params[:type] == "2" # 课程资源 elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:type] == "3" # 项目资源 elsif params[:type] == "3" # 项目资源
@ -1570,9 +1623,20 @@ class UsersController < ApplicationController
elsif params[:type] == "5" #用户资源 elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id] @attachments = get_principal_resources params[:id]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids)
elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids)
elsif params[:status] == "4"
@attachments = get_attch_resources_public
elsif params[:status] == "5"
@attachments = get_principal_resources_public
else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids)
end end
end
@status = params[:status]
@type = params[:type] @type = params[:type]
@limit = 25 @limit = 25
@is_remote = true @is_remote = true
@ -2320,7 +2384,7 @@ class UsersController < ApplicationController
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2 if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids) @attachments = get_project_resources(params[:id], user_project_ids)

View File

@ -661,4 +661,16 @@ module UsersHelper
type type
end end
#根据姓名搜索用户
def search_user_by_name user_ids, name
result_ids = []
user_ids.each do |user_id|
user = User.find user_id
username = user.lastname.to_s.downcase + user.firstname.to_s.downcase
if username.include?(name)
result_ids << user_id
end
end
result_ids
end
end end

View File

@ -45,8 +45,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% project_tree(@projects) do |project, level| %> <% @projects.each do |project| %>
<tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> <tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;"> <td style="text-align: center;">
<%= project.id %> <%= project.id %>
</td> </td>

View File

@ -22,7 +22,7 @@
<div class="homepageRight mt0 ml10"> <div class="homepageRight mt0 ml10">
<div class="homepageRightBanner"> <div class="homepageRightBanner">
<div class="NewsBannerName"> <div class="NewsBannerName">
课程讨论 课程问答
</div> </div>
</div> </div>
<% if User.current.logged? %> <% if User.current.logged? %>

View File

@ -24,7 +24,7 @@
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> <% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f12 c_blue02 ml10 fn" %> <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f12 c_blue02 ml10 fn" %>
<%= 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 %> <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") %>
</div> </div>
<% end %> <% end %>
<% if show_nav?(course_feedback_count) %> <% if show_nav?(course_feedback_count) %>

View File

@ -7,7 +7,7 @@
<% homework_num = @course.homework_commons.where("publish_time <= '#{Date.today}'").count %> <% homework_num = @course.homework_commons.where("publish_time <= '#{Date.today}'").count %>
<% end %> <% end %>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en" xmlns="http://www.w3.org/1999/html">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title> <title>
@ -104,7 +104,7 @@
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %> <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
<%= link_to "(#{@course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %> <%= link_to "(#{@course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
<%= 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 %> <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") %>
</div> </div>
<% end %> <% end %>
<% unless show_nav?(course_feedback_count) %> <% unless show_nav?(course_feedback_count) %>
@ -142,32 +142,55 @@
<div class="cl"></div> <div class="cl"></div>
<% unless contributor_course_scor(@course.id).count == 0 %> <% unless contributor_course_scor(@course.id).count == 0 %>
<ul class="rankList"> <ul class="rankList">
<h4>课程活跃度</h4> <h4>课程活跃度<a style="float: right; color: #7f7f7f; font-size: 12px;" onmouseover ="message_titile_show2($(this),event)" onmouseout ="message_titile_hide2($(this))">积分规则</a></h4>
<div style="display: none" class="numIntro">
<div style="padding-left: 35px; font-size: 14px;color: #3b3b3b">积分规则</div>
资源得分:资源数 x 5 </br>
发帖得分:发帖数 x 2 </br>
回帖得分:回复数 x 1 </br>
课程留言得分:留言数 x 1 </br>
作业留言得分:留言数 x 1 </br>
通知得分:通知数 x 1 </br>
总得分为以上得分之和
</div>
<% contributor_course_scor(@course.id).each do |contributor_score| %> <% contributor_course_scor(@course.id).each do |contributor_score| %>
<% unless contributor_score.total_score ==0 %> <% unless contributor_score.total_score ==0 %>
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a> <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a>
<p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p> <p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p>
<p><span class="c_green" style="cursor:pointer"> <p><span class="c_green" style="cursor:pointer">
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p> <a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green">
<%=total_score = contributor_score.resource_num.to_i * 5 + contributor_score.message_num.to_i * 2 +
contributor_score.message_reply_num.to_i * 1 + contributor_score.journal_num.to_i * 1 +
+ contributor_score.homework_journal_num * 1 + contributor_score.news_reply_num.to_i * 1 %></a></span></p>
<div style="display: none" class="numIntro"> <div style="display: none" class="numIntro">
<% unless contributor_score.resource_num == 0 %> <!--<div style="display: none" class="message_title_red system_message_style">-->
课程资源:<%= contributor_score.resource_num %><br /> <!--<p><strong>评论对象:</strong><%#= ma.course_message.commented.title %></p>-->
<% end %> <!--<%# unless ma.course_message.comments.nil? %>-->
<% unless contributor_score.message_num == 0 %> <!--<div class="fl"><strong>评论内容:</strong></div>-->
课程讨论:<%= contributor_score.message_num %><br /> <!--<div class="ml60"><%#= ma.course_message.comments.html_safe %></div>-->
<% end %> <!--<%# end %>-->
<% unless contributor_score.message_reply_num == 0 %> <!--</div>-->
评论回复:<%= contributor_score.message_reply_num %><br /> <div style="padding-left: 65px; font-size: 14px;color: #3b3b3b">积分计算</div>
<% end %> <%# unless contributor_score.resource_num.to_i == 0 %>
<% unless contributor_score.journal_num == 0 %> 课程资源:资源数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %></br>
课程留言:<%= contributor_score.journal_num %><br /> <%# end %>
<% end %> <%# unless contributor_score.message_num.to_i == 0 %>
<% unless contributor_score.homework_journal_num == 0 %> 课程讨论:发帖数 x 2 = <%= contributor_score.message_num.to_i %> x 2 = <%= contributor_score.message_num.to_i * 2 %></br>
作业留言:<%= contributor_score.homework_journal_num %><br /> <%# end %>
<% end %> <%# unless contributor_score.message_reply_num.to_i == 0 %>
<% unless contributor_score.news_reply_num == 0 %> 评论回复:回复数 x 1 = <%= contributor_score.message_reply_num.to_i %> x 1 = <%= contributor_score.message_reply_num.to_i %></br>
课程通知:<%= contributor_score.news_reply_num %><br /> <%# end %>
<% end %> <%# unless contributor_score.journal_num.to_i == 0 %>
课程留言:留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %></br>
<%# end %>
<%# unless contributor_score.homework_journal_num.to_i == 0 %>
作业留言:留言数 x 1 = <%= contributor_score.homework_journal_num.to_i %> x 1 = <%= contributor_score.homework_journal_num.to_i %></br>
<%# end %>
<%# unless contributor_score.news_reply_num.to_i == 0 %>
课程通知:通知数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %></br>
<%# end %>
总得分:<%=total_score %>
</div> </div>
</li> </li>
<% end %> <% end %>
@ -179,12 +202,12 @@
<% hero_homework_scores = hero_homework_score(@course, "desc") %> <% hero_homework_scores = hero_homework_score(@course, "desc") %>
<% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %> <% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %>
<ul class="rankList"> <ul class="rankList">
<h4>课程英雄榜</h4> <h4><span>课程英雄榜</span><a style="float: right; color: #7f7f7f; font-size: 12px;" title="英雄榜的得分是每个同学作业的得分总和">积分规则</a></h4>
<% hero_homework_scores.each do |student_score| %> <% hero_homework_scores.each do |student_score| %>
<% if student_score.score.to_i != 0 %> <% if student_score.score.to_i != 0 %>
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a> <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a>
<p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p> <p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p>
<p><span class="c_red" style="cursor:pointer" title="作业总分:<%= format("%.1f",student_score.score<0 ? 0 : student_score.score) %>"><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p> <p><span class="c_red" style="cursor:pointer" title="英雄榜的得分是每个同学作业的得分总和"><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p>
</li> </li>
<% end %> <% end %>
<% end %> <% end %>
@ -303,6 +326,16 @@
obj.parent().parent().next("div").hide(); obj.parent().parent().next("div").hide();
} }
function message_titile_show2(obj,e)
{
obj.parent().next("div").show();
obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute");
}
function message_titile_hide2(obj)
{
obj.parent().next("div").hide();
}
$("#expand_tools_expand").click(function(){ $("#expand_tools_expand").click(function(){
$("#navContentCourse").toggle(); $("#navContentCourse").toggle();
}); });

View File

@ -128,7 +128,7 @@
<div class="cl"></div> <div class="cl"></div>
<% if activity.student_works.count != 0 %> <% if activity.student_works.count != 0 %>
<% sw = activity.student_works.reorder("created_at desc").first %> <% sw = activity.student_works.reorder("created_at desc").first %>
<div class="mt10 homepagePostDeadline"> <div class="mt10 homepagePostDeadline mb10">
#&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 #&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
</div> </div>
<% end %> <% end %>
@ -139,12 +139,19 @@
<%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
<% unless student_work_scores.empty? %> <% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %> <% last_score = student_work_scores.first %>
<div class="mt10"> <div>
<p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %> <p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %>
<%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行: <%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:
</p> </p>
<% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> </div>
<% end %>
<div>
<% if activity.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% end %>
<% student_works.each_with_index do |sw, i| %> <% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
@ -163,7 +170,6 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% end %>
<% end %>
<div class="cl"></div> <div class="cl"></div>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %>
<% projects = activity.student_work_projects.where("is_leader = 1") %> <% projects = activity.student_work_projects.where("is_leader = 1") %>
@ -239,7 +245,8 @@
<% end %> <% end %>
<% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
<li> <li>
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink",
:title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>

View File

@ -12,7 +12,7 @@
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
</div> </div>
<div class="homepagePostTitle hidden m_w530 fl"> <div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> <% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->

View File

@ -41,12 +41,12 @@
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %> <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %>
<% end %> <% end %>
<div> <div>
<input type="text" name="student_work[name]" id="student_work_name" placeholder="请简洁的概括作品的功能或特性" class="InputBox W700" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>"> <input type="text" name="student_work[name]" id="student_work_name" placeholder="请输入作品名称" class="InputBox W700" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_name_span" class="c_red mb10"></p> <p id="student_work_name_span" class="c_red mb10"></p>
</div> </div>
<div class="mt10"> <div class="mt10">
<textarea name="student_work[description]" id="student_work_description" placeholder="请介绍你的作品" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea> <textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<script> <script>
var text = document.getElementById("student_work_description"); var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用 autoTextarea(text);// 调用

View File

@ -127,12 +127,12 @@
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
<% end %> <% end %>
<div> <div>
<%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %> <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称", :onkeyup => "regexStudentWorkName();" %>
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_name_span" class="c_red mb10"></p> <p id="student_work_name_span" class="c_red mb10"></p>
</div> </div>
<div class="mt10"> <div class="mt10">
<%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%> <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
<script> <script>
var text = document.getElementById("student_work_description"); var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用 autoTextarea(text);// 调用

View File

@ -128,7 +128,7 @@
<div class="cl"></div> <div class="cl"></div>
<% if activity.student_works.count != 0 %> <% if activity.student_works.count != 0 %>
<% sw = activity.student_works.reorder("created_at desc").first %> <% sw = activity.student_works.reorder("created_at desc").first %>
<div class="mt10 homepagePostDeadline"> <div class="mt10 homepagePostDeadline mb10">
#&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 #&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
</div> </div>
<% end %> <% end %>
@ -138,12 +138,19 @@
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% unless student_work_scores.empty? %> <% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %> <% last_score = student_work_scores.first %>
<div class="mt10"> <div>
<p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %> <p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %>
<%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行: <%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:
</p> </p>
<% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> </div>
<% end %>
<div>
<% if activity.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% end %>
<% student_works.each_with_index do |sw, i| %> <% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
@ -162,7 +169,6 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% end %>
<% end %>
<div class="cl"></div> <div class="cl"></div>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %>
<% projects = activity.student_work_projects.where("is_leader = 1") %> <% projects = activity.student_work_projects.where("is_leader = 1") %>
@ -238,7 +244,8 @@
<% end %> <% end %>
<% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
<li> <li>
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink",
:title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>

View File

@ -20,7 +20,7 @@
<% end %> <% end %>
<% end %> <% end %>
TO TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
</div> </div>
<div class="homepagePostTitle hidden m_w530 fl"> <div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> <% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->

View File

@ -0,0 +1,12 @@
<div id="popbox02">
<div class="ni_con">
<p style="display: block;font-size: 14px;margin-left: 30px;margin-top: 20px;">
题目已发送到目标课程的作业列表,但需要您设置发布和截止时间,以激活相应作业,谢谢!
</p>
<div class="ni_btn">
<a href="javascript:void(0)" class="tijiao c_white ml45" onclick="hideModal();">
确&nbsp;&nbsp;定
</a>
</div>
</div>
</div>

View File

@ -0,0 +1,29 @@
<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" />
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;
function search_hws(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'users', :action => 'user_search_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>&is_import=<%=is_import %>&property=<%=property %>',
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='search']").on('input', function (e) {
throttle(search_hws,window,e);
});
</script>

View File

@ -1,4 +1,4 @@
<input type="text" name="search" placeholder="输入关键词进行搜索" class="subject-pop-search fr" /> <input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" />
<script type="text/javascript"> <script type="text/javascript">
var lastSearchCondition = ''; var lastSearchCondition = '';
var count = 0; var count = 0;

View File

@ -25,3 +25,350 @@
<div class="cl"></div> <div class="cl"></div>
<% end %> <% end %>
<% end %> <% end %>
<script>
var pageX = 0;
var pageY = 0;
//当前选中的行
var line;
//已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line
var last_line;
//资源名称
var res_name;
//资源名称的链接
var res_link;
var id; //资源id
var sendType = '1'; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型
$("#resources_list").mousedown(function(e) {
//如果是右键的话
if (3 == e.which) {
if( $("#res_name").length != 0 || $("#ajax-indicator").is(":hidden") == false){ //其他ajax在执行的时候阻止操作
e.preventDefault();
return ;
}
document.oncontextmenu = function() {return false;}
pageX = e.clientX;
pageY = e.clientY;
$("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY
+ "px; left:"
+ pageX
+ "px; width: 80px;");
$("#contextMenu").show();
//当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象
line = $(ele).parent();
//如果上一条存在被选中,那么将上一条的背景色改为白色
if(last_line != null){
last_line.children().css("background-color", 'white');
restore();
last_line == null;
}
//如果当前的tag是li那么还要li的父级元素
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
//将当前的元素的所有子元素的背景色改为蓝色
line.children().css("background-color", '#e1e1e1');
//将当前元素赋给 上一个对象 保存起来。
last_line = line;
}
});
//元素包含关系计算
var contains = function(root, el) {
if (root.compareDocumentPosition)
return root === el || !!(root.compareDocumentPosition(el) & 16);
if (root.contains && el.nodeType === 1){
return root.contains(el) && root !== el;
}
while ((el = el.parentNode))
if (el === root) return true;
return false;
}
$(document.body).click(function(e) {
//在列表上的任何单击事件都要恢复原来的样子
//隐藏右键菜单
//e.preventDefault();
$("#contextMenu").hide();
if( $("#ajax-indicator").is(":hidden") == false && $("#res_name").length != 0 ){ //其他ajax在执行的时候或者res_name仍然存在阻止操作
return ;
}
document.oncontextmenu = function() {return true;}
//如果当前行为空,那么要将当前行的拿到
var ele;
if(line == null){
ele = document.elementFromPoint(e.clientX, e.clientY);
line = $(ele).parent();
//如果是在li上点击事件那么要获得父组件
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
}
//如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了
if( contains($("#resources_list").get(0),line.get(0))){
line.children().css("background-color", 'white');
}
//当前行恢复编辑状态到链接状态
if(ele && ele.nodeName != 'INPUT') {
restore();
}
line = null;
});
//只要有一个选中了就是true
function checkboxSelected(){
selected = false;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == true){
selected = true;
}
});
return selected;
}
//只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
}
$("#res_count").html(getCheckBoxSeletedCount());
}
//获取当前checkbox选中的数目
function getCheckBoxSeletedCount(){
var i = 0;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
i ++;
}
});
return i;
}
//全选反选
function all_select(){
if($("#checkboxAll").attr('checked')){
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',true);
});
$("#res_count").html(getCheckBoxSeletedCount());
}else{
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',false);
});
$("#res_count").html(0);
}
}
function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>User.current.id,:type=>@type,:status=>@status})%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
}
//批量删除
function batch_delete(){
var data = $("#resources_list_form").serialize();
if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){
alert("您只能删除没有历史记录的资源,请重新选择后再删除。");
return;
}
if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){
alert("您只能删除自己上传的资源,请重新选择后再删除。");
return;
}
if(data != "" && confirm('确认要删除这些资源吗?')) {
$.post(
'<%= user_resource_delete_user_path(User.current.id,:type=>@type,:status=>@status)%>',
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
function (data) {
}
);
}
}
function show_send_(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(User.current.id)%>' + '?send_id=' + id,
data:{send_type:'file'}
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(User.current.id)%>' + '?send_id=' + id,
data:{send_type:'file'}
});
}
}
function batch_send(){
if($("#resources_list_form").serialize() == ""){
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(User.current.id)%>' + '?' + $("#resources_list_form").serialize(),
data:{send_type:'file'}
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(User.current.id)%>' + '?'+ $("#resources_list_form").serialize(),
data:{send_type:'file'}
});
}
}
function preview(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
$.ajax({
type:'get',
url:'<%= resource_preview_user_path(User.current.id)%>'+"?resource_id="+id
});
}
function rename(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id %>') {
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html(
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
' onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' +
'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>');
$("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{
alert('您无法修改此资源!')
}
}
String.prototype.trim = function() {
var str = this,
str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
//恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
function restore(){
//上一行不为空 且链接不为空
if( last_line != null && res_link != null && res_link != '') {
name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ;
if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态
return;
}
if( name && name != res_name.trim()){
if(confirm('确定修改为 '+name)){
$.ajax({
url: '<%=rename_resource_user_path(User.current.id) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(),
type:'get',
success:function (data)
{
if (data != 'fail' && name != undefined && name != 'undefined') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title', name);
last_line.children().eq(1).children().attr('href', data);
last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name);
} else {
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
}
} );
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空
}
}else {
last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空
}
}
}
function delete_file() {
$("#contextMenu").hide();
document.oncontextmenu = function () {
return true;
}
line.children().css("background-color", 'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(line.children().first().children().data('hasHistory') == 'Y'){
alert('该资源存在历史版本,不能删除');
return;
}
if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({
type: 'post',
url: '<%= user_resource_delete_user_path(User.current.id)%>' + '?resource_id=' + id + '&type=<%=@type %>&status=<%=@status %>'
});
}
}else{
alert('您无法删除此资源!')
}
}
</script>

View File

@ -6,7 +6,7 @@
<span title="<%= homework.name%>"><%= homework.name%></span> <span title="<%= homework.name%>"><%= homework.name%></span>
</label> </label>
</li> </li>
<li class="subject-pop-from fl hidden">攻城狮</li> <li class="subject-pop-from fl hidden"><span title="<%=homework.course.name %>(<%=current_time_and_term(homework.course) %>)"><%=homework.course.name %>(<%=current_time_and_term_short(homework.course) %>)</span></li>
<li class="subject-pop-type fl"> <li class="subject-pop-type fl">
<% case homework.homework_type %> <% case homework.homework_type %>
<% when 1 %> <% when 1 %>

View File

@ -1,8 +1,8 @@
<div class="w985"> <a href="javascript:void(0);" class="popup-close" onclick="hideModal()"></a> <div class="w985"> <a href="javascript:void(0);" class="popup-close" onclick="hideModal()"></a>
<div class="f16 fb fontBlue mb10">选用题库中的题目</div> <div class="f16 fb fontBlue mb10">选用题库中的题目</div>
<div class="subject-list fl mr10"> <div class="subject-list fl mr10">
<a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="subjectChoose chooseActive fl" data-remote="true">公共题库</a> <a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="resource-tab resource-tab-active fl" data-remote="true">公共题库</a>
<a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="subjectChoose fl" data-remote="true">我的题库</a> <a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="resource-tab fl" data-remote="true">我的题库</a>
<div id="homework_search_input"> <div id="homework_search_input">
<%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 1} %> <%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 1} %>
</div> </div>
@ -43,11 +43,11 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$("#public_homeworks_choose").click(function(){ $("#public_homeworks_choose").click(function(){
$(this).toggleClass("choose-active"); $(this).toggleClass("resource-tab-active");
$("#user_homeworks_choose").toggleClass("choose-active"); $("#user_homeworks_choose").toggleClass("resource-tab-active");
}); });
$("#user_homeworks_choose").click(function(){ $("#user_homeworks_choose").click(function(){
$(this).toggleClass("choose-active"); $(this).toggleClass("resource-tab-active");
$("#public_homeworks_choose").toggleClass("choose-active"); $("#public_homeworks_choose").toggleClass("resource-tab-active");
}); });
</script> </script>

View File

@ -2,7 +2,7 @@
<span class="uploadDialogText">上传资源 </span> <span class="uploadDialogText">上传资源 </span>
<!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>--> <!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>-->
<div class="uploadBoxContainer"> <div class="uploadBoxContainer">
<%= form_tag(user_resource_create_user_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> <%= form_tag(user_resource_create_user_path(:type=>type,:status=>status), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
<div> <div>
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html"> <span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
<% if defined?(container) && container && container.saved_attachments %> <% if defined?(container) && container && container.saved_attachments %>
@ -38,7 +38,7 @@
</div> </div>
<div class="uploadResourceIntr"> <div class="uploadResourceIntr">
<div class="uploadResourceName"><span id="upload_file_count">(未选择文件)</span></div> <div class="uploadResourceName"><span id="upload_file_count">(未选择文件)</span></div>
<div class="uploadResourceIntr2">您可以上传小于<span class="c_red">50MB</span>的文件</div> <div class="uploadResourceIntr2"><!--您可以上传小于<span class="c_red">50MB</span>的文件--></div>
</div> </div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

View File

@ -131,7 +131,7 @@
<div class="cl"></div> <div class="cl"></div>
<% if homework_common.student_works.count != 0 %> <% if homework_common.student_works.count != 0 %>
<% sw = homework_common.student_works.reorder("created_at desc").first %> <% sw = homework_common.student_works.reorder("created_at desc").first %>
<div class="mt10 homepagePostDeadline"> <div class="mt10 homepagePostDeadline mb10">
#&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 #&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
</div> </div>
<% end %> <% end %>
@ -142,12 +142,19 @@
<%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
<% unless student_work_scores.empty? %> <% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %> <% last_score = student_work_scores.first %>
<div class="mt10"> <div>
<p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %> <p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %>
<%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行: <%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:
</p> </p>
<% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> </div>
<% end %>
<div>
<% if homework_common.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% end %>
<% student_works.each_with_index do |sw, i| %> <% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %> <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %>
@ -166,7 +173,6 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% end %>
<% end %>
<% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %> <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %>
<% projects = homework_common.student_work_projects.where("is_leader = 1") %> <% projects = homework_common.student_work_projects.where("is_leader = 1") %>
@ -244,7 +250,8 @@
<% end %> <% end %>
<% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
<li> <li>
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink",
:title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %> <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %>

View File

@ -185,7 +185,7 @@
<div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>"> <div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>">
<div class="mt10"> <div class="mt10">
<% if edit_mode %> <% if edit_mode %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description.html_safe %></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description %></textarea>
<%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %> <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
<% else %> <% else %>
<%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %>

View File

@ -1 +1,9 @@
$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>); $("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>);
$("#ajax-modal").html("<%=escape_javascript(render :partial => 'homework_post_notice') %>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","50%").css("left","50%");
$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -7,5 +7,9 @@ $("#homework_search_input").html("<%=escape_javascript(render :partial=>'homewor
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); $("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>"); $("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
$("#homework_type_all").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>');
$("#homework_type_nor").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>');
$("#homework_type_pro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>');
$("#homework_type_gro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>');
<% end %> <% end %>

View File

@ -20,10 +20,11 @@
if(check.length == 0) { if(check.length == 0) {
$("#choose_homework_notice").text("请先选择一个作业"); $("#choose_homework_notice").text("请先选择一个作业");
} else { } else {
var hw_id = $('input[name="checkMenu"]:checked').val();
$("#choose_homework_notice").text(""); $("#choose_homework_notice").text("");
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '/users/' + user_id + '/choose_user_course', url: '/users/' + user_id + '/choose_user_course?homework='+hw_id,
data:{send_id:$('input[name="checkMenu"]:checked').val()} data:{send_id:$('input[name="checkMenu"]:checked').val()}
}); });
} }
@ -45,10 +46,10 @@
<ul class="resourcesSelect"> <ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a> <li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType"> <ul class="resourcesType">
<li> <a href="/users/8523/user_resource?type=1" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li> <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>" id="homework_type_all" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li>
<li> <a href="/users/8523/user_resource?type=2" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li> <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>" id="homework_type_nor" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li>
<li> <a href="/users/8523/user_resource?type=3" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li> <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>" id="homework_type_pro" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li>
<li> <a href="/users/8523/user_resource?type=5" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li> <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>" id="homework_type_gro" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -57,7 +58,7 @@
</ul> </ul>
<div class="cl"></div> <div class="cl"></div>
<div id="homework_search_input" class="mt10 fl"> <div id="homework_search_input" class="mt10 fl">
<%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 0} %> <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
</div> </div>
<!--<form class="resourcesSearchloadBox mt10"> <!--<form class="resourcesSearchloadBox mt10">
<input type="text" name="serach" placeholder="输入题库关键词进行搜索" class="searchResource" /> <input type="text" name="serach" placeholder="输入题库关键词进行搜索" class="searchResource" />

View File

@ -1,5 +1,3 @@
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); $("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
/*$("#user_show_more_homework").replaceWith("<%#= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");*/

View File

@ -21,16 +21,6 @@
$("#resource_search_form").submit(); $("#resource_search_form").submit();
} }
function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>@user})%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
}
function show_public_resource(){ function show_public_resource(){
$("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 6}) %>'); $("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 6}) %>');
} }
@ -115,340 +105,5 @@
<div class="cl"></div> <div class="cl"></div>
<script>
var pageX = 0;
var pageY = 0;
//当前选中的行
var line;
//已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line
var last_line;
//资源名称
var res_name;
//资源名称的链接
var res_link;
var id; //资源id
var sendType = '1'; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型
$("#resources_list").mousedown(function(e) {
//如果是右键的话
if (3 == e.which) {
if( $("#res_name").length != 0 || $("#ajax-indicator").is(":hidden") == false){ //其他ajax在执行的时候阻止操作
e.preventDefault();
return ;
}
document.oncontextmenu = function() {return false;}
pageX = e.clientX;
pageY = e.clientY;
$("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY
+ "px; left:"
+ pageX
+ "px; width: 80px;");
$("#contextMenu").show();
//当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象
line = $(ele).parent();
//如果上一条存在被选中,那么将上一条的背景色改为白色
if(last_line != null){
last_line.children().css("background-color", 'white');
restore();
last_line == null;
}
//如果当前的tag是li那么还要li的父级元素
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
//将当前的元素的所有子元素的背景色改为蓝色
line.children().css("background-color", '#e1e1e1');
//将当前元素赋给 上一个对象 保存起来。
last_line = line;
}
});
//元素包含关系计算
var contains = function(root, el) {
if (root.compareDocumentPosition)
return root === el || !!(root.compareDocumentPosition(el) & 16);
if (root.contains && el.nodeType === 1){
return root.contains(el) && root !== el;
}
while ((el = el.parentNode))
if (el === root) return true;
return false;
}
$(document.body).click(function(e) {
//在列表上的任何单击事件都要恢复原来的样子
//隐藏右键菜单
//e.preventDefault();
$("#contextMenu").hide();
if( $("#ajax-indicator").is(":hidden") == false && $("#res_name").length != 0 ){ //其他ajax在执行的时候或者res_name仍然存在阻止操作
return ;
}
document.oncontextmenu = function() {return true;}
//如果当前行为空,那么要将当前行的拿到
var ele;
if(line == null){
ele = document.elementFromPoint(e.clientX, e.clientY);
line = $(ele).parent();
//如果是在li上点击事件那么要获得父组件
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
}
//如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了
if( contains($("#resources_list").get(0),line.get(0))){
line.children().css("background-color", 'white');
}
//当前行恢复编辑状态到链接状态
if(ele && ele.nodeName != 'INPUT') {
restore();
}
line = null;
});
//只要有一个选中了就是true
function checkboxSelected(){
selected = false;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == true){
selected = true;
}
});
return selected;
}
//只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
}
$("#res_count").html(getCheckBoxSeletedCount());
}
//获取当前checkbox选中的数目
function getCheckBoxSeletedCount(){
var i = 0;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
i ++;
}
});
return i;
}
//全选反选
function all_select(){
if($("#checkboxAll").attr('checked')){
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',true);
});
$("#res_count").html(getCheckBoxSeletedCount());
}else{
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',false);
});
$("#res_count").html(0);
}
}
//批量删除
function batch_delete(){
var data = $("#resources_list_form").serialize();
if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){
alert("您只能删除没有历史记录的资源,请重新选择后再删除。");
return;
}
if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){
alert("您只能删除自己上传的资源,请重新选择后再删除。");
return;
}
if(data != "" && confirm('确认要删除这些资源吗?')) {
$.post(
'<%= user_resource_delete_user_path(@user)%>',
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
function (data) {
}
);
}
}
function show_send_(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id,
data:{send_type:'file'}
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id,
data:{send_type:'file'}
});
}
}
function batch_send(){
if($("#resources_list_form").serialize() == ""){
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize(),
data:{send_type:'file'}
});
}else{
$.ajax({
type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize(),
data:{send_type:'file'}
});
}
}
function preview(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
$.ajax({
type:'get',
url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id
});
}
function rename(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id %>') {
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html(
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
' onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' +
'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>');
$("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{
alert('您无法修改此资源!')
}
}
String.prototype.trim = function() {
var str = this,
str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
//恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
function restore(){
//上一行不为空 且链接不为空
if( last_line != null && res_link != null && res_link != '') {
name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ;
if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态
return;
}
if( name && name != res_name.trim()){
if(confirm('确定修改为 '+name)){
$.ajax({
url: '<%=rename_resource_user_path(@user) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(),
type:'get',
success:function (data)
{
if (data != 'fail' && name != undefined && name != 'undefined') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title', name);
last_line.children().eq(1).children().attr('href', data);
last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name);
} else {
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
}
} );
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空
}
}else {
last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空
}
}
}
function delete_file() {
$("#contextMenu").hide();
document.oncontextmenu = function () {
return true;
}
line.children().css("background-color", 'white');
id = line.children().last().html();
user_id = line.children().eq(5).html();
if(line.children().first().children().data('hasHistory') == 'Y'){
alert('该资源存在历史版本,不能删除');
return;
}
if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({
type: 'post',
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val()
});
}
}else{
alert('您无法删除此资源!')
}
}
</script>

View File

@ -15,7 +15,7 @@ zh:
label_course_new: 新建课程 label_course_new: 新建课程
label_course_name: 课程名称 label_course_name: 课程名称
label_homework: 课程作业 label_homework: 作业
label_course_news: 课程通知 label_course_news: 课程通知
label_course_mail_news_reply: 课程通知回复 label_course_mail_news_reply: 课程通知回复
label_main_teacher: 主讲教师 label_main_teacher: 主讲教师

View File

@ -614,7 +614,7 @@ zh:
label_homework_info: 提交情况 #huang label_homework_info: 提交情况 #huang
label_course_news_description: '课程必须是高校正式开设的课程,或是围绕特定主题定期发布课程资料的公共开放课程;<br/>如果您想创建一个协作研究空间,请您前往“我的项目”页面创建项目,谢谢!' label_course_news_description: '课程必须是高校正式开设的课程,或是围绕特定主题定期发布课程资料的公共开放课程;<br/>如果您想创建一个协作研究空间,请您前往“我的项目”页面创建项目,谢谢!'
label_course_board: 讨论 label_course_board: 问答
label_version: 版本 label_version: 版本
label_version_new: 新建版本 label_version_new: 新建版本
@ -1731,7 +1731,7 @@ zh:
label_newbie_faq: '新手指引 & 问答' label_newbie_faq: '新手指引 & 问答'
label_hot_project: '热门项目' label_hot_project: '热门项目'
label_borad_project: 项目讨论区 label_borad_project: 项目讨论区
label_borad_course: 课程讨论 label_borad_course: 课程问答
label_borad_org_subfield: 资源栏目讨论区 label_borad_org_subfield: 资源栏目讨论区
view_borad_course: 课程讨论 view_borad_course: 课程讨论
label_memo_create_succ: 发布成功 label_memo_create_succ: 发布成功

View File

@ -99,8 +99,6 @@ ActiveRecord::Schema.define(:version => 20160304154643) do
t.integer "quotes" t.integer "quotes"
t.integer "version" t.integer "version"
t.integer "attachment_id" t.integer "attachment_id"
t.integer "is_publish", :default => 1
t.date "publish_time"
end end
create_table "attachments", :force => true do |t| create_table "attachments", :force => true do |t|
@ -1280,6 +1278,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do
t.text "description" t.text "description"
t.integer "creator_id" t.integer "creator_id"
t.integer "home_id" t.integer "home_id"
t.string "domain"
t.boolean "is_public" t.boolean "is_public"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
@ -1387,6 +1386,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do
t.integer "changeset_num", :default => 0 t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0 t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0 t.integer "board_num", :default => 0
t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0 t.integer "attach_num", :default => 0
t.datetime "commit_time" t.datetime "commit_time"
end end

View File

@ -1125,3 +1125,7 @@ a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px s
.h34 {height:34px;} .h34 {height:34px;}
.resource-tab {font-size:16px; color:#4d4d4d; width:70px; padding:5px 10px; display:inline-block; text-align:left; border-bottom:1px solid #ddd;} .resource-tab {font-size:16px; color:#4d4d4d; width:70px; padding:5px 10px; display:inline-block; text-align:left; border-bottom:1px solid #ddd;}
a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px solid #269ac9;} a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px solid #269ac9;}
a.group-btn{ background: url(../images/course/hwork_icon.png) -2px -58px no-repeat !important; height:20px; display:block; padding-left:23px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repeat; width:30px; height:20px; display:block; padding-left:23px; color:#888888;}