From d049a0065592210a17c97da7e620104d5c90302c Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 20 Oct 2015 10:28:16 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E6=9C=AA=E5=8F=91=E5=B8=83=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=9A=84=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151020021234_update_course_activity.rb | 23 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20151020021234_update_course_activity.rb 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 From 1dd0954a9400a5508527b54de61ed35021172171 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 20 Oct 2015 10:29:51 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=84=8F=E8=A7=81=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/feedback.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 515dad66e2d986b618d1e68d05673d8271c3657f Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 10:30:09 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=E9=99=84=E4=BB=B6=E5=8D=95=E7=8B=ACJS=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_attachement_list.html.erb | 2 +- public/javascripts/attachments.js | 285 ++++++++++++++------- 2 files changed, 200 insertions(+), 87 deletions(-) diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index c2c8d2d10..eb730640c 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -27,7 +27,7 @@ :id => '_file', :class => ie8? ? '':'file_selector', :multiple => true, - :onchange => 'addInputFiles(this,"'+ checkBox.to_s+'");', + :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");', :style => ie8? ? '': 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, 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); - } + + 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'); - } + }).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 From 290e61599fdb8f526e6ebd45e98cbb492f86ba8d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 10:47:51 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=AF=B9=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=85=AC=E5=BC=80=E7=A7=81=E6=9C=89=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_attachement_list.html.erb | 55 +++++++++++++++------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index eb730640c..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 => '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) - } %> +<% 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 %> + From af4523815c6d53a95f8ff3ed0838698532c5bb4a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 11:03:47 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BB=8E=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E6=94=B9=E6=88=90=E7=A7=81=E6=9C=89=20=E5=88=99?= =?UTF-8?q?=E8=AF=A5=E8=AF=BE=E7=A8=8B=E4=B8=AD=E6=89=80=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E9=83=BD=E5=8F=98=E6=88=90=E7=A7=81=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/course.rb b/app/models/course.rb index 46599dbfc..a583990c1 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 @@ -213,6 +215,14 @@ class Course < ActiveRecord::Base 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 @board = self.boards.build From 5a5cf430d3d331958ac84835c00c58b00bd372b8 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 14:24:18 +0800 Subject: [PATCH 06/10] 0 --- app/models/course.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index a583990c1..7288c3b3b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -214,7 +214,7 @@ class Course < ActiveRecord::Base def self_validate end - + def update_files_public unless self.is_public? self.attachments.each do |a| From a8b4bde77c9cad26906169c7a9ab495554983dcc Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 20 Oct 2015 14:38:24 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8div?= =?UTF-8?q?=20=E4=B8=8B=E6=8B=89=E5=88=86=E9=A1=B5=20=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=A1=B5=20=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/my/account.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(''); From cc59b4c8779aad6cbf7216d36c4a5b2c36c3e415 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 20 Oct 2015 15:15:18 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=BC=96=E8=BE=91=E5=B8=96=E5=AD=90=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_message_edit.html.erb | 2 +- app/views/messages/edit.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 %> From 87b4c8324718d3874a1a6708f44405d1f8e398fe Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 20 Oct 2015 16:19:32 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E5=8C=BF=E8=AF=84=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=88=A0=E9=99=A4=EF=BC=9B=20=E7=9C=8B?= =?UTF-8?q?=E5=AE=8C=E6=B6=88=E6=81=AF=E5=90=8E=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=BA=94=E7=9A=84=E5=AD=97=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 6 +++++- app/controllers/users_controller.rb | 2 +- app/models/student_work.rb | 6 ++++-- app/views/users/_user_message_course.html.erb | 20 +++++++++---------- 4 files changed, 20 insertions(+), 14 deletions(-) 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/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/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 6c22976fd..86b44f66d 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? %> From a817c3b81ea87127fb540d529075b349296c412f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 20 Oct 2015 17:27:06 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 30 +++++++++---------- app/models/course_message.rb | 8 +++-- app/services/courses_service.rb | 1 + .../courses/_join_private_course.html.erb | 10 +++---- app/views/courses/_set_join.js.erb | 4 ++- app/views/courses/join.js.erb | 26 ++++++++++++++++ 6 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 app/views/courses/join.js.erb 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/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/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/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 %>