From 03c8f397291f703660763d94554fe3a0e27edfc1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 29 May 2014 08:37:54 +0800 Subject: [PATCH 001/420] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=8F=8F=E8=BF=B0=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=202.=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_homework.html.erb | 6 +++--- config/locales/zh.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 3f0ad6cf8..5a358628e 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -29,8 +29,8 @@
- - + + @@ -155,7 +155,7 @@
-
高校课程实践社区<%= l(:label_user_location) %> : 高校课程实践社区<%= l(:label_user_location) %> :
+
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d5964c011..03530a97a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -600,7 +600,7 @@ zh: label_my_page_block: 我的工作台模块 label_administration: 管理 label_login: 登录 - label_login_prompt: 邮箱/账号 + label_login_prompt: 邮箱/昵称 lable_user_name: 登录名 label_logout: 退出 label_help: 帮助 From c4b292b711ff1883aa5ec0425280dc5ccd667455 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 29 May 2014 09:32:06 +0800 Subject: [PATCH 002/420] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=9F=A5=E7=9C=8B=E7=9C=9F=E5=90=8D=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=8B=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/show.html.erb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 173fc26a4..6be2a4d72 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -17,8 +17,13 @@ - +
<%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
<%= h(e.project) if @project.nil? || @project.id != e.project.id %> - - <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>) + + <% if @canShowRealName %> + <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>) + <% else %> + <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> + <% end %> + <%= l(:label_new_activity) %> <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> From 5a2226af37799ab5690efebdc562ccf45f26ed8d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 29 May 2014 09:34:09 +0800 Subject: [PATCH 003/420] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9Ahtm?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/_add_jour_reply.html.erb | 1 - app/views/homework_attach/_addjour.html.erb | 1 - app/views/homework_attach/_app_link.html.erb | 1 - app/views/homework_attach/_pre_show.html.erb | 1 - 4 files changed, 4 deletions(-) diff --git a/app/views/homework_attach/_add_jour_reply.html.erb b/app/views/homework_attach/_add_jour_reply.html.erb index 1e202e6a4..7a51b0ed6 100644 --- a/app/views/homework_attach/_add_jour_reply.html.erb +++ b/app/views/homework_attach/_add_jour_reply.html.erb @@ -1,4 +1,3 @@ - <%= form_tag({:controller => 'homework_attach', :action => 'add_jour_reply'}, :remote => true) do %> <%= text_area_tag 'user_notes', "", :class => 'noline', :style => "resize: none;", :rows => 4, diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 6cb35bccc..fb64a0995 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -1,4 +1,3 @@ - <% is_student = is_cur_course_student? @homework.bid.courses.first %> <% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %> -

<%= notice %>

@@ -29,8 +28,12 @@
作业下载: - <% options = {:author => true } %> - <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% if @is_evaluation || is_teacher%> + <% options = {:author => true } %> + <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <% else %> + <%= l(:label_cant_download) %> + <% end %> 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> @@ -133,10 +136,19 @@
作业评论:
<% if is_student %> -
评分: - <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
+ <% if @is_evaluation %> + <% if @has_evaluation %> +
+ <%= l(:lable_has_evaluation)%> +
+ <% else %> + <%= render :partial => 'evaluation', :locals => {:homework => @homework} %> + <% end %> + <% else %> +
+ <%= l(:lable_close_evaluation)%> +
+ <% end %> <% end %>
diff --git a/app/views/projects/_homework_form.html.erb b/app/views/projects/_homework_form.html.erb index 13255120f..596d83071 100644 --- a/app/views/projects/_homework_form.html.erb +++ b/app/views/projects/_homework_form.html.erb @@ -32,10 +32,8 @@

-->

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>

-

<%= hidden_field_tag 'course_id', @project.id %>

<%= l(:label_attachment_plural) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index de390a8f8..aecf2f19a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1546,6 +1546,7 @@ zh: label_bids_credit_number: 分 field_budget: 奖励 field_deadline: 截止日期 + field_is_evaluation: 是否启动互评 label_tags_selected: 已选标签 label_tags_related: 相关标签 button_project_tags_add: 增加 @@ -1600,6 +1601,9 @@ zh: label_have_feedback: 有了 label_of_feedback: 的 label_welcome_participate: 参与了 + label_cant_download: 未开启互评功能作业不允许下载 + lable_close_evaluation: 该作业未开启互评功能 + lable_has_evaluation: 您已进行过评价 #modify by men label_x_welcome_participate: zero: 参与了 @@ -1789,6 +1793,8 @@ zh: label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 label_task_submit_form_project: 作业最终以项目形式提交 + lable_start_mutual_evaluation: 启动互评 + lable_close_mutual_evaluation: 关闭互评 label_has_been: 已经被 label_course_userd_by: 个课程引用 diff --git a/db/migrate/20140605025247_add_evaluation_to_bid.rb b/db/migrate/20140605025247_add_evaluation_to_bid.rb new file mode 100644 index 000000000..f940974b4 --- /dev/null +++ b/db/migrate/20140605025247_add_evaluation_to_bid.rb @@ -0,0 +1,5 @@ +class AddEvaluationToBid < ActiveRecord::Migration + def change + add_column :bids, :is_evaluation, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 721945ed4..185f5e134 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 => 20140527060344) do +ActiveRecord::Schema.define(:version => 20140605025247) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -105,6 +105,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do t.integer "homework_type" t.integer "parent_id" t.string "password" + t.integer "is_evaluation" end create_table "boards", :force => true do |t| From cd3c69af9406db118a21c4dcf2e709dd9e2feae3 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 5 Jun 2014 14:07:44 +0800 Subject: [PATCH 076/420] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=BF=81=E7=A7=BB=EF=BC=8C=E4=BB=8E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=AD=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 1 + app/views/layouts/base_courses.html.erb | 7 ++----- ...20140605025302_migrate_course_attachments.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20140605025302_migrate_course_attachments.rb diff --git a/app/models/attachment.rb b/app/models/attachment.rb index aff63439e..65e3fe26a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -21,6 +21,7 @@ require "fileutils" class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" + belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e4a52826b..73c46b68b 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -40,9 +40,9 @@
<%= link_to request.host()+"/course", :controller => 'courses', :action => 'course' %><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %>

<%= link_to "主页", home_path %> - > <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'course' %> + > <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > <%= link_to @course.name, nil %>

@@ -79,9 +79,6 @@ <% end %> <% unless User.current.member_of?(@course) %> -
- - <%= watcher_link(@course, User.current) %>
<% end %> <% end %>
diff --git a/db/migrate/20140605025302_migrate_course_attachments.rb b/db/migrate/20140605025302_migrate_course_attachments.rb new file mode 100644 index 000000000..447624fa4 --- /dev/null +++ b/db/migrate/20140605025302_migrate_course_attachments.rb @@ -0,0 +1,17 @@ +class MigrateCourseAttachments < ActiveRecord::Migration + def self.up + # 原课程的资源数据迁移成新模式 + Attachment.all.each do |attach| + if attach.container_type == "Project" + project = Project.find_by_id(attach.container_id) + if project && project.project_type == 1 + attach.container_type= 'Course' + attach.save + end + end + end + end + + def self.down + end +end diff --git a/db/schema.rb b/db/schema.rb index dae888700..d559d41fb 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 => 20140605025300) do +ActiveRecord::Schema.define(:version => 20140605025302) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 6abdce1e5918869133ef2c29d4bfbf5dc739a653 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 14:13:27 +0800 Subject: [PATCH 077/420] sdf --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 50d8e823f..7dbc54f02 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -211,9 +211,9 @@ ActiveRecord::Schema.define(:version => 20140605003915) do t.string "summary" t.string "description" t.integer "author_id" - t.integer "comments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "contests", :force => true do |t| From f1555bf134a06a202db4e37468515e6f4251f390 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 14:58:24 +0800 Subject: [PATCH 078/420] dfg --- app/controllers/application_controller.rb | 4 ++-- app/views/contestnotifications/index.html.erb | 2 +- app/views/news/index.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 27829fa08..9eadda027 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -296,9 +296,9 @@ class ApplicationController < ActionController::Base end def find_contest_from_association - render_404 unless @contest.present? + render_404 unless @object.present? - @contest = @contest.contest + @contest =@object.contest end def find_model_object diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb index f4354a099..195257237 100644 --- a/app/views/contestnotifications/index.html.erb +++ b/app/views/contestnotifications/index.html.erb @@ -48,7 +48,7 @@ <%= l :label_update_time %>  <%= format_time(contestnotifications.created_at) %> - <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if(contestnotifications.notificationcomments_count >= 0)%> + <%= link_to l(:label_project_newother), contest_contestnotification_path(@contest, contestnotifications) %><%#= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count >= 0 %> diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 58b3aa43f..4dfa21d52 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -64,7 +64,7 @@ <%= l :label_update_time %> : <%= format_time(news.created_on) %> - + <%= link_to l(:label_project_newother), news_path(news) %><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %> From cb03669085596ba2e4c10c08b220754f32b4dbbe Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 15:00:38 +0800 Subject: [PATCH 079/420] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index bb7a2424f..ed6cdd25a 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -70,7 +70,12 @@ class Mailer < ActionMailer::Base end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " - else + elsif journals_for_message.jour.class.to_s.to_sym == :Bid + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 999b856d84e907bc188d7c6534ad54494cc21148 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Jun 2014 15:14:51 +0800 Subject: [PATCH 080/420] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=BC=80?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2=E6=95=88?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- app/views/bids/_homework_list.html.erb | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 97ebb4d49..c0df0699c 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -878,7 +878,7 @@ class BidsController < ApplicationController def find_bid if params[:id] - @bid = Bid.find(params[:id]) + @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) @user = @bid.author end rescue diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 5e041065d..48f1c150d 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -99,7 +99,7 @@   - <% if is_cur_course_user? @bid %> + <% if User.current.member_of?(@bid.courses.first) %> <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> <% end %> @@ -112,20 +112,6 @@ <% end %> - - From d22ffa84b45367e37ac9d5bb254b1444c5f33d36 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 5 Jun 2014 15:20:09 +0800 Subject: [PATCH 081/420] =?UTF-8?q?1.=E8=AF=BE=E7=A8=8B=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=EF=BC=8C=E4=BB=8E=E9=A1=B9=E7=9B=AE=E4=B8=AD?= =?UTF-8?q?=E5=88=86=E7=A6=BB=202.=E6=A0=87=E7=AD=BEcontrol\view=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E8=AF=BE=E7=A8=8B=E7=B1=BB=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 13 ++++++++++++- app/models/course.rb | 4 +++- app/views/layouts/base_courses.html.erb | 9 +++------ app/views/tags/_tag_name.html.erb | 9 ++++++++- config/routes.rb | 9 ++++++++- db/migrate/20140605025303_migrate_course_tags.rb | 16 ++++++++++++++++ db/schema.rb | 2 +- 7 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20140605025303_migrate_course_tags.rb diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 84c3aff0f..175041de9 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -4,7 +4,8 @@ class TagsController < ApplicationController layout "base_tags" before_filter :require_admin,:only => :show - + + include CoursesHelper include ProjectsHelper include IssuesHelper include UsersHelper @@ -64,6 +65,7 @@ class TagsController < ApplicationController # 获取搜索结果 @obj,@obj_pages,@results_count,@users_results, @projects_results, + @@courses_results, @issues_results, @bids_results, @forums_results, @@ -96,6 +98,7 @@ class TagsController < ApplicationController # 获取搜索结果 @obj,@obj_pages,@results_count,@users_results, @projects_results, + @@courses_results, @issues_results, @bids_results, @forums_results, @@ -114,6 +117,7 @@ class TagsController < ApplicationController # 获取搜索结果 @obj,@obj_pages,@results_count,@users_results, @projects_results, + @@courses_results, @issues_results, @bids_results, @forums_results, @@ -188,6 +192,7 @@ class TagsController < ApplicationController @obj_pages = nil @obj = nil @result = nil + @courses_results = nil # 这里为了提高系统的响应速度 把搜索结果放到case中去了 case obj_flag @@ -219,6 +224,9 @@ class TagsController < ApplicationController when '8' @obj = OpenSourceProject.find_by_id(obj_id) @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags)) + when '9' then + @obj = Course.find_by_id(obj_id) + @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) else @obj = nil end @@ -232,6 +240,7 @@ class TagsController < ApplicationController @forums_results, attachments_results, @contests_results, + @courses_results, @open_source_projects_results] end @@ -279,6 +288,8 @@ class TagsController < ApplicationController return 'Contest' when '8' return 'OpenSourceProject' + when '9' + return 'Course' else render_error :message => e.message return diff --git a/app/models/course.rb b/app/models/course.rb index df063cecb..e47fb52c2 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -23,8 +23,10 @@ class Course < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_many :course_infos, :dependent => :destroy + acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy - + acts_as_attachable :view_permission => :view_files, + :delete_permission => :manage_files validates_presence_of :password, :term validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 73c46b68b..8e32e2194 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -96,9 +96,6 @@ <% files_count = @course.attachments.count %> - <% @course.versions.each do |version| %> - <% files_count += version.attachments.count %> - <% end %>
@@ -188,7 +185,7 @@
- <% if @course.description.size>0 %> + <% if @course.description && @course.description.size>0 %>
<%= textilizable @course.description %> @@ -199,7 +196,7 @@
<% end %>
- <%= l(:label_create_time) %>:<%= format_time(@course.created_on) %> + <%= l(:label_create_time) %>:<%= format_time(@course.created_at) %>
@@ -210,7 +207,7 @@
- <%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "2"} %> + <%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "5"} %>
diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index dad5d53f7..0b94264dd 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -7,7 +7,7 @@ // }); // }) - + <% @tags = obj.reload.tag_list %> <% if non_list_all and (@tags.size > 0) %> @@ -70,6 +70,7 @@ :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> + <% when '6' %> <% if (User.current.logged? && User.current.admin? @@ -86,6 +87,12 @@ :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> + <% when '9' %> + + <% if (CourseInfo.find_by_course_id(obj.id)).try(:user_id) == User.current.id %> + <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, + :taggable_id => obj.id, :taggable_type => object_flag %> + <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 7074965f5..3057955ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -550,9 +550,16 @@ RedmineApp::Application.routes.draw do get 'settings(/:tab)', :action => 'settings', :as => 'settings' get 'homework', :action => 'homework', :as => 'homework' get 'new_homework', :action => 'new_homework', :as => 'new_homework' + get 'file', :action => 'file', :as => 'file' post 'finishcourse' post 'restartcourse' - end + end + + resources :files, :only => [:index, :new, :create] do + collection do + match "getattachtype" , via: [:get, :post] + end + end end match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post] #match 'project/enterprise_course', :to => 'projects#enterprise_course' diff --git a/db/migrate/20140605025303_migrate_course_tags.rb b/db/migrate/20140605025303_migrate_course_tags.rb new file mode 100644 index 000000000..17f93d403 --- /dev/null +++ b/db/migrate/20140605025303_migrate_course_tags.rb @@ -0,0 +1,16 @@ +class MigrateCourseTags < ActiveRecord::Migration + def self.up + # 原课程的标签数据迁移成新模式 + taggings = ActsAsTaggableOn::Tagging.find_all_by_taggable_type('Project') + taggings.each do |tagging| + project = Project.find_by_id(tagging.taggable_id) + if project && project.project_type == 1 + tagging.taggable_type= 'Course' + tagging.save + end + end + end + + def self.down + end +end diff --git a/db/schema.rb b/db/schema.rb index d559d41fb..f642770a0 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 => 20140605025302) do +ActiveRecord::Schema.define(:version => 20140605025303) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 0255a61d2f4d1dba0a1904c50cab613c07e6129d Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 5 Jun 2014 15:23:58 +0800 Subject: [PATCH 082/420] dfg --- app/helpers/application_helper.rb | 7 +++++++ app/views/contestnotifications/index.api.rsb | 14 ++++++++++++++ app/views/contestnotifications/show.html.erb | 14 +++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 app/views/contestnotifications/index.api.rsb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd1f6f162..f558f1e7a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,6 +46,10 @@ module ApplicationHelper def authorize_for(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @project) end + + def authorize_for_contest(controller, action) + User.current.allowed_to?({:controller => controller, :action => action}, @contest) + end # Display a link if user is authorized # @@ -57,6 +61,9 @@ module ApplicationHelper link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) end + def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) + link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) + end # Displays a link to user's account page if active def link_to_user(user, options={}) if user.is_a?(User) diff --git a/app/views/contestnotifications/index.api.rsb b/app/views/contestnotifications/index.api.rsb new file mode 100644 index 000000000..6509d2915 --- /dev/null +++ b/app/views/contestnotifications/index.api.rsb @@ -0,0 +1,14 @@ +api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do + @contestnotificationss.each do |contestnotifications| + api.contestnotifications do + api.id contestnotifications.id + api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil? + api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil? + + api.title contestnotifications.title + api.summary contestnotifications.summary + api.description contestnotifications.description + api.created_at contestnotifications.created_at + end + end +end diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb index bd4c8a4f8..ead40aef7 100644 --- a/app/views/contestnotifications/show.html.erb +++ b/app/views/contestnotifications/show.html.erb @@ -38,23 +38,23 @@
<%= watcher_link(@contestnotifications, User.current) %> <%= link_to(l(:button_edit), - edit_news_path(@news), + edit_contest_contestnotification_path(@contestnotifications), :class => 'icon icon-edit', :accesskey => accesskey(:edit), - :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_contestnotification, @contest) %> - <%= delete_link news_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotification, @contest) %> + :onclick => '$("#edit-contestnotifications").show(); return false;') if User.current.allowed_to?(:manage_contestnotifications, @contest) %> + <%= delete_link contest_contestnotification_path(@contestnotifications) if User.current.allowed_to?(:manage_contestnotifications, @contest) %>

<%=h @contestnotifications.title %>

-<% if authorize_for('contestnotifications', 'edit') %> -
作业评分: - <% stars_reates = homework.rates(:quality) %> - <% sum = 0 %> - <% stars_reates.each do |star_reates| %> - <% sum = sum + star_reates.stars %> - <% end %> - <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> - <%= format("%.2f", sum * 1.0 / stars_reates_count) %> + <%= homework_score homework %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> @@ -104,8 +90,7 @@ <% end %> - <% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && - (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %> + <% if (User.current == homework.user) || is_teacher %> <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> <%= link_to(l(:label_bid_respond_delete), homework, method: :delete, :confirm => l(:text_are_you_sure)) %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 81a8b0861..62c7d482d 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -22,27 +22,27 @@ <% course = Course.find_by_extra(project.identifier) %>
-
- <%= render :partial => 'layouts/base_header'%> +
+ <%= render :partial => 'layouts/base_header'%>
-
+
- + - -
高校课程实践社区 <%= l(:label_user_location) %> :
<%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > +

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > + <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > <%=link_to(@bid.name, respond_path(@bid)) %>

+
- +