Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
daiao 2016-08-05 19:02:41 +08:00
commit 85c16ca9e8
14 changed files with 81 additions and 63 deletions

View File

@ -58,9 +58,10 @@ class HomeworkCommonController < ApplicationController
def edit def edit
@user = User.current @user = User.current
@is_in_course = params[:is_in_course].to_i @is_in_course = params[:is_in_course]
@is_manage = params[:is_manage]
@course_activity = params[:course_activity].to_i @course_activity = params[:course_activity].to_i
if @is_in_course == 1 || @course_activity == 1 if @is_in_course.to_i == 1 || @course_activity == 1
@left_nav_type = 3 @left_nav_type = 3
respond_to do |format| respond_to do |format|
format.html{render :layout => 'base_courses'} format.html{render :layout => 'base_courses'}
@ -144,7 +145,11 @@ class HomeworkCommonController < ApplicationController
@homework_detail_programing.save if @homework_detail_programing @homework_detail_programing.save if @homework_detail_programing
@homework_detail_group.save if @homework_detail_group @homework_detail_group.save if @homework_detail_group
if params[:is_in_course] == "1" if params[:is_manage] == "1"
redirect_to manage_or_receive_homeworks_user_path(User.current.id)
elsif params[:is_manage] == "2"
redirect_to my_homeworks_user_path(User.current.id)
elsif params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => @course.id) redirect_to homework_common_index_path(:course => @course.id)
elsif params[:is_in_course] == "0" elsif params[:is_in_course] == "0"
redirect_to user_homeworks_user_path(User.current.id) redirect_to user_homeworks_user_path(User.current.id)

View File

@ -775,30 +775,33 @@ class StudentWorkController < ApplicationController
end end
def retry_work def retry_work
if @work.destroy if @homework.homework_type == 3
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 if @work.destroy
pros = @work.student_work_projects.where("is_leader = 0") if @homework.homework_detail_group.base_on_project == 1
pros.each do |pro| pros = @work.student_work_projects.where("is_leader = 0")
pro.destroy pros.each do |pro|
end pro.destroy
project = @work.student_work_projects.where("is_leader = 1").first end
project.update_attributes(:student_work_id => nil) project = @work.student_work_projects.where("is_leader = 1").first
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 project.update_attributes(:student_work_id => nil)
@work.student_work_projects.each do |pro2| elsif @homework.homework_detail_group.base_on_project == 0
pro2.destroy @work.student_work_projects.each do |pro2|
pro2.destroy
end
end end
end end
@student_work = StudentWork.new elsif @homework.homework_type == 1
respond_to do |format| @work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0)
format.js end
end @student_work = StudentWork.new
respond_to do |format|
format.js
end end
end end
#添加评分,已评分则为修改评分 #添加评分,已评分则为修改评分
def add_score def add_score
@is_last = params[:is_last] == "true" @is_last = params[:is_last] == "true"
render_403 and return if User.current == @work.user #不可以匿评自己的作品
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2 render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2

View File

@ -1,6 +1,6 @@
#学生提交作品表 #学生提交作品表
class StudentWork < ActiveRecord::Base class StudentWork < ActiveRecord::Base
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value, :work_status
belongs_to :homework_common belongs_to :homework_common
belongs_to :user belongs_to :user

View File

@ -1,5 +1,5 @@
<script type="text/javascript"> <script type="text/javascript">
<% if @is_in_course == 1 || @course_activity == 1 %> <% if @is_in_course.to_i == 1 || @course_activity == 1 %>
$(function(){ $(function(){
$("#RSide").removeAttr("id"); $("#RSide").removeAttr("id");
$("#Container").css("width","1000px"); $("#Container").css("width","1000px");
@ -19,13 +19,17 @@
$("#homework_editor").toggle(); $("#homework_editor").toggle();
} }
function cancel_edit(){ function cancel_edit(){
<% if @is_in_course == 1 %> <% if @is_manage.to_i == 1 %>
window.location.href='<%=manage_or_receive_homeworks_user_path(User.current.id) %>';
<% elsif @is_manage.to_i == 2 %>
window.location.href='<%=my_homeworks_user_path(User.current.id) %>';
<% elsif @is_in_course.to_i == 1 %>
window.location.href='<%=homework_common_index_path(:course => @course.id) %>'; window.location.href='<%=homework_common_index_path(:course => @course.id) %>';
<% elsif @is_in_course == 0 %> <% elsif @is_in_course.to_i == 0 %>
window.location.href='<%=user_homeworks_user_path(User.current.id) %>'; window.location.href='<%=user_homeworks_user_path(User.current.id) %>';
<% elsif @is_in_course == -1 && @course_activity == 0 %> <% elsif @is_in_course.to_i == -1 && @course_activity == 0 %>
window.location.href='<%=user_path(User.current.id) %>'; window.location.href='<%=user_path(User.current.id) %>';
<% elsif @is_in_course == -1 && @course_activity == 1 %> <% elsif @is_in_course.to_i == -1 && @course_activity == 1 %>
window.location.href='<%=course_path(@course.id) %>'; window.location.href='<%=course_path(@course.id) %>';
<% end %> <% end %>
} }
@ -40,6 +44,7 @@
<%= form_for @homework do |f| %> <%= form_for @homework do |f| %>
<input type="text" name="is_in_course" class="none" value="<%= @is_in_course%>"/> <input type="text" name="is_in_course" class="none" value="<%= @is_in_course%>"/>
<input type="text" name="course_activity" class="none" value="<%= @course_activity%>"/> <input type="text" name="course_activity" class="none" value="<%= @course_activity%>"/>
<input type="text" name="is_manage" class="none" value="<%= @is_manage%>"/>
<div id="HomeWorkCon"> <div id="HomeWorkCon">
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> <%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
</div> </div>

View File

@ -9,35 +9,42 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div> <div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<div class="mt10 mb15"> <div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span> 请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<div class="merge-commit-option mt15">
<% if @commits_count == 0 && @changes_count == 0 %> <% if @commits_count == 0 && @changes_count == 0 %>
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br /> <div class="merge-commit-option mt15">
<p class="fontGrey2 mt5">请将新改动提交至源分支或者切换到其它目标分支</p> <span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
<% else %> <p class="fontGrey2 mt5">请将新改动提交至源分支或者切换到其它目标分支</p>
<% if @request.state == "merged" %> </div>
<span class="fontGrey3 fb" style="font-size:13px;"><a href="javascript:void(0);" class="link-blue"> Hjqreturn</a>于两小时前合并</span><br /> </div>
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
<% else %> <% else %>
<% if @request.state == "merged" %>
<div class="merge-commit-option mt15">
<span class="fontGrey3 fb" style="font-size:13px;"><a href="javascript:void(0);" class="link-blue"> <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %></a>于<%= time_tag(@request.created_at) %> 前合并</span><br />
<p class="fontGrey2 mt5">改动已合并至<%= @request.target_branch %></p>
</div>
<% else %>
<% if is_project_manager?(User.current.id, @project.id) %> <% if is_project_manager?(User.current.id, @project.id) %>
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn", :remote => true %> <div class="merge-commit-option mt15">
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn", :remote => true %>
</div>
<% end %> <% end %>
<% end %>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
<% end %> <% end %>
</div>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
<% end %>
</div> </div>

View File

@ -34,7 +34,7 @@
</p> </p>
</div> </div>
<% if homework.student_works.has_committed.count == 0 %> <% if homework.student_works.has_committed.count == 0 %>
<%= link_to '编&nbsp;&nbsp;&nbsp;&nbsp;辑'.html_safe, edit_homework_common_path(homework), :class => 'hw_btn_green fr mt5', :target => '_blank' %> <%= link_to '编&nbsp;&nbsp;&nbsp;&nbsp;辑'.html_safe, edit_homework_common_path(homework, :is_manage => is_manage), :class => 'hw_btn_green fr mt5', :target => '_blank' %>
<% else %> <% else %>
<%= link_to '评&nbsp;&nbsp;&nbsp;&nbsp;分'.html_safe, student_work_index_path(:homework => homework.id), :class => 'hw_btn_green fr mt5', :target => '_blank' %> <%= link_to '评&nbsp;&nbsp;&nbsp;&nbsp;分'.html_safe, student_work_index_path(:homework => homework.id), :class => 'hw_btn_green fr mt5', :target => '_blank' %>
<% end %> <% end %>

View File

@ -2,10 +2,10 @@
<span class="sy_cgrey fl"><%= @manage_pre ? '我管理的作业:' : '我收到的的作业:' %></span> <span class="sy_cgrey fl"><%= @manage_pre ? '我管理的作业:' : '我收到的的作业:' %></span>
<%= link_to '查看更多', @manage_pre ? manage_or_receive_homeworks_user_path(@user) : manage_or_receive_homeworks_user_path(@user, :type =>2), :class => 'sy_cgrey fr mr15' %> <%= link_to '查看更多', @manage_pre ? manage_or_receive_homeworks_user_path(@user) : manage_or_receive_homeworks_user_path(@user, :type =>2), :class => 'sy_cgrey fr mr15' %>
</div> </div>
<%= render :partial => "#{@manage_pre ? 'manage_homework_list' : 'receive_homework_list'}", :locals => {:homeworks => @manage_pre ? @manage_homeworks : @receive_homeworks} %> <%= render :partial => "#{@manage_pre ? 'manage_homework_list' : 'receive_homework_list'}", :locals => {:homeworks => @manage_pre ? @manage_homeworks : @receive_homeworks, :is_manage => 2} %>
<div class="hw_tab_top clear"> <div class="hw_tab_top clear">
<span class="sy_cgrey fl"><%= @manage_pre ? '我收到的的作业:' : '我管理的作业:' %></span> <span class="sy_cgrey fl"><%= @manage_pre ? '我收到的的作业:' : '我管理的作业:' %></span>
<%= link_to '查看更多', @manage_pre ? manage_or_receive_homeworks_user_path(@user, :type =>2) : manage_or_receive_homeworks_user_path(@user), :class => 'sy_cgrey fr mr15' %> <%= link_to '查看更多', @manage_pre ? manage_or_receive_homeworks_user_path(@user, :type =>2) : manage_or_receive_homeworks_user_path(@user), :class => 'sy_cgrey fr mr15' %>
</div> </div>
<%= render :partial => "#{@manage_pre ? 'receive_homework_list' : 'manage_homework_list'}", :locals => {:homeworks => @manage_pre ? @receive_homeworks : @manage_homeworks} %> <%= render :partial => "#{@manage_pre ? 'receive_homework_list' : 'manage_homework_list'}", :locals => {:homeworks => @manage_pre ? @receive_homeworks : @manage_homeworks, :is_manage => 2} %>

View File

@ -8,7 +8,7 @@
<%# else %> <%# else %>
<% if params[:is_observe].nil? %> <% if params[:is_observe].nil? %>
var htmlvalue = "<%= escape_javascript(render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>"; var htmlvalue = "<%= escape_javascript(render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>";
pop_box_new(htmlvalue,460,50,50); pop_box_new(htmlvalue,460,435);
<% else %> <% else %>
$("#send_homework_to_course_form").html("<%= escape_javascript(render :partial => 'users/send_homework_to_course_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>"); $("#send_homework_to_course_form").html("<%= escape_javascript(render :partial => 'users/send_homework_to_course_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>");
<% end %> <% end %>

View File

@ -35,7 +35,7 @@
<div class="sy_classbox" style="min-height:800px;" id="my_homework_list"> <div class="sy_classbox" style="min-height:800px;" id="my_homework_list">
<% if @type == 1 %> <% if @type == 1 %>
<%= render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks} %> <%= render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks, :is_manage => 1} %>
<% else %> <% else %>
<%= render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks} %> <%= render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks} %>
<% end %> <% end %>

View File

@ -1,5 +1,5 @@
<% if @type == 1 %> <% if @type == 1 %>
$("#my_homework_list").html('<%= escape_javascript(render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks})%>'); $("#my_homework_list").html('<%= escape_javascript(render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks, :is_manage => 1})%>');
<% else %> <% else %>
$("#my_homework_list").html('<%= escape_javascript(render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks})%>'); $("#my_homework_list").html('<%= escape_javascript(render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks})%>');
<% end %> <% end %>

View File

@ -1,5 +1,5 @@
<% if @type == 1 %> <% if @type == 1 %>
$("#my_homework_list").html('<%= escape_javascript(render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks})%>'); $("#my_homework_list").html('<%= escape_javascript(render :partial => "manage_homework_list", :locals => {:homeworks => @homeworks, :is_manage => 1})%>');
<% else %> <% else %>
$("#my_homework_list").html('<%= escape_javascript(render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks})%>'); $("#my_homework_list").html('<%= escape_javascript(render :partial => "receive_homework_list", :locals => {:homeworks => @homeworks})%>');
<% end %> <% end %>

View File

@ -1,4 +1,4 @@
$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>); $("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>);
hideModal(); hideModal();
var htmlvalue = "<%= escape_javascript(render :partial => 'homework_post_notice') %>"; var htmlvalue = "<%= escape_javascript(render :partial => 'homework_post_notice') %>";
pop_box_new(htmlvalue,380,40,50); pop_box_new(htmlvalue,380,182);

View File

@ -3,5 +3,5 @@
$("#choose_courses_notice").html(""); $("#choose_courses_notice").html("");
<% else %> <% else %>
var htmlvalue = "<%= escape_javascript(render :partial => 'users/homework_repository_detail') %>"; var htmlvalue = "<%= escape_javascript(render :partial => 'users/homework_repository_detail') %>";
pop_box_new(htmlvalue,820,50,50); pop_box_new(htmlvalue,820,155);
<% end %> <% end %>

View File

@ -1495,7 +1495,7 @@ function pop_up_box(value,tWidth,tTop,tLeft){
// 公共弹框样式 // 公共弹框样式
function pop_box_new(value, Width, Height){ function pop_box_new(value, Width, Height){
w = ($(window).width() - Width)/2; w = ($(window).width() - Width)/2;
h = ($(window).height() - Height)/2; h = ($(window).height() - Height)/2 - 100;
$("#ajax-modal").html(value); $("#ajax-modal").html(value);
showModal('ajax-modal', Width + 'px'); showModal('ajax-modal', Width + 'px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
@ -1552,9 +1552,7 @@ function pop_box_new(value, Width, Height){
document.onmousemove = null; document.onmousemove = null;
} }
window.onload = function () { new Drag("popupWrap");
new Drag("popupWrap");
}
} }
// 公共提示弹框样式 // 公共提示弹框样式