diff --git a/app/controllers/syllabus_member_controller.rb b/app/controllers/syllabus_member_controller.rb index ac686c0a2..b6da3290e 100644 --- a/app/controllers/syllabus_member_controller.rb +++ b/app/controllers/syllabus_member_controller.rb @@ -45,12 +45,12 @@ class SyllabusMemberController < ApplicationController member = SyllabusMember.find(params[:id]) @syllabus = member.syllabus members = @syllabus.syllabus_members - if params[:opr] == 'up' && member.rank > 2 + if params[:opr] == 'up' && member.rank > 1 before_mem = members.where("rank = #{member.rank - 1}").first if before_mem && member.update_attribute('rank', member.rank - 1) before_mem.update_attribute('rank', before_mem.rank + 1) end - elsif params[:opr] == 'down' && member.rank > 1 && member.rank < members.count + elsif params[:opr] == 'down' && member.rank < members.count after_mem = members.where("rank = #{member.rank + 1}").first if after_mem && member.update_attribute('rank', member.rank + 1) after_mem.update_attribute('rank', after_mem.rank - 1) diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index f0d1254bc..a6b11cfbf 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -33,6 +33,8 @@ class SyllabusesController < ApplicationController @syllabus.user_id = User.current.id @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content if @syllabus && @syllabus.save + member = SyllabusMember.create(:user_id => @syllabus.user_id, :rank => 1) + @syllabus.syllabus_members << member respond_to do |format| flash[:notice] = l(:notice_successful_create) format.html {redirect_to syllabus_path(@syllabus)} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef606c0cb..27e90b356 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3578,7 +3578,9 @@ def get_group_member_names work end def course_syllabus_option user = User.current - syllabuses = user.syllabuses + syllabus_members = SyllabusMember.where("user_id = #{user.id}") + syllabus_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|mem| mem.syllabus_id}.join(',') + ")" + syllabuses = Syllabus.where("id in #{syllabus_ids}") type = [] option1 = [] option1 << "请选择课程" diff --git a/app/models/user.rb b/app/models/user.rb index c1a830809..3386836ed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -853,6 +853,13 @@ class User < Principal OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 end + def member_of_syl?(syllabus) + if !self.logged? + return false + end + SyllabusMember.where("user_id =? and syllabus_id =?", self.id, syllabus.id).count > 0 + end + def admin_of_org?(org) if self.admin? return true diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index e523b347f..4c54e2289 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -32,8 +32,9 @@
  • - <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:210px'} %> - 如果列表中没有对应的课程,请您先<%=link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'ml5 green_btn_share c_white'%>,然后【刷新】 + <%=@course.syllabus.title %> + <%#= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:210px'} %> +
  • diff --git a/app/views/student_work/_evaluation_title.html.erb b/app/views/student_work/_evaluation_title.html.erb index 55e1b57c1..094df203e 100644 --- a/app/views/student_work/_evaluation_title.html.erb +++ b/app/views/student_work/_evaluation_title.html.erb @@ -33,7 +33,7 @@ <%= render :partial => "evaluation_work", :locals => {:student_work => student_work, :index => i}%> -
    +
    diff --git a/app/views/student_work/_evaluation_un_group.html.erb b/app/views/student_work/_evaluation_un_group.html.erb index 05cc7c5c1..9a3364258 100644 --- a/app/views/student_work/_evaluation_un_group.html.erb +++ b/app/views/student_work/_evaluation_un_group.html.erb @@ -1,9 +1,9 @@
    <% @stundet_works.each_with_index do |student_work, i| %> -
    +
    <%= render :partial => 'evaluation_un_group_work', :locals => {:student_work => student_work} %>
    -
    +
    <%= render :partial => 'group_member_work', :locals => {:student_work => student_work} %> diff --git a/app/views/student_work/_evaluation_un_group_member_work.html.erb b/app/views/student_work/_evaluation_un_group_member_work.html.erb index 089365952..efd3440f7 100644 --- a/app/views/student_work/_evaluation_un_group_member_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_member_work.html.erb @@ -4,22 +4,22 @@
    > <%= link_to(image_tag(url_to_avatar(st.user),:width =>"40",:height => "40", :style => "display:block;"),user_activities_path(st.user), :class => "fl") %> <% if !is_expand %> - - + + (组长) -
  • @@ -83,4 +83,11 @@ }).mouseleave(function(){ $("#work_click_<%= st.id%>").hide(); }).mouse; + + $(".syllabus_class_list").mouseenter(function(){ + $(this).css("background-color","#f6fafd"); + }); + $(".syllabus_class_list").mouseleave(function(){ + $(this).css("background-color","#fff"); + }); \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_group_work.html.erb b/app/views/student_work/_evaluation_un_group_work.html.erb index 25b42e5f6..8c18d64c7 100644 --- a/app/views/student_work/_evaluation_un_group_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_work.html.erb @@ -1,7 +1,7 @@
    - + <% if student_work.work_status%> <%=get_status student_work.work_status %> @@ -9,19 +9,18 @@ <% if @homework.homework_detail_group.base_on_project == 1 %> - 关联项目: <% if student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? %> - <%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "width:200px;", :title => "项目名称"%> + <%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fr hidden', :style => "max-width:200px;", :title => "项目名称"%> <% else %> - + <% end %> + 关联项目: <% end %> - 评分
    - 提交时间:<%=format_date(student_work.commit_time) %> -
    + 提交时间:<%=format_date(student_work.commit_time) %> +
    教师:<%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%>
    助教:<%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%>
    <% if @homework.anonymous_comment == 0 %> @@ -69,5 +68,6 @@
    + 评分
    \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb index 4fdd6384f..902c8fa50 100644 --- a/app/views/student_work/_evaluation_un_title.html.erb +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -78,7 +78,7 @@ <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work, :index => i} %> -
    +
    diff --git a/app/views/student_work/_group_member_work.html.erb b/app/views/student_work/_group_member_work.html.erb index bfe25c982..d9a2cf726 100644 --- a/app/views/student_work/_group_member_work.html.erb +++ b/app/views/student_work/_group_member_work.html.erb @@ -2,10 +2,10 @@ <% student_work_groups = @homework.student_works.where("user_id in #{user_ids}").order("created_at asc") %> <% anon_count = student_work.student_works_scores.where(:reviewer_role => 3).group_by(&:user_id).count %> <% student_work_groups.each_with_index do |st, j| %> -
    +
    <%= render :partial => 'evaluation_un_group_member_work', :locals => {:st => st, :anon_count => anon_count} %>
    <% if j != 0 %> -
    +
    <% end %> <% end %> \ No newline at end of file diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index 135da3c0d..d8f36d4ba 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -2,6 +2,7 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0){ $("#about_hwork_<%= @work.id%>").html(""); } else{ + $(".about_hwork").html(""); <% if @homework.homework_type == 2%> $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>"); diff --git a/app/views/syllabuses/_syllabus_course_list.html.erb b/app/views/syllabuses/_syllabus_course_list.html.erb index 8bbbd3cf9..05219f4d0 100644 --- a/app/views/syllabuses/_syllabus_course_list.html.erb +++ b/app/views/syllabuses/_syllabus_course_list.html.erb @@ -75,9 +75,9 @@
    <% else %> -
    - <% if User.current == @syllabus.user %> -

    您建立的课程还未创建班级,请 +

    + <% if User.current.member_of_syl?(@syllabus) %> +

    该课程还未创建班级,请 <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_corange", :target => '_blank'%> ,谢谢啦!

    <% else %> diff --git a/app/views/syllabuses/_syllabus_member_list.html.erb b/app/views/syllabuses/_syllabus_member_list.html.erb index 2a726ac18..84bbe1d01 100644 --- a/app/views/syllabuses/_syllabus_member_list.html.erb +++ b/app/views/syllabuses/_syllabus_member_list.html.erb @@ -13,13 +13,14 @@ + <% count = @members.count %> <% @members.each_with_index do |member, i| %> <% user = member.user %> - <% allow_delete = @syllabus.courses.where(:tea_id => member.user_id).empty? && i != 0 %> + <% allow_delete = is_admin && @syllabus.courses.where(:tea_id => member.user_id).empty? %> <%= member.rank %> - <% if member.rank == 1 %> + <% if user == @syllabus.user %>
    <%= user.show_name %>创建者
    <% else %> <%= user.show_name %> @@ -35,23 +36,20 @@ <%= courses.where("tea_id != #{user.id}").count %> <% if is_admin %> - <% if i == 0 %> -   + <% if user == @syllabus.user %> + <% elsif allow_delete %> + <%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %> <% else %> - <% if allow_delete %> - <%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %> - <% else %> - 删除 - <% end %> - <% if i == 1 %> - <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> - <% elsif i == @members.count - 1 %> - <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> - <% else %> - <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> - <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> - <% end %> + 删除 <% end %> + <% if i != 0 && i < count - 1 %> + <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> + <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> + <% elsif i < count - 1 %> + <%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %> + <% elsif i == count - 1 %> + <%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %> + <% end %> <% end %> diff --git a/app/views/syllabuses/show.html.erb b/app/views/syllabuses/show.html.erb index 03eb3f90a..d3398234a 100644 --- a/app/views/syllabuses/show.html.erb +++ b/app/views/syllabuses/show.html.erb @@ -5,6 +5,7 @@ $(function() { sd_create_editor_from_data(<%= @syllabus.id %>, null, "100%", "<%= @syllabus.class.to_s %>"); showNormalImage('syllabus_description_<%= @syllabus.id %>'); + autoUrl('syllabus_description_<%= @syllabus.id %>'); });