diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 7d26b2eca..fe9318006 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -31,27 +31,25 @@ class CoursesController < ApplicationController
def join
if User.current.logged?
- cs = CoursesService.new
- user = User.current
- join = cs.join_course params,user
- @state = join[:state]
- course = join[:course]
+ if params[:role] == 10
+ cs = CoursesService.new
+ @user = User.current
+ join = cs.join_course params,user
+ @state = join[:state]
+ @course = join[:course]
+ else
+ @course = Course.find_by_id params[:object_id]
+ CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest')
+ @state = 6
+ end
else
@state = 5 #未登录
end
- # if @state == 1 || @state == 3
- # respond_to course_path(course.id)
- # else
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
- end
- #end
-
- rescue Exception => e
- @state = 4 #已经加入了课程
+ @object_id = params[:object_id]
respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} }
+ format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} }
end
+
end
def unjoin
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 9393339a8..e5e1bf391 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -63,7 +63,7 @@ class StudentWorkController < ApplicationController
journal_for_teacher.update_attributes(:viewed => true)
end
#不能参与作业匿评消息状态更新
- no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "NoEvaluation", 0)
+ no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =? and status =?", User.current.id, @homework.course, "StudentWork", 0, 0)
no_evaluation.update_all(:viewed => true)
# 作品留言
# 消息end
@@ -144,6 +144,10 @@ class StudentWorkController < ApplicationController
end
def new
+ #更新消息
+ noEvaluation = @homework.course_messages.where("user_id =? and viewed =?", User.current.id, 0)
+ noEvaluation.update_all(:viewed => true)
+
if @homework.homework_type==2
redirect_to new_user_commit_homework_users_path(homework_id: @homework.id)
return
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index ef3210719..7adba7cbf 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -128,7 +128,7 @@ class UsersController < ApplicationController
#课程相关消息
when 'homework'
- @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','NoEvaluation') and user_id =?", @user).order("created_at desc")
+ @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?", @user).order("created_at desc")
when 'course_message'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
when 'course_news'
diff --git a/app/models/course.rb b/app/models/course.rb
index 46599dbfc..7288c3b3b 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -50,6 +50,8 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
+ # 公开课程变成私有课程,所有资源都变成私有
+ after_update :update_files_public
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message
before_destroy :delete_all_members
@@ -212,6 +214,14 @@ class Course < ActiveRecord::Base
def self_validate
end
+
+ def update_files_public
+ unless self.is_public?
+ self.attachments.each do |a|
+ a.update_attributes(:is_public => false)
+ end
+ end
+ end
# 创建课程讨论区
def create_board_sync
diff --git a/app/models/course_message.rb b/app/models/course_message.rb
index 65e91141c..11b0165c5 100644
--- a/app/models/course_message.rb
+++ b/app/models/course_message.rb
@@ -18,8 +18,10 @@ class CourseMessage < ActiveRecord::Base
after_create :add_user_message
def add_user_message
- if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
- self.message_alls << MessageAll.new(:user_id => self.user_id)
- end
+ #unless self.course_message_type == 'JoinCourseRequest'
+ if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
+ self.message_alls << MessageAll.new(:user_id => self.user_id)
+ end
+ #end
end
end
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 700613792..010ede635 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -8,6 +8,8 @@ class StudentWork < ActiveRecord::Base
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
has_many :student_work_tests, order: 'id desc'
+ # course's message
+ has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
before_destroy :delete_praise
before_save :set_program_score, :set_src
@@ -138,10 +140,10 @@ class StudentWork < ActiveRecord::Base
end
end
+ # status == 0 : delay
def act_as_message
if self.created_at > self.homework_common.end_time + 1
- CourseMessage.create(:user_id => self.user_id, :course_id => self.homework_common.course_id,
- :course_message_id => self.id, :course_message_type => 'NoEvaluation',:viewed => false)
+ self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false)
end
end
end
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index c2944fed5..4639f1c2b 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -299,6 +299,7 @@ class CoursesService
#@state == 3 您已经加入了课程
#@state == 4 您加入的课程不存在
#@state == 5 您还未登录
+ #@state == 6 申请成功,请等待审核完毕
#@state 其他 未知错误,请稍后再试
def join_course params,current_user
course = Course.find_by_id params[:object_id]
diff --git a/app/views/boards/_course_message_edit.html.erb b/app/views/boards/_course_message_edit.html.erb
index 16807afb0..caa389945 100644
--- a/app/views/boards/_course_message_edit.html.erb
+++ b/app/views/boards/_course_message_edit.html.erb
@@ -12,5 +12,5 @@
<%= render :partial => 'boards/course_new',
- :locals => {:f => f, :edit_mode => edit_mode, :topic => topic} %>
+ :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :course => course} %>
\ No newline at end of file
diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb
index 01e04dcfd..4122a7105 100644
--- a/app/views/courses/_join_private_course.html.erb
+++ b/app/views/courses/_join_private_course.html.erb
@@ -71,12 +71,12 @@
密 码:
-
+
身 份:
-
diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb
index 5476e7ff0..33caf5273 100644
--- a/app/views/courses/_set_join.js.erb
+++ b/app/views/courses/_set_join.js.erb
@@ -1,4 +1,4 @@
-<% if object_id%>
+<% if object_id && @state != 6%>
$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(course, user)) %>");
<% end %>
<% if @state %>
@@ -18,6 +18,8 @@
alert("您加入的课程不存在");
<% elsif @state == 5 %>
alert("您还未登录");
+ <% elsif @state == 6 %>
+ alert("申请成功,请等待审核")
<% else %>
alert("未知错误,请稍后再试");
<% end %>
diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb
new file mode 100644
index 000000000..64b1ffd4c
--- /dev/null
+++ b/app/views/courses/join.js.erb
@@ -0,0 +1,26 @@
+<% if @object_id && @state != 6%>
+$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@course, @user)) %>");
+<% end %>
+<% if @state %>
+<% if @state == 0 %>
+alert("加入成功");
+hideModal($("#popbox02"));
+$("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品");
+window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
+<% elsif @state == 1 %>
+alert("密码错误");
+<% elsif @state == 2 %>
+alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
+<% elsif @state == 3 %>
+alert("您已经加入了课程");
+window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
+<% elsif @state == 4 %>
+alert("您加入的课程不存在");
+<% elsif @state == 5 %>
+alert("您还未登录");
+<% elsif @state == 6 %>
+alert("申请成功,请等待审核")
+<% else %>
+alert("未知错误,请稍后再试");
+<% end %>
+<% end %>
diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb
index c2c8d2d10..4c631d22f 100644
--- a/app/views/files/_attachement_list.html.erb
+++ b/app/views/files/_attachement_list.html.erb
@@ -23,23 +23,44 @@
<% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%>
-<%= file_field_tag 'attachments[dummy][file]',
- :id => '_file',
- :class => ie8? ? '':'file_selector',
- :multiple => true,
- :onchange => 'addInputFiles(this,"'+ checkBox.to_s+'");',
- :style => ie8? ? '': 'display:none',
- :data => {
- :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
- :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
- :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
- :upload_path => uploads_path(:format => 'js'),
- :description_placeholder => l(:label_optional_description),
- :field_is_public => l(:field_is_public),
- :are_you_sure => l(:text_are_you_sure),
- :file_count => l(:label_file_count),
- :delete_all_files => l(:text_are_you_sure_all)
- } %>
+<% if @course %>
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => ie8? ? '':'file_selector',
+ :multiple => true,
+ :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");',
+ :style => ie8? ? '': 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js'),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+<% else %>
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => ie8? ? '':'file_selector',
+ :multiple => true,
+ :onchange => 'addInputFiles(this);',
+ :style => ie8? ? '': 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js'),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+<% end %>
+
diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb
index 0817594ab..624174b14 100644
--- a/app/views/messages/edit.html.erb
+++ b/app/views/messages/edit.html.erb
@@ -30,7 +30,7 @@
:method => :post}
} do |f| %>
<%= render :partial => 'boards/course_message_edit',
- :locals => {:f => f, :edit_mode => true, :topic => @message} %>
+ :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %>
<% end %>
<% end %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 0531ea9e7..7bc674ea6 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -603,7 +603,7 @@
success: function (data) {
schoolsResult = data.schools;
count = data.count;
- maxPage = count % 100 + 1; //最大页码值
+ maxPage = Math.ceil(count/100) //最大页码值
if(schoolsResult.length != undefined && schoolsResult.length != 0) {
var i = 0;
$("#search_school_result_list").html('');
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 2467a436c..d59045e07 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -37,7 +37,7 @@
<%= time_tag(ma.created_at).html_safe %>
<% end %>
- <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? && !ma.course_message.nil? %>
+ <% if ma.course_message_type == "HomeworkCommon" %>
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
@@ -376,27 +376,27 @@
<% end %>
<% end %>
- <% if ma.course_message_type == "NoEvaluation" %>
+ <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
<%= User.current.lastname + User.current.firstname %>
- <%= User.current.allowed_to?(:as_teacher,student_work.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
+ <%= User.current.allowed_to?(:as_teacher,ma.course_message.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
-
课程名称:<%= student_work.homework_common.course.name %>(<%= student_work.homework_common.course.time.to_s + '年' + student_work.homework_common.course.term %>)
-
作业标题:<%=student_work.homework_common.name %>
-
提交截止:<%=student_work.homework_common.end_time %> 24:00
-
提交时间:<%=format_time(student_work.created_at) %>
+
课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
+
作业标题:<%=ma.course_message.homework_common.name %>
+
提交截止:<%=ma.course_message.homework_common.end_time %> 24:00
+
提交时间:<%=format_time(ma.course_message.created_at) %>
- <%= time_tag(ma.created_at).html_safe %>
diff --git a/db/migrate/20151020021234_update_course_activity.rb b/db/migrate/20151020021234_update_course_activity.rb
new file mode 100644
index 000000000..595b0d333
--- /dev/null
+++ b/db/migrate/20151020021234_update_course_activity.rb
@@ -0,0 +1,23 @@
+class UpdateCourseActivity < ActiveRecord::Migration
+ def up
+ count = CourseActivity.all.count / 30 + 2
+ transaction do
+ for i in 1 ... count do i
+ CourseActivity.page(i).per(30).each do |activity|
+ if activity.course_act
+ if activity.course_act_type == 'Poll'
+ if activity.course_act.polls_status == 1
+ activity.destroy
+ end
+ end
+ else
+ activity.destroy
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 41efc5698..4aa12f627 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20151020014759) do
+ActiveRecord::Schema.define(:version => 20151020021234) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 12384f451..329d0db5a 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -88,7 +88,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
return null;
}
-function addFile(inputEl, file, eagerUpload,checkBox) {
+function addFile(inputEl, file, eagerUpload) {
var attachments_frame = '#attachments_fields';
if ($(attachments_frame).children().length < 30) {
@@ -99,72 +99,50 @@ function addFile(inputEl, file, eagerUpload,checkBox) {
'id': 'attachments_' + attachmentId,
'class': 'attachment'
});
- //alert(checkBox);
- if(checkBox){
- fileSpan.append(
- $('', {
- 'type': 'text',
- 'class': 'filename readonly',
- 'name': 'attachments[' + attachmentId + '][filename]',
- 'readonly': 'readonly'
- }).val(file.name),
- $('', {
- 'type': 'text',
- 'class': 'description',
- 'name': 'attachments[' + attachmentId + '][description]',
- 'maxlength': 254,
- 'placeholder': $(inputEl).data('descriptionPlaceholder')
- }).toggle(!eagerUpload),
- $('', {
- 'class': 'div_attachments',
- 'name': 'div_' + 'attachments_' + attachmentId
- })
- ).appendTo('#attachments_fields');
- }else {
- fileSpan.append(
- $('
', {
- 'type': 'text',
- 'class': 'filename readonly',
- 'name': 'attachments[' + attachmentId + '][filename]',
- 'readonly': 'readonly'
- }).val(file.name),
- $('
', {
- 'type': 'text',
- 'class': 'description',
- 'name': 'attachments[' + attachmentId + '][description]',
- 'maxlength': 254,
- 'placeholder': $(inputEl).data('descriptionPlaceholder')
- }).toggle(!eagerUpload),
- $('
' + $(inputEl).data('fieldIsPublic') + ':').attr({
- 'class': 'ispublic-label'
- }),
- $('
', {
- 'type': 'checkbox',
- 'class': 'is_public_checkbox',
- 'value': 1,
- 'name': 'attachments[' + attachmentId + '][is_public_checkbox]',
- checked: 'checked'
- }).toggle(!eagerUpload),
- $('
 ').attr({
- 'href': "#",
- 'class': 'remove-upload'
- }).click(function () {
- if (confirm($(inputEl).data('areYouSure'))) {
- removeFile();
- if (!eagerUpload) {
- (function (e) {
- reload(e);
- })(fileSpan);
- }
- }
- }).toggle(!eagerUpload),
- $('
', {
- 'class': 'div_attachments',
- 'name': 'div_' + 'attachments_' + attachmentId
- })
- ).appendTo('#attachments_fields');
- }
+ fileSpan.append(
+ $('
', {
+ 'type': 'text',
+ 'class': 'filename readonly',
+ 'name': 'attachments[' + attachmentId + '][filename]',
+ 'readonly': 'readonly'
+ }).val(file.name),
+ $('
', {
+ 'type': 'text',
+ 'class': 'description',
+ 'name': 'attachments[' + attachmentId + '][description]',
+ 'maxlength': 254,
+ 'placeholder': $(inputEl).data('descriptionPlaceholder')
+ }).toggle(!eagerUpload),
+ $('
' + $(inputEl).data('fieldIsPublic') + ':').attr({
+ 'class': 'ispublic-label'
+ }),
+ $('
', {
+ 'type': 'checkbox',
+ 'class': 'is_public_checkbox',
+ 'value': 1,
+ 'name': 'attachments[' + attachmentId + '][is_public_checkbox]',
+ checked: 'checked'
+ }).toggle(!eagerUpload),
+ $('
 ').attr({
+ 'href': "#",
+ 'class': 'remove-upload'
+ }).click(function() {
+ if (confirm($(inputEl).data('areYouSure'))) {
+ removeFile();
+ if (!eagerUpload) {
+ (function(e) {
+ reload(e);
+ })(fileSpan);
+ }
+ }
+
+ }).toggle(!eagerUpload),
+ $('
', {
+ 'class': 'div_attachments',
+ 'name': 'div_' + 'attachments_' + attachmentId
+ })
+ ).appendTo('#attachments_fields');
if (eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
@@ -195,9 +173,9 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
ajaxUpload.uploading++;
uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, {
- loadstartEventHandler: onLoadstart.bind(progressSpan),
- progressEventHandler: onProgress.bind(progressSpan)
- })
+ loadstartEventHandler: onLoadstart.bind(progressSpan),
+ progressEventHandler: onProgress.bind(progressSpan)
+ })
.done(function(result) {
progressSpan.progressbar('value', 100).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
@@ -284,22 +262,22 @@ function removeFile() {
//gcm delete all file
//modify by yutao 2015-5-14 ��1��ҳ����ڶ���ϴ��ؼ�ʱ�˿�������bug �ʸ�֮ start
function removeAll(containerid) {
- if (confirm(deleteallfiles)) {
- if (containerid == undefined) {
- $(".remove-upload").removeAttr("data-confirm");
- $(".remove-upload").click();
- } else {
- var arr = $(".remove-upload").filter(function() {
- return $(this).data('containerid') == containerid;
- });
- arr.removeAttr("data-confirm");
- arr.click();
- }
+ if (confirm(deleteallfiles)) {
+ if (containerid == undefined) {
+ $(".remove-upload").removeAttr("data-confirm");
+ $(".remove-upload").click();
+ } else {
+ var arr = $(".remove-upload").filter(function() {
+ return $(this).data('containerid') == containerid;
+ });
+ arr.removeAttr("data-confirm");
+ arr.click();
}
- // return false;
}
- //modify by yutao 2015-5-14 ��1��ҳ����ڶ���ϴ��ؼ�ʱ�˿�������bug �ʸ�֮ end
- //gcm
+ // return false;
+}
+//modify by yutao 2015-5-14 ��1��ҳ����ڶ���ϴ��ؼ�ʱ�˿�������bug �ʸ�֮ end
+//gcm
function uploadBlob(blob, uploadUrl, attachmentId, options) {
@@ -335,11 +313,10 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
}
function addInputFiles(inputEl) {
- checkBox = arguments[1] == 'public' ? false : true;
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// upload files using ajax
- uploadAndAttachFiles(inputEl.files, inputEl,checkBox);
+ uploadAndAttachFiles(inputEl.files, inputEl);
// $(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
@@ -386,7 +363,7 @@ function addInputFiles_board(inputEl, id) {
//clearedFileInput.insertAfter('#attachments_fields');
}
-function uploadAndAttachFiles(files, inputEl,checkBox) {
+function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
@@ -401,7 +378,7 @@ function uploadAndAttachFiles(files, inputEl,checkBox) {
window.alert(maxFileSizeExceeded);
} else {
$.each(files, function() {
- addFile(inputEl, this, true,checkBox);
+ addFile(inputEl, this, true);
});
}
}
@@ -490,3 +467,139 @@ $(function() {
}
});
});
+
+//课程课件
+function addInputFilesCourseSource(inputEl) {
+ checkBox = arguments[1] == 'public' ? false : true;
+ // var clearedFileInput = $(inputEl).clone().val('');
+ if (inputEl.files) {
+ // upload files using ajax
+ uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox);
+ // $(inputEl).remove();
+ } else {
+ // browser not supporting the file API, upload on form submission
+ var attachmentId;
+ var aFilename = inputEl.value.split(/\/|\\/);
+ var count = $('#attachments_fields>span').length;
+ attachmentId = addFile(inputEl, {
+ name: aFilename[aFilename.length - 1]
+ }, false);
+ if (attachmentId) {
+ $(inputEl).attr({
+ name: 'attachments[' + attachmentId + '][file]'
+ }).hide();
+ if (count <= 0) count = 1;
+ $('#upload_file_count').html("
" + count + "" + $(inputEl).data('fileCount'));
+ }
+ }
+
+ //clearedFileInput.insertAfter('#attachments_fields');
+}
+
+function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) {
+
+ var maxFileSize = $(inputEl).data('max-file-size');
+ var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
+
+ var sizeExceeded = false;
+ $.each(files, function() {
+ if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {
+ sizeExceeded = true;
+ }
+ });
+ if (sizeExceeded) {
+ window.alert(maxFileSizeExceeded);
+ } else {
+ $.each(files, function() {
+ addFileCourseSource(inputEl, this, true,checkBox);
+ });
+ }
+}
+
+function addFileCourseSource(inputEl, file, eagerUpload,checkBox) {
+
+ var attachments_frame = '#attachments_fields';
+ if ($(attachments_frame).children().length < 30) {
+ deleteallfiles = $(inputEl).data('deleteAllFiles');
+ var attachmentId = addFile.nextAttachmentId++;
+
+ var fileSpan = $('
', {
+ 'id': 'attachments_' + attachmentId,
+ 'class': 'attachment'
+ });
+ //alert(checkBox);
+ if(checkBox){
+ fileSpan.append(
+ $('', {
+ 'type': 'text',
+ 'class': 'filename readonly',
+ 'name': 'attachments[' + attachmentId + '][filename]',
+ 'readonly': 'readonly'
+ }).val(file.name),
+ $('', {
+ 'type': 'text',
+ 'class': 'description',
+ 'name': 'attachments[' + attachmentId + '][description]',
+ 'maxlength': 254,
+ 'placeholder': $(inputEl).data('descriptionPlaceholder')
+ }).toggle(!eagerUpload),
+ $('', {
+ 'class': 'div_attachments',
+ 'name': 'div_' + 'attachments_' + attachmentId
+ })
+ ).appendTo('#attachments_fields');
+ }else {
+ fileSpan.append(
+ $('
', {
+ 'type': 'text',
+ 'class': 'filename readonly',
+ 'name': 'attachments[' + attachmentId + '][filename]',
+ 'readonly': 'readonly'
+ }).val(file.name),
+ $('
', {
+ 'type': 'text',
+ 'class': 'description',
+ 'name': 'attachments[' + attachmentId + '][description]',
+ 'maxlength': 254,
+ 'placeholder': $(inputEl).data('descriptionPlaceholder')
+ }).toggle(!eagerUpload),
+ $('
' + $(inputEl).data('fieldIsPublic') + ':').attr({
+ 'class': 'ispublic-label'
+ }),
+ $('
', {
+ 'type': 'checkbox',
+ 'class': 'is_public_checkbox',
+ 'value': 1,
+ 'name': 'attachments[' + attachmentId + '][is_public_checkbox]',
+ checked: 'checked'
+ }).toggle(!eagerUpload),
+ $('
 ').attr({
+ 'href': "#",
+ 'class': 'remove-upload'
+ }).click(function () {
+ if (confirm($(inputEl).data('areYouSure'))) {
+ removeFile();
+ if (!eagerUpload) {
+ (function (e) {
+ reload(e);
+ })(fileSpan);
+ }
+ }
+
+ }).toggle(!eagerUpload),
+ $('
', {
+ 'class': 'div_attachments',
+ 'name': 'div_' + 'attachments_' + attachmentId
+ })
+ ).appendTo('#attachments_fields');
+ }
+
+ if (eagerUpload) {
+ ajaxUpload(file, attachmentId, fileSpan, inputEl);
+
+ }
+ return attachmentId;
+ }
+ return null;
+}
+addFileCourseSource.nextAttachmentId = 1;
\ No newline at end of file
diff --git a/public/javascripts/feedback.js b/public/javascripts/feedback.js
index fb3b35ca7..b30c8f91d 100644
--- a/public/javascripts/feedback.js
+++ b/public/javascripts/feedback.js
@@ -19,12 +19,12 @@
if(options.minStatue == "true"){
show_btn.css("float", options.float);
sideContent.css('width', 0);
- show_btn.css('width', 25);
+ show_btn.css('width', 28);
}
//close
closeBtn.bind("click",function(){
sideContent.animate({width: '0px'},"fast");
- show_btn.stop(true, true).delay(300).animate({ width: '25px'},"fast");
+ show_btn.stop(true, true).delay(300).animate({ width: '28px'},"fast");
cookiesave('minStatue','true','','','');
});
//show