diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index f9236d0b7..5b81b7291 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -52,9 +52,14 @@ class FilesController < ApplicationController end def create - if params[:tag_name] + if params[:add_tag] + @addTag=true + #render :back tag_saveEx - render :text =>"success" + #render :text =>"success" + respond_to do |format| + format.js + end else @addTag=false container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) @@ -64,7 +69,27 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.attachments_added(attachments[:files]).deliver end - redirect_to project_files_path(@project) + + # 临时用 + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun + @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + @attachtype = 0 + @contenttype = 0 + + respond_to do |format| + format.js + format.html { + redirect_to project_files_path(@project) + } + end + end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 8eae8b855..64bfe5c40 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -102,11 +102,12 @@ class HomeworkAttachController < ApplicationController percent_m.to_s + "%" end @limit = 10 - @jours = @homework.journals_for_messages.order("created_on DESC") + @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] + @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") end #删除留言 @@ -127,13 +128,14 @@ class HomeworkAttachController < ApplicationController #添加留言 def addjours @homework = HomeworkAttach.find(params[:jour_id]) - @homework.addjours User.current.id, params[:new_form][:user_message],0 - @jours = @homework.journals_for_messages.order("created_on DESC") + @add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation] + @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC") @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] + @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") respond_to do |format| format.js end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 917d5b337..6452bcc81 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -689,7 +689,7 @@ class UsersController < ApplicationController end def tag_saveEx - @tags = params[:tag_name][:name] + @tags = params[:tag_name] @obj_id = params[:obj_id] @obj_flag = params[:obj_flag] diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 721b30361..8b03d74cd 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -145,6 +145,27 @@ module BidsHelper people.include?(User.current) end + # 当前用户是否加入了此课程(包括教师) + def is_cur_course_user? bid + people = [] + #people << bid.author + course = bid.courses.first + course.members.each do |member| + people << member.user + end + people.include?(User.current) + end + #当前用户是不是指定课程的学生 + def is_cur_course_student? course + people = [] + course.members.each do |member| + if [5,10].include? member.roles.first.id + people << member.user + end + end + people.include?(User.current) + end + # def select_option_helper option # tmp = Hash.new # option.each do |project| diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index dd83f895a..959d36cb0 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -137,14 +137,24 @@ module CoursesHelper Course.find_by_extra(try(extra)) end #判断制定用户是不是当前课程的老师 - def is_course_teacher user,project - is_teacher = false - searchTeacherAndAssistant(project).each do |teacher| - if user == teacher.user - is_teacher = true - break + def is_course_teacher user,course + people = [] + course.members.each do |member| + role_id = member.roles.first.id + if TeacherRoles.include? role_id + people << member.user end end - is_teacher + people.include?(user) + end + #当前用户是不是指定课程的学生 + def is_cur_course_student? course + people = [] + course.members.each do |member| + if StudentRoles.include? member.roles.first.id + people << member.user + end + end + people.include?(User.current) end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index ba2470fe9..201a582f2 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -49,5 +49,9 @@ module TagsHelper end return @result end - + +end + +def tagname_val + ("#tag_name_name").value end \ No newline at end of file diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index ac285e606..ad59d107d 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -13,8 +13,8 @@ class HomeworkAttach < ActiveRecord::Base "user_id" acts_as_attachable - def addjours user_id,message,status = 0 - jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status) + def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0 + jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation) jfm.save jfm end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index a9b88c32b..dc1e47ed7 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -1,11 +1,33 @@ <%= call_hook :view_account_login_top %> + + +
<%= form_tag(signin_path) do %> <%= back_url_hidden_field_tag %> - - + + diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index f24f7d052..cc7a26ad8 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -279,7 +279,7 @@ <% if @user.auth_source_id.nil? %>

<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %>

+ <%= l(:label_max_number) %>

<%= f.password_field :password, :size => 25, :required => true %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

@@ -302,10 +302,16 @@
<%= text_field_tag 'username', params[:username], :tabindex => '1' %> + <%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}", + :onfocus => "clearInfo('username','#{l(:label_login_prompt)}')", + :onblur => "showInfo('username','#{l(:label_login_prompt)}')", + :style => "resize: none;font-size: 12px;color: #818283;"%> +
-
<%= l(:label_gender) %>   - <%= select_tag 'gender', " - ".html_safe %>

+

+ + + +
<%= l(:label_gender) %>   + <%= select_tag 'gender', " + ".html_safe %> +
+

+

diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 674d73b79..63600619b 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -12,6 +12,5 @@ fileSpan.find('a.remove-upload') }) .off('click'); var divattach = fileSpan.find('div.div_attachments'); -divattach.html('<%#= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); - +divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>'); <% end %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index b650f2cb5..aa4140f95 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,13 +1,15 @@ -<% is_teacher = is_course_teacher User.current,@bid.courses.first.project %> +<% is_student = is_cur_course_student? @bid.courses.first %> +<% is_teacher = is_course_teacher User.current,@bid.courses.first %> + <%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
<%= l(:label_location) %> *
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( - User.current.admin? || - !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || + User.current.admin? || + !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || (Rails.env.development?) %> @@ -25,8 +27,8 @@ <% @homework_list.each do |homework|%> <% if homework.attachments.any?%> - - + +
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%>
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> @@ -44,8 +46,12 @@ <% end %> @@ -71,7 +77,7 @@ diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index a01143e0b..7dcf82e19 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -2,7 +2,7 @@ <% versions = project.versions.sort %> <% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true,:name=>"upload_form", :class => "tabular") do %> +<%= form_tag(project_files_path(project), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>

- <% if display_id %> + <% if is_student %> <%= link_to "互评>>" , homework_attach_path(homework)%> + <% else %> + <% if is_teacher %> + <%= link_to "综评>>" , homework_attach_path(homework)%> + <% end %> <% end %>
  - <% if display_id || is_teacher %> + <% if is_cur_course_user? @bid %> <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> <% end %>
diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index a5e7bed66..6cb35bccc 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -56,6 +56,7 @@ :url => {:controller => 'homework_attach', :action => 'addjours', :jour_id => homework_attach.id, + :is_comprehensive_evaluation => is_comprehensive_evaluation, :sta => sta}) do |f|%>
diff --git a/app/views/homework_attach/_comprehensive_evaluation.html.erb b/app/views/homework_attach/_comprehensive_evaluation.html.erb new file mode 100644 index 000000000..e6ebacffe --- /dev/null +++ b/app/views/homework_attach/_comprehensive_evaluation.html.erb @@ -0,0 +1,54 @@ +<% is_teacher = is_course_teacher User.current,homework.bid.courses.first %> +<% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %> + <% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %> +
+
+ 作业综评: + +
+ <% if stars != nil %> +
+ <% else %> +
+ <% end %> +
+
+
+
+
+
+
+
<%= comprehensive_evaluation.first.notes%>
+
+ <% if is_teacher %> +
评分: + <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> + (您可以重新打分,打分结果以最后一次打分为主!) +
+ <% end %> +
+<% else %> + <% if is_teacher %> +
+
+ 作业综评: +
+
评分: + <%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %> + (您可以重新打分,打分结果以最后一次打分为主!) +
+
+ <%= render :partial => 'addjour', :locals => {:homework_attach => homework, :sta => 0,:is_comprehensive_evaluation => 1} %> +
+
+ <% else %> +
+
+ 作业综评: +
+
老师还未进行评价!
+
+ <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/_showjour.html.erb b/app/views/homework_attach/_showjour.html.erb index 939deff3b..529767138 100644 --- a/app/views/homework_attach/_showjour.html.erb +++ b/app/views/homework_attach/_showjour.html.erb @@ -38,10 +38,25 @@ <% if jour.size > 0 %>
    <% for journal in jour%> + <% seems = homework.rates(:quality).where("rater_id = #{journal.user.id}").select("stars").first %>
  • <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> - <%= link_to journal.user, user_path(journal.user)%> + + <%= link_to journal.user, user_path(journal.user)%> + + <% label = l(:label_contest_requirement) %>
    <%= textilizable journal.notes%>
    <%= l(:label_bids_published) %> @@ -70,4 +85,12 @@
  • <% end %>
-<% end %> \ No newline at end of file +<% end %> + + + + \ No newline at end of file diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb index e463237e5..ed5887a7f 100644 --- a/app/views/homework_attach/addjours.js.erb +++ b/app/views/homework_attach/addjours.js.erb @@ -1,4 +1,9 @@ -$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false} )) %>'); -$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); -$('#new_form_user_message').val(""); -$('#new_form_reference_user_id').val(""); \ No newline at end of file +<% if @add_jour.is_comprehensive_evaluation == 1 %> + $('#comprehensive_evaluation').html('<%= escape_javascript(render(:partial => 'comprehensive_evaluation', + :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} )) %>'); +<% else %> + $('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>'); + $('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); + $('#new_form_user_message').val(""); + $('#new_form_reference_user_id').val(""); +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index f2c37d9ac..9c39e84f1 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -6,6 +6,9 @@ height: 200px; } +<% is_student = is_cur_course_student? @homework.bid.courses.first %> +<% is_teacher = is_course_teacher User.current,@homework.bid.courses.first %> +

<%= notice %>

@@ -93,10 +96,14 @@
+ <% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
最终得分
- <%= @homework.average(:quality).try(:avg).try(:round, 2).to_s %> - 分 + <% if score == "" %> + 0分 + <% else %> + <%= score %>分 + <% end %>
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> @@ -114,42 +121,32 @@
- +
+ <%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} %>
-
---> +
作业评论:
-
评分: - <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> - (您可以重新打分,打分结果以最后一次打分为主!) -
- + <% if is_student %> +
评分: + <%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %> + (您可以重新打分,打分结果以最后一次打分为主!) +
+ <% end %>
+<% if !is_teacher %> -
- <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0} %> +
+ <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %>
+<% end %>
- <%= render :partial => 'showjour', :locals => {:jour => @jour} %> -
- - -
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 0418697c3..c9390bcc3 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -57,6 +57,10 @@