diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a1c7ae875..1623979f0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -604,7 +604,7 @@ class CoursesController < ApplicationController def toggleCourse @course_prefs = Course.find_by_extra(@course.extra) - unless (@course_prefs.student != User.current || User.current.admin?) + unless (User.current.allowed_to?(:as_teacher,@course_prefs) || User.current.admin?) render_403 end end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 0a33ef87a..5324a0d38 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -18,31 +18,31 @@ class HomeworkCommonController < ApplicationController end def new - # @homework_type = "1" - # - # @homework = HomeworkCommon.new - # @homework.safe_attributes = params[:homework_common] - # @homework.late_penalty = 0 - # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.publish_time = Time.now.strftime('%Y-%m-%d') - # - # if @homework_type == "1" - # #匿评作业相关属性 - # @homework_detail_manual = HomeworkDetailManual.new - # @homework_detail_manual.ta_proportion = 0.6 - # @homework_detail_manual.absence_penalty = 0 - # @homework_detail_manual.evaluation_num = 3 - # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') - # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.homework_detail_manual = @homework_detail_manual - # elsif @homework_type == "2" - # #编程作业相关属性 - # @homework_detail_programing = HomeworkDetailPrograming.new - # @homework.homework_detail_programing = @homework_detail_programing - # end - # respond_to do |format| - # format.html - # end + @homework_type = "1" + + @homework = HomeworkCommon.new + @homework.safe_attributes = params[:homework_common] + @homework.late_penalty = 0 + @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.publish_time = Time.now.strftime('%Y-%m-%d') + + if @homework_type == "1" + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 0 + @homework_detail_manual.evaluation_num = 3 + @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') + @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.homework_detail_manual = @homework_detail_manual + elsif @homework_type == "2" + #编程作业相关属性 + @homework_detail_programing = HomeworkDetailPrograming.new + @homework.homework_detail_programing = @homework_detail_programing + end + respond_to do |format| + format.html + end end #新建作业下一步 diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 303e4a213..e0aea0c2e 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -449,6 +449,8 @@ update def stats @project_id = params[:id] @repository_id = @repository.identifier + # 提交次数统计 + @status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id]) render :layout => 'base_projects' end @@ -463,8 +465,6 @@ update data = graph_author_commits_per_month(@repository) when "author_commits_six_month" data = author_commits_six_month(@repository) - when "author_qoc_per_author" - data = graph_author_qoc_per_author(@repository) when "author_code_six_months" data = author_code_six_month(@repository) end @@ -658,7 +658,7 @@ update ) graph.add_data( :data => commits_data, - :title => l(:label_revision_plural) + :title => l(:label_revision_commit_count) ) graph.burn end @@ -694,7 +694,7 @@ update ) graph.add_data( :data => commits_data, - :title => l(:label_revision_plural) + :title => l(:label_revision_commit_count) ) graph.burn end diff --git a/app/views/courses/_new_groups_name.html.erb b/app/views/courses/_new_groups_name.html.erb index 39fa33677..fc2c5a62d 100644 --- a/app/views/courses/_new_groups_name.html.erb +++ b/app/views/courses/_new_groups_name.html.erb @@ -31,7 +31,7 @@ <% if @canShowCode%> <%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, :id => 'update_group_'+group.id.to_s) do %>
<% end %> @@ -47,7 +47,7 @@- <%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %> -
-- <%# 用户每月提交代码次数 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %> -
-- <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_per_month")) %> -
-- <%# 用户每月提交代码量 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_qoc_per_author")) %> -
-- <%# 用户最近六个月的提交次数 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_six_month")) %> -
-- <%# 用户最近一年的提交次数 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_qoc_per_author")) %> -
-- <%# 用户最近六个月的代码量 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_code_six_months")) %> -
-- <%# 用户最近一年的代码量 %> - <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_code_year")) %> -
-<%= link_to l(:button_back), :action => 'show', :id => @project %>
-<% html_title(l(:label_repository), l(:label_statistics)) -%> +<% if @status_commit_count ==0 %> ++ <%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %> +
++ <%# 用户每月提交代码次数 %> + <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %> +
++ <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_per_month")) %> +
++ <%# 用户最近六个月的提交次数 %> + <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_six_month")) %> +
++ <%# 用户最近六个月的代码量 %> + <%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_code_six_months")) %> +
+<%= link_to l(:button_back), :action => 'show', :id => @project %>
+ <% html_title(l(:label_repository), l(:label_statistics)) -%> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index fc82aea1e..92f6f93e0 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -139,6 +139,14 @@ <% if @homework.homework_type == 2 && @homework.homework_detail_programing%>+ 输入 + | ++ 输出 + | +
@@ -151,8 +159,20 @@ <% end%> |