diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 514f68d49..23fe19333 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -600,7 +600,7 @@ private def has_login unless @attachment && @attachment.container_type == "PhoneAppVersion" - render_403 if !User.current.logged? && @attachment.container_type != 'OrgSubfield' && @attachment.container_type != 'OrgDocumentComment' + render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) end end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c8dcf0b8e..5966b310f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -25,7 +25,9 @@ class CommentsController < ApplicationController def create raise Unauthorized unless @news.commentable? - + if !@news.org_subfield_id.nil? + @org_subfield = OrgSubfield.find(@news.org_subfield_id) + end @comment = Comment.new #@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment] if params[:user_activity_id] diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index d3ac71b99..0962deb10 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -46,15 +46,16 @@ class NewsController < ApplicationController @course = Course.find(params[:course_id]) end if @project + @page = params[:page] ? params[:page].to_i + 1 : 0 scope = @project ? @project.news.visible : News.visible @news_count = scope.count - @news_pages = Paginator.new @news_count, @limit, params['page'] - @offset ||= @news_pages.offset + #@news_pages = Paginator.new @news_count, @limit, params['page'] + #@offset ||= @news_pages.offset @newss = scope.all(:include => [:author, :project], :order => "#{News.table_name}.created_on DESC", - :offset => @offset, - :limit => @limit) + :offset => @page * 10, + :limit => 10) respond_to do |format| format.html { @@ -63,6 +64,7 @@ class NewsController < ApplicationController render :layout => false if request.xhr? } + format.js format.api format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } end @@ -144,6 +146,10 @@ class NewsController < ApplicationController if @course render :layout => 'base_courses' end + elsif @news.org_subfield_id + @org_subfield = OrgSubfield.find(@news.org_subfield_id) + @organization = @org_subfield.organization + render :layout => 'base_org' end end @@ -151,6 +157,21 @@ class NewsController < ApplicationController #modify by nwb if @project @news = News.new(:project => @project, :author => User.current) + @news.safe_attributes = params[:news] + @news.save_attachments(params[:attachments]) + if @news.save + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS + end + render_attachment_warning_if_needed(@news) + #flash[:notice] = l(:notice_successful_create) + redirect_to project_news_index_url(@project) + else + redirect_to project_news_index_url(@project) + #layout_file = 'base_courses' + #render :action => 'new', :layout => layout_file + end elsif @course @news = News.new(:course => @course, :author => User.current) #render :layout => 'base_courses' @@ -221,8 +242,14 @@ class NewsController < ApplicationController end def edit + if @news.org_subfield_id + @org_subfield = OrgSubfield.find(@news.org_subfield_id) + @organization = @org_subfield.organization + end if @course render :layout => "base_courses" + elsif @org_subfield + render :layout => 'base_org' end end @@ -240,12 +267,17 @@ class NewsController < ApplicationController end def destroy + if @news.org_subfield_id + @org_subfield = OrgSubfield.find(@news.org_subfield_id) + end @news.destroy # modify by nwb if @project redirect_to project_news_index_url(@project) elsif @course redirect_to course_news_index_url(@course) + elsif @org_subfield + redirect_to organization_path(@org_subfield.organization, :org_subfield_id => @org_subfield.id) end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 39ece6fbe..361303833 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -116,6 +116,7 @@ class OrganizationsController < ApplicationController @organization.description = params[:organization][:description] # @organization.domain = params[:organization][:domain] @organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0 + @organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0 #@organization.name = params[:organization][:name] @organization.save respond_to do |format| @@ -300,7 +301,11 @@ class OrganizationsController < ApplicationController def org_resources_subfield @org = Organization.find(params[:id]) - @subfield = @org.org_subfields.where('field_type = "Resource" ') + if params[:send_type].present? and params[:send_type] == 'news' + @subfield = @org.org_subfields.where("field_type = 'Post'") + else + @subfield = @org.org_subfields.where('field_type = "Resource" ') + end respond_to do | format| format.js end diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index ec54ae8a4..78babc43c 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -2,6 +2,7 @@ class PollController < ApplicationController before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll] before_filter :find_container, :only => [:new,:create, :index] + before_filter :is_logged, :only => [:index, :show, :poll_result,:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll,:export_poll,:commit_answer,:commit_poll,:statistics_result] before_filter :is_member_of_course, :only => [:index,:show,:poll_result] before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll,:export_poll] include PollHelper @@ -503,6 +504,10 @@ class PollController < ApplicationController end end + def is_logged + redirect_to signin_path unless User.current.logged? + end + def is_member_of_course render_403 unless(@course && (User.current.member_of_course?(@course) || User.current.admin?)) end diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index b99963e2f..96eeab884 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -24,7 +24,7 @@ class PraiseTreadController < ApplicationController end return end - #@horizontal = params[:horizontal].downcase == "false" ? false:true + @horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal] if @obj.respond_to?("author_id") author_id = @obj.author_id elsif @obj.respond_to?("user_id") @@ -103,30 +103,36 @@ class PraiseTreadController < ApplicationController def find_object_by_type_and_id(type,id) @obj = nil case type - when 'User' - @obj = User.find_by_id(id) - when 'Issue' - @obj = Issue.find_by_id(id) - when 'Project' - @obj = Project.find_by_id(id) - when 'Bid' - @obj = Bid.find_by_id(id) - when 'Contest' - @obj = Contest.find_by_id(id) - when 'Memo' - @obj = Memo.find_by_id(id) - when 'Message' - @obj = Message.find_by_id(id) - when 'HomeworkCommon' - @obj = HomeworkCommon.find_by_id(id) - when 'JournalsForMessage' - @obj = JournalsForMessage.find_by_id(id) - when 'News' - @obj = News.find_by_id(id) - when 'Comment' - @obj = Comment.find_by_id(id) - when 'Journal' - @obj = Journal.find_by_id(id) + when 'Memo' + @obj = Memo.find_by_id(id) + when 'Message' + @obj = Message.find_by_id(id) + when 'HomeworkCommon' + @obj = HomeworkCommon.find_by_id(id) + when 'JournalsForMessage' + @obj = JournalsForMessage.find_by_id(id) + when 'News' + @obj = News.find_by_id(id) + when 'Comment' + @obj = Comment.find_by_id(id) + when 'Journal' + @obj = Journal.find_by_id(id) + when 'BlogComment' + @obj = BlogComment.find_by_id(id) + when 'OrgDocumentComment' + @obj = OrgDocumentComment.find_by_id(id) + when 'User' + @obj = User.find_by_id(id) + when 'Issue' + @obj = Issue.find_by_id(id) + when 'Project' + @obj = Project.find_by_id(id) + when 'Bid' + @obj = Bid.find_by_id(id) + when 'Contest' + @obj = Contest.find_by_id(id) + else + @obj = nil end return @obj end @@ -143,7 +149,8 @@ class PraiseTreadController < ApplicationController # end #再创建或更新praise_tread_cache表 - @ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) + #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) + @ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first @ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc @ptc.object_id = id.to_i @ptc.object_type = type diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 449d8b9de..b1c384ae4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -746,14 +746,34 @@ class UsersController < ApplicationController end end # end - jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @page = params[:page] ? params[:page].to_i + 1 : 0 + if params[:type].present? + case params[:type] + when "public" + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 0').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + when "private" + jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 1').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + else + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + end + else + jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jour_count = jours.count + @jour = jours.limit(10).offset(@page * 10) + end + @type = params[:type] if User.current == @user jours.update_all(:is_readed => true, :status => false) jours.each do |journal| fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) end end - @jour = paginateHelper jours,10 @state = false render :layout=>'new_base_user' end @@ -1753,6 +1773,48 @@ class UsersController < ApplicationController end end + def share_news_to_course + news = News.find(params[:send_id]) + course_ids = params[:course_ids] + course_ids.each do |course_id| + if Course.find(course_id).news.map(&:id).exclude?(news.id) + course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + news.attachments.each do |attach| + course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + end + end + end + + def share_news_to_project + news = News.find(params[:send_id]) + project_ids = params[:project_ids] + project_ids.each do |project_id| + if Project.find(project_id).news.map(&:id).exclude?(news.id) + project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now) + news.attachments.each do |attach| + project_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + end + end + end + + def share_news_to_org + news = News.find(params[:send_id]) + field_id = params[:subfield] + org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + news.attachments.each do |attach| + org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) + end + OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id) + end + def change_org_subfield end @@ -2102,9 +2164,17 @@ class UsersController < ApplicationController @user = User.current if !params[:search].nil? #发送到有栏目类型为资源的组织中 search = "%#{params[:search].to_s.strip.downcase}%" - @orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0} + if params[:send_type].present? and params[:send_type] == 'news' + @orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Post'").count > 0} + else + @orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0} + end else - @orgs = @user.organizations.select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0} + if params[:send_type].present? and params[:send_type] == 'news' + @orgs = @user.organizations.select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Post'").count > 0} + else + @orgs = @user.organizations.select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0} + end end @search = params[:search] #这里仅仅是传递需要发送的资源id diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index ebd46caa7..8115f3f91 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -225,11 +225,11 @@ class WordsController < ApplicationController def leave_user_message if User.current.logged? @user = User.find(params[:id]) - if params[:new_form][:user_message].size>0 && User.current.logged? && @user + if params[:new_form][:content].size>0 && User.current.logged? && @user if params[:private] && params[:private] == '1' - @user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:user_message], :reply_id => 0, :status => true, :is_readed => false, :private => 1) + @user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:content], :reply_id => 0, :status => true, :is_readed => false, :private => 1) else - @user.add_jour(User.current, params[:new_form][:user_message]) + @user.add_jour(User.current, params[:new_form][:content]) end end redirect_to feedback_path(@user) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f08a63ed..8aa11c3ac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2789,13 +2789,6 @@ int main(int argc, char** argv){ ss.html_safe end - #代码提交数量 - def changesets_num project - g = Gitlab.client - project.gpid.nil? ? 0 : g.project(project.gpid).commit_count - # project.changesets.count -end - #课程动态的更新 def update_course_activity type, id course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first @@ -2836,4 +2829,13 @@ end principal_activity.save end end + + #项目按更新时间排序 + def project_sort_update projects + unless projects.empty? + project_ids = '('+projects.map{|pro|pro.project_id}.join(',')+')' + sort_projects = ForgeActivity.find_by_sql("SELECT MAX(updated_at) AS updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} GROUP BY project_id ORDER BY MAX(updated_at) DESC") + return sort_projects + end + end end diff --git a/app/models/course.rb b/app/models/course.rb index 24e955d15..0194a2a9d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,7 +1,6 @@ require 'elasticsearch/model' class Course < ActiveRecord::Base include Redmine::SafeAttributes - include ApplicationHelper STATUS_ACTIVE = 1 STATUS_CLOSED = 5 @@ -71,7 +70,7 @@ class Course < ActiveRecord::Base validates_length_of :description, :maximum => 10000 before_save :self_validate # 公开课程变成私有课程,所有资源都变成私有 - after_update :update_files_public,:update_course_ealasticsearch_index,:update_activity + after_update :update_files_public,:update_course_ealasticsearch_index after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index before_destroy :delete_all_members,:delete_course_ealasticsearch_index @@ -429,12 +428,6 @@ class Course < ActiveRecord::Base end end end -#动态的更新 -def update_activity - update_course_activity(self.class, self.id) - update_user_activity(self.class, self.id) - update_org_activity(self.class, self.id) -end # Delete the previous articles index in Elasticsearch # Course.__elasticsearch__.client.indices.delete index: Course.index_name rescue nil diff --git a/app/models/news.rb b/app/models/news.rb index 7c44f7e8a..fee5d2801 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -22,6 +22,7 @@ class News < ActiveRecord::Base has_many_kindeditor_assets :assets, :dependent => :destroy #added by nwb belongs_to :course,:touch => true + belongs_to :org_subfield, :touch => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on" # fq @@ -57,7 +58,7 @@ class News < ActiveRecord::Base after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count after_update :update_activity - after_destroy :delete_kindeditor_assets, :decrease_news_count + after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities scope :visible, lambda {|*args| includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) @@ -187,4 +188,8 @@ class News < ActiveRecord::Base Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') end + def delete_org_activities + OrgActivity.where("container_type='OrgSubfield' and org_act_type='News' and org_act_id=?", self.id).destroy_all + end + end \ No newline at end of file diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index b109ba042..c62cbf4f8 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -6,6 +6,7 @@ class OrgSubfield < ActiveRecord::Base has_many :org_subfield_messages, :dependent => :destroy has_many :messages, :through => :org_subfield_messages has_many :boards, :dependent => :destroy + has_many :news, :dependent => :destroy acts_as_attachable after_create :create_board_sync # 创建资源栏目讨论区 diff --git a/app/views/attachments/_activity_attach.html.erb b/app/views/attachments/_activity_attach.html.erb index 9bd7d9d2f..32e796382 100644 --- a/app/views/attachments/_activity_attach.html.erb +++ b/app/views/attachments/_activity_attach.html.erb @@ -3,7 +3,7 @@
- <%= link_to_short_attachment attachment,:length=> 58, :class => 'mw400 hidden link_file_a fl newsBlue', :download => true -%> + <%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> ( diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index c3a6cc9d0..936bdd9b6 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -28,7 +28,7 @@ $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); - $('#ajax-modal').parent().css("top","").css("left","").css("width","511"); + $('#ajax-modal').parent().css("top","").css("left","").css("width","511").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("alert_praise"); <% end %> diff --git a/app/views/bids/alert_anonymous_comment.js.erb b/app/views/bids/alert_anonymous_comment.js.erb index 66c36e223..04f99980c 100644 --- a/app/views/bids/alert_anonymous_comment.js.erb +++ b/app/views/bids/alert_anonymous_comment.js.erb @@ -1,8 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'alert_anonyoms', locals: { bid: @bid, totle_size:@totle_size, cur_size:@cur_size, percent:@percent}) %>'); -showModal('ajax-modal', '500px'); -//$('#ajax-modal').css('height','180px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + - ""); -$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'alert_anonyoms', locals: { bid: @bid, totle_size:@totle_size, cur_size:@cur_size, percent:@percent}) %>'); +showModal('ajax-modal', '500px'); +//$('#ajax-modal').css('height','180px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("anonymos"); \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 02f1ad1ad..6f4397569 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -116,9 +116,18 @@ <% count=@article.children.count%> <% end %>
- <% unless count == 0 %> + <%# unless count == 0 %>
-
回复(<%=count %>)
+
回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if @article.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@article, :user_activity_id=>@article.id,:type=>"activity"}%> + <% end %> + +
-
-
-<% end %> - - \ No newline at end of file diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb index ac8c242d1..8b6e9f00c 100644 --- a/app/views/exercise/commit_exercise.js.erb +++ b/app/views/exercise/commit_exercise.js.erb @@ -1,8 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>'); -showModal('ajax-modal', '270px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + - ""); -$('#ajax-modal').parent().removeClass("alert_praise"); -$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>'); +showModal('ajax-modal', '270px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 9b6961e6c..8637273f1 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -25,7 +25,7 @@ $('#ajax-modal').before("" + ""); $('#ajax-modal').parent().removeClass("alert_praise"); - $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls"); } @@ -57,7 +57,7 @@ $('#ajax-modal').before("" + ""); $('#ajax-modal').parent().removeClass("alert_praise"); - $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls"); } } diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb index c1c4a4fd5..004ca9625 100644 --- a/app/views/exercise/publish_exercise.js.erb +++ b/app/views/exercise/publish_exercise.js.erb @@ -1,10 +1,10 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>"); -$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); -showModal('ajax-modal', '250px'); -//$('#ajax-modal').css('height','111px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + - ""); -$('#ajax-modal').parent().removeClass("alert_praise"); -$('#ajax-modal').parent().css("top","").css("left",""); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','111px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb index 2b4e67606..a55cefbde 100644 --- a/app/views/exercise/republish_exercise.js.erb +++ b/app/views/exercise/republish_exercise.js.erb @@ -1,10 +1,10 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>"); -$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); -showModal('ajax-modal', '250px'); -//$('#ajax-modal').css('height','80px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + - ""); -$('#ajax-modal').parent().removeClass("alert_praise"); -$('#ajax-modal').parent().css("top","").css("left",""); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','80px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 9513baab0..85b230be3 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -40,7 +40,7 @@ showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls"); } diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index f1d96d22c..47c08d2fb 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -43,7 +43,7 @@ <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
+
\ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 254b24f01..969e2643b 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -126,7 +126,8 @@ <%# 工具栏展开 %> <% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 || course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %> - + + @@ -278,7 +279,7 @@ showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls"); } // 鼠标经过的时候显示内容 @@ -292,6 +293,9 @@ obj.parent().parent().next("div").hide(); } + $("#expand_tools_expand").click(function(){ + $("#navContentCourse").toggle(); + }); \ No newline at end of file diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 58289b352..880c6cc1c 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -242,9 +242,13 @@ showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top","40%").css("left","36%"); + $('#ajax-modal').parent().css("top","40%").css("left","36%").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("popbox_polls"); } + + $("#expand_tools_expand").click(function(){ + $("#navContent").toggle(); + }); diff --git a/app/views/my/clear_user_avatar_temp.js.erb b/app/views/my/clear_user_avatar_temp.js.erb index 788678673..8795177fc 100644 --- a/app/views/my/clear_user_avatar_temp.js.erb +++ b/app/views/my/clear_user_avatar_temp.js.erb @@ -1,8 +1,8 @@ - $("img[nhname='avatar_image']").attr('src',$("#nh_user_tx").attr('src')); - $('#ajax-modal').html($("#nh_tx_dialog_html").html()); - showModal('ajax-modal','460px'); - $('#ajax-modal').siblings().hide(); - $('#ajax-modal').parent().removeClass("alert_praise"); - //$('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("alert_box"); - $('#ajax-modal').parent().css("border", "2px solid #15bccf").css("border-radius", "0").css(" -webkit-border-radius", "0").css(" -moz-border-radius", "0"); \ No newline at end of file + $("img[nhname='avatar_image']").attr('src',$("#nh_user_tx").attr('src')); + $('#ajax-modal').html($("#nh_tx_dialog_html").html()); + showModal('ajax-modal','460px'); + $('#ajax-modal').siblings().hide(); + $('#ajax-modal').parent().removeClass("alert_praise"); + //$('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("alert_box"); + $('#ajax-modal').parent().css("border", "3px solid #269ac9").css("border-radius", "0").css(" -webkit-border-radius", "0").css(" -moz-border-radius", "0"); \ No newline at end of file diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 914b1a6a1..07aaef26d 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -41,6 +41,7 @@ @@ -330,7 +330,7 @@ - function show_send(){ + function show_send_(){ $("#contextMenu").hide(); document.oncontextmenu = function() {return true;} line.children().css("background-color",'white'); @@ -338,12 +338,14 @@ if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 $.ajax({ type: 'get', - url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id + 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 + url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id, + data:{send_type:'file'} }); } } @@ -476,91 +478,5 @@ } } - //id 发送的id - //发送的id数组 - function chooseSendType(res_id,res_ids){ - - sendType = $(".resourcesSendType").val(); - if (sendType === lastSendType) { - return; - } else if (lastSendType != null) { //不是第一次点击的时候 - if(res_ids == "") {//如果是单个发送 - if (sendType === '1') { - $.ajax({ - type: 'get', - url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id - }); - } else if(sendType === '2') { - $.ajax({ - type: 'get', - url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id - }); - }else if(sendType ==='3') - { - $.ajax({ - type: 'get', - url: '<%= search_user_org_user_path(@user)%>' + '?send_id=' + res_id - }); - } - }else{//如果是多个发送 - if (sendType === '1'){ - $.ajax({ - type: 'get', - url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize() - }); - }else if(sendType === '2'){ - $.ajax({ - type: 'get', - url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize() - }); - }else if(sendType === '3'){ - $.ajax({ - type: 'get', - url: '<%= search_user_org_user_path(User.current)%>' + '?'+$("#resources_list_form").serialize() - }); - } - } - } - - lastSendType = sendType; - } - - function observeSearchfieldOnInput(fieldId, url,send_id,send_ids) { - $('#'+fieldId).each(function() { - var $this = $(this); - $this.addClass('autocomplete'); - $this.attr('data-value-was', $this.val()); - var check = function() { - var val = $this.val(); - if ($this.attr('data-value-was') != val){ - $this.attr('data-value-was', val); - $.ajax({ - url: url, - type: 'get', - data: {search: $this.val(),send_id:send_id,send_ids:send_ids}, - success: function(data){ }, - beforeSend: function(){ $this.addClass('ajax-loading'); }, - complete: function(){ $this.removeClass('ajax-loading'); } - }); - } - }; - var reset = function() { - if (timer) { - clearInterval(timer); - timer = setInterval(check, 300); - } - }; - var timer = setInterval(check, 300); - $this.bind('keyup click mousemove', reset); - }); - } - - function subfield_click(){ - var sendText = $("input[name='org_id']:checked").next().text(); - var orgDirection = "目标地址:" - var sendColumn = $("input[name='subfield']:checked").next().text(); - $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn); - } - diff --git a/config/routes.rb b/config/routes.rb index ccbe67004..3531f4b5f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -464,6 +464,8 @@ RedmineApp::Application.routes.draw do get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report' get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details' post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities" + match 'projects/:project_id/news/index', :to => 'news#index', :via => [:get, :post], :as => 'new_course_news' + match 'projects/:project_id/news/new', :to => 'news#new', :via => [:get, :post] post '/courses/:id/course_activity', :to => 'courses#show', :as => 'course_activity' get '/boards/:id/boards_topic', :to =>'boards#show', :as => 'boards_topic' @@ -532,6 +534,9 @@ RedmineApp::Application.routes.draw do post "add_exist_file_to_course" post "add_exist_file_to_project" post 'add_exist_file_to_org' + post 'share_news_to_course' + post 'share_news_to_project' + post 'share_news_to_org' get 'resource_preview' get 'rename_resource' get 'search_user_project' diff --git a/db/migrate/20160120032758_add_org_subfield_id_to_news.rb b/db/migrate/20160120032758_add_org_subfield_id_to_news.rb new file mode 100644 index 000000000..bd4ca9772 --- /dev/null +++ b/db/migrate/20160120032758_add_org_subfield_id_to_news.rb @@ -0,0 +1,5 @@ +class AddOrgSubfieldIdToNews < ActiveRecord::Migration + def change + add_column :news, :org_subfield_id, :integer + end +end diff --git a/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb b/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb new file mode 100644 index 000000000..edf5c47b0 --- /dev/null +++ b/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb @@ -0,0 +1,5 @@ +class AddAllowGuestDownloadToOrganizations < ActiveRecord::Migration + def change + add_column :organizations, :allow_guest_download, :boolean, :default => true + end +end diff --git a/db/schema.rb b/db/schema.rb index bac1882c5..347f801a6 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 => 20160115125217) do +ActiveRecord::Schema.define(:version => 20160121070232) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1082,14 +1082,15 @@ ActiveRecord::Schema.define(:version => 20160115125217) do create_table "news", :force => true do |t| t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" t.text "description" - t.integer "author_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false t.integer "course_id" - t.integer "sticky", :default => 0 + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1213,6 +1214,7 @@ ActiveRecord::Schema.define(:version => 20160115125217) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" + t.string "role" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -1261,8 +1263,9 @@ ActiveRecord::Schema.define(:version => 20160115125217) do t.integer "home_id" t.string "domain" t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "allow_guest_download", :default => true end create_table "phone_app_versions", :force => true do |t| @@ -1709,6 +1712,10 @@ ActiveRecord::Schema.define(:version => 20160115125217) do t.string "extra" end + create_table "temp", :id => false, :force => true do |t| + t.integer "id", :default => 0, :null => false + end + create_table "time_entries", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false diff --git a/public/images/bid/close.png b/public/images/bid/close.png index 301ba5e85..124685035 100644 Binary files a/public/images/bid/close.png and b/public/images/bid/close.png differ diff --git a/public/images/mes_icon.png b/public/images/mes_icon.png new file mode 100644 index 000000000..4a37cca0c Binary files /dev/null and b/public/images/mes_icon.png differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 193b358dc..f982d92f6 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -23,23 +23,6 @@ function description_show_hide(id){ }); } -function homework_description_show_hide(id){ - showNormalImage('homework_description_'+id); - if($("#intro_content_"+id).height() > 810) { - $("#intro_content_show_"+id).show(); - } - $("#intro_content_show_"+id).click(function(){ - $("#homework_description_"+id).toggleClass("maxh360"); - $("#intro_content_show_"+id).hide(); - $("#intro_content_hide_"+id).show(); - }); - $("#intro_content_hide_"+id).click(function(){ - $("#homework_description_"+id).toggleClass("maxh360"); - $("#intro_content_hide_"+id).hide(); - $("#intro_content_show_"+id).show(); - }); -} - function cleanArray (actual){ var newArray = new Array(); for (var i = 0; i< actual.length; i++){ @@ -1035,3 +1018,120 @@ function showNormalImage(id) { } } + +//文件、帖子、通知分享 +function org_id_click(){ + var sendText = $("input[name='org_id']:checked").next().text(); + var orgDirection = "目标地址:"; + $(".orgDirection").text(orgDirection + sendText); +} +function subfield_click(){ + var sendText = $("input[name='org_id']:checked").next().text(); + var orgDirection = "目标地址:"; + var sendColumn = $("input[name='subfield']:checked").next().text(); + $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn); +} + +function observeSearchfieldOnInput(fieldId, url,send_id,send_ids, send_type) { + $('#'+fieldId).each(function() { + var $this = $(this); + $this.addClass('autocomplete'); + $this.attr('data-value-was', $this.val()); + var check = function() { + var val = $this.val(); + if ($this.attr('data-value-was') != val){ + $this.attr('data-value-was', val); + $.ajax({ + url: url, + type: 'get', + data: {search: $this.val(),send_id:send_id,send_ids:send_ids, send_type:send_type}, + success: function(data){ }, + beforeSend: function(){ $this.addClass('ajax-loading'); }, + complete: function(){ $this.removeClass('ajax-loading'); } + }); + } + }; + var reset = function() { + if (timer) { + clearInterval(timer); + timer = setInterval(check, 300); + } + }; + var timer = setInterval(check, 300); + $this.bind('keyup click mousemove', reset); + }); +} +function check_des(event){ + if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){ + event.preventDefault(); + $(".orgDirection").text('目标地址组织不能为空'); + return false; + }else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){ + event.preventDefault(); + $(".orgDirection").text('目标地址栏目不能为空'); + return false; + }else{ + return true; + } +} + +var sendType = '1'; +var lastSendType ;//初始为发送到我的课程 +function show_send(id, user_id, send_type){ + if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_project', + data:{send_id:id, send_type:send_type} + }); + }else if(lastSendType == '1'){ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:id, send_type:send_type} + }); + }else if( lastSendType == '3'){//组织 + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_org', + data:{send_id:id, send_type:send_type} + }); + }else{ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:id, send_type:send_type} + }); + } +} + +//id 发送的id +//发送的id数组 +function chooseSendType(res_id,res_ids, user_id, send_type){ + + sendType = $(".resourcesSendType").val(); + if (sendType === lastSendType) { + return; + } else if(lastSendType != null) { //不是第一次点击的时候 + if (sendType == '1') { + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:res_id, send_type:send_type} + }); + } else if(sendType == '2') { + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_project', + data:{send_id:res_id, send_type:send_type} + }); + }else if(sendType == '3'){ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_org', + data:{send_id:res_id, send_type:send_type} + }); + } + } + lastSendType = sendType; +} diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 373cce51c..45721fd1b 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -1,365 +1,371 @@ -$(function(){ -//提交作业 - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - var tested = false; - var valid_form = function() { - var src = $('#program-src').val(); - var title = $('#program-title').val(); - - if (!src) { - alert('请输入正确的代码'); - return false; - } - if (!title) { - alert('请输入标题'); - return false; - } - return true; - }; - - var test_program = function(cb){ - var homework_id = $('#test-program-btn').attr('data-homework-id'); - var student_work_id = $('#test-program-btn').attr('data-student-work-id'); - var src = $('#program-src').val(); - var title = $('#program-title').val(); - var is_test = $('input[name=is_test]').val(); - - if(!valid_form()){ - return; - } - - $.post( - '/student_work/program_test', - {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}, - function(data,status){ - tested = true; - console.log(data); - if(data.index <=0){ - data.index = $('.ProResultTop').length+1; - } - - if (typeof cb == 'function') {cb(data); return;} - - - var html=bt('t:result-list',data); - $('.ProResult').prepend(html); - - if (data.status==0 && is_test != 'true') { - var r=confirm("答题正确,是否立刻提交?"); - if (r) { - $(".HomeWorkCon form").submit(); - } - } - } - ); - }; - - $('#test-program-btn').on('click', test_program); - - - $('#commit-program-work-btn').on('click', function(){ - if(!valid_form()){ - return; - } - if($('.ProResult .ProResultTop').length<=0){ - var r=confirm("测试后才能提交,是否立刻测试?"); - if (r) { - test_program(); - } - return; - } - - if (!tested) { - test_program(function(data){ - if (data.status!=0) { - var r=confirm("测试不通过,是否强制提交?"); - if (!r) { - return; - } - }; - $(".HomeWorkCon form").submit(); - }); - return; - } - - $(".HomeWorkCon form").submit(); - }); - - $('form.edit_student_work').on('keydown', '#program-src', function(){ - tested = false; - }); - -//发布作业 - - $('#program-src').focus(function(){ - $(this).css('height', '100px'); - }); - - var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true}; - - $('input.date-input').datepicker(datepickerOptions); - - $('a.pic_date').on('click', function(){ - $(this).parent().prev().first().focus(); - }) - - - $("#BluePopupBox").dialog({ - modal: true, - autoOpen: false, - dialogClass: 'BluePopupBox', - minWidth: 753 - }); - - $('a.ProBtn').live('click', function(){ - $("#BluePopupBox").dialog("open"); - $(".ui-dialog-titlebar").hide(); - $("a.CloseBtn").on('click', function(){ - $("#BluePopupBox" ).dialog("close"); - }); - $('#textarea_input_test').focus(); - }); - - var saveProgramAnswers = function() { - var test_numbers = 0; - var valid = true; - var input = null; - var output = null; - var input_groups = []; - $.each($('#BluePopupBox textarea.InputBox'), function(i, val){ - if ($(val).val().length<=0) { - $(val)[0].focus(); - valid =false; - return false; - } - if (test_numbers %2==0) { - input = $(val).val(); - } else { - output = $(val).val(); - input_groups.push({input: input, output: output}); - } - test_numbers += 1; - }); - - var language = ''; - if($('select.language_type').val() == 1){ - language = 'C'; - }else if($('select.language_type').val() == 2){ - language = 'C++'; - }else if($('select.language_type').val() == 3){ - language = 'Python'; - }else if($('select.language_type').val() == 4){ - language = 'Java'; - } - - if (valid) { - $("input[name=homework_type]").val(2); - $('span.program_detail_info').text('('+language+','+test_numbers/2+'组测试)'); - //保存js值 - var data = { - language_type: $('select.language_type').val(), - input_groups: input_groups - }; - //构建到form中 - $('.program-input').remove(); - var html=bt('t:program-input-list',data); - $("input[name=homework_type]").after(html); - } - return valid; - }; - - $("#BluePopupBox a.BlueCirBtn").live('click', function(){ - if(saveProgramAnswers()){ - if($( "#BluePopupBox" ).dialog( "isOpen" )){ - $("#BluePopupBox").dialog( "close" ); - } - } - }); - - $("#BluePopupBox").on('click', 'a.icon_add', function(){ - var html = bt('t:test-answer-list', null); - $(this).parent('.mt10').after(html); - var inputs = document.getElementsByName("program[input][]"); - var outputs = document.getElementsByName("program[output][]"); - if (inputs.length == outputs.length) { - for (var i=0; i