Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
z9hang 2015-03-26 15:55:21 +08:00
commit 57dad3f3c7
13 changed files with 108 additions and 99 deletions

View File

@ -202,7 +202,7 @@ class CoursesController < ApplicationController
group.course_id = @course.id
group.save
end
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
@is_remote = true
@course_groups = @course.course_groups
@ -236,17 +236,26 @@ class CoursesController < ApplicationController
valid_attr = params[:valid]
valid_value = params[:value]
faker = CourseGroup.new
group_id = params[:group_id]
# faker = CourseGroup.new
if valid_attr.eql?('name')
faker.name = valid_value
faker.course_id = params[:course_id]
faker.valid?
req[:valid] = faker.errors[:name].blank?
req[:message] = faker.errors[:name]
course = Course.find params[:course_id]
group_names = course.course_groups.map{|group| group.name unless group.id.to_s == group_id}.select{|group| !group.nil?}
if group_names.include?(valid_value)
req[:valid] = false
req[:message] = l(:modal_valid_unpassing)
else
req[:valid] = true
req[:message] = l(:modal_valid_passing)
end
# faker.name = valid_value
# faker.course_id = params[:course_id]
# faker.valid?
# req[:valid] = faker.errors[:name].blank?
# req[:message] = faker.errors[:name]
end
req[:message] = l(:modal_valid_passing) if req[:message].blank?
# req[:message] = l(:modal_valid_passing) if req[:message].blank?
render :json => req
end
def join_group
@ -274,7 +283,7 @@ class CoursesController < ApplicationController
end
def searchgroupmembers
@subPage_title = l :label_student_list
@render_file = 'member_list'
@render_file = 'new_member_list'
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true
@score_sort_by = "desc"
@ -293,7 +302,7 @@ class CoursesController < ApplicationController
## 有角色参数的才是课程,没有的就是项目
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@render_file = 'member_list'
@render_file = 'new_member_list'
@score_sort_by = "desc"
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
@role = params[:role].nil? ? '2':params[:role]
@ -337,7 +346,7 @@ class CoursesController < ApplicationController
def member_score_sort
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@subPage_title = l :label_student_list
@render_file = 'member_list'
@render_file = 'new_member_list'
@is_remote = true
@score_sort_by = params[:sort_by] if params[:sort_by]
@search_name = params[:search_name] if params[:search_name]
@ -842,7 +851,7 @@ class CoursesController < ApplicationController
#当加入,退出分班时查询分班的学生
def search_group_members group
@subPage_title = l :label_student_list
@render_file = 'member_list'
@render_file = 'new_member_list'
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true
@score_sort_by = "desc"

View File

@ -1,20 +1,10 @@
<div class="st_list">
<div class="st_search">
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:remote=>true,:id => "search_student") do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'st_search_input', :placeholder => '输入学生姓名、学号进行搜索'%>
<% if @group %>
<%= hidden_field "search_group_id", params[:search_group_id],:value => "#{@group.id}", name: 'search_group_id' %>
<input type="hidden" name="ingroup">
<% else %>
<input type="hidden" name="incourse">
<% end %>
<% end %>
<a href="javascript:" class="f_l" onclick="$('#search_student').submit();">搜索</a>
<%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'),:class=>'xls'%>
<div class="st_search" id="search_members">
<%= render :partial => 'searchmembers' %>
</div>
<div class="cl"></div>
<div class="st_addclass">
<div class="st_addclass" id="st_groups">
<%= render :partial => 'new_groups_name', :locals => {:course_groups => @course_groups} %>
</div>
<div class="cl"></div>

View File

@ -23,7 +23,8 @@
<div class="st_box">
<ul class="st_box_top" style="margin-left: 17px;">
<% if @subPage_title == l(:label_student_list) %>
<li class="ml358"><%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<li class="ml358">
<%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<% if @score_sort_by == 'desc' %>
<a id="pic" href="#" class= "st_down"></a>
<% else %>

View File

@ -1,7 +1,7 @@
<ul>
<li style=" color:#8b8b8b;">分班:</li>
<li class="classbox">
<%= link_to l(:label_all), searchgroupmembers_course_path(@course,:group_id => 0), :onclick => "checkclass('group_name_0')", method: 'get', remote: true%>
<li class="classbox" id="course_group_0">
<%= link_to l(:label_all), searchgroupmembers_course_path(@course,:group_id => 0), :onclick => "checkclass('course_group_0')", method: 'get', remote: true%>
</li>
<% unless course_groups.nil? %>
@ -10,27 +10,31 @@
<li class="classbox" style="margin-bottom: 5px;">
<%= link_to group_name, searchgroupmembers_course_path(@course,:group_id => group.id), method: 'get', remote: true,:onclick => "checkclass('group_name_#{group.id}')"%>
<% if @canShowCode%>
<%= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
:data => {confirm: l(:label_delete_group)},
:class => 'f_1',
:style => "width: 11px;height: 16px;margin-top:3px;margin-left:5px;background: url(/images/pic_del.gif) no-repeat 0 0;"
%>
<% else%>
<a href="javascript:" onClick="alert('温馨提示:已有学生加入该班级,不能删除该班级,仅可编辑班级名称。');" style="margin-right:4px;" >
<img src="/images/pic_del.gif" width="11" height="12" alt="删除班级" title="删除该班级" />
<% if group.members.empty?%>
<%= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
:data => {confirm: l(:label_delete_group)},
:class => 'f_1',
:style => "width: 11px;height: 16px;margin-top:3px;margin-left:5px;background: url(/images/pic_del.gif) no-repeat 0 0;"
%>
<% else%>
<a href="javascript:" onClick="alert('温馨提示:已有学生加入该班级,不能删除该班级,仅可编辑班级名称。');" style="margin-right:4px;" >
<img src="/images/pic_del.gif" width="11" height="12" alt="删除班级" title="删除该班级" />
</a>
<% end%>
<a href="javascript:void(0)" class="f_l" style="padding-left: 5px;" onclick="$('#group_name_<%= group.id %>').val('');$('#edit_group_<%= group.id %>').slideToggle();">
<img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" />
</a>
<% end %>
<a href="javascript:void(0)" class="f_l" style="padding-left: 5px;" onclick="$('#group_name_<%= group.id %>').value='';$('#edit_group_<%= group.id %>').slideToggle();">
<img src="/images/pic_edit.png" width="14" height="15" alt="编辑班级" />
</a>
</li>
<!-- 编辑分班 -->
<li>
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, update: 'group_name') do %>
<span id="edit_group_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
<input type="button" class="submit f_l" onclick="edit_group('edit_group_<%= group.id%>');"/>
</span>
<% if @canShowCode%>
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, :id => 'update_group_'+group.id.to_s) do %>
<span id="edit_group_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
<input type="text" id="group_name_<%= group.id%>" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
<input type="button" class="submit f_l" onclick="edit_group('group_name_<%= group.id%>','<%= valid_ajax_course_path%>','<%= @course.id%>','<%= group.id%>');"/>
</span>
<% end %>
<% end %>
</li>
<% end %>
@ -42,9 +46,9 @@
</li>
<li >
<span id="new_group_name" style="display:none; vertical-align: middle;" class="ml10 f_l">
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true) do %>
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true,:id => 'add_group_name') do %>
<input type="text" id="group_name" name="group_name" size="20" class="isTxt w90 f_l" maxlength="100" />
<input type="button" class="submit f_l" onclick="edit_group('group_name');"/>
<input type="button" class="submit f_l" onclick="add_group('<%= valid_ajax_course_path%>','<%= @course.id%>');"/>
<% end %>
</span>
</li>

View File

@ -24,7 +24,14 @@
<ul class="st_box_top">
<li class="ml50" style="padding-right: 5px;"><a href="">姓名</a></li>
<li class="ml10" style="padding-right: 15px;"><a href="">学号</a></li>
<li class="ml358"><a href="#" >作业积分</a><a href="#" class="st_down"></a></li>
<li class="ml358">
<%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<% if @score_sort_by == 'desc' %>
<a id="pic" href="javascript:" class= "st_down"></a>
<% else %>
<a id="pic" href="javascript:" class= "st_up"></a>
<% end %>
</li>
<li class="ml50"><a href="#" >加入时间</a></li>
</ul>
<div class="cl"></div><!--st_box_top end-->

View File

@ -1,12 +1,11 @@
<% if @subPage_title && @subPage_title == l(:label_student_list)%>
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:style => "margin-left: 5px; ",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'f_1', :style => "height:15px; float: left;"%>
<% if @group %>
<%= hidden_field "search_group_id", params[:search_group_id],:value => "#{@group.id}", name: 'search_group_id' %>
<%= submit_tag l(:label_search_member), :name => "ingroup",:class => "f_2", :style => "float: left "%>
<% else %>
<%= submit_tag l(:label_search_member),:style => "float: left", :name => 'incourse',:onclick => "checkclass('group_name_0')",:class => "f_2"%>
<% end %>
<%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:remote=>true,:id => "search_student") do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'st_search_input', :placeholder => '输入学生姓名、学号进行搜索'%>
<% if @group %>
<%= hidden_field "search_group_id", params[:search_group_id],:value => "#{@group.id}", name: 'search_group_id' %>
<input type="hidden" name="ingroup">
<% else %>
<input type="hidden" name="incourse">
<% end %>
<%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'),:class=>'xls'%>
<% end %>
<% end %>
<a href="javascript:" class="f_l" onclick="$('#search_student').submit();">搜索</a>
<%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'),:class=>'xls'%>

View File

@ -1 +1 @@
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");

View File

@ -1 +1 @@
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");

View File

@ -1,4 +1,4 @@
/**
* Created by Administrator on 2014/12/3.
*/
$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>");
$("#member_content").html("<%= escape_javascript( render :partial => "new_member_list", :locals => {:members => @results})%>");

View File

@ -1,4 +1,4 @@
/**
* Created by Administrator on 2014/12/3.
*/
$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>");
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");

View File

@ -2088,6 +2088,7 @@ zh:
label_open_anonymous_evaluation: 是否匿评
label_evaluation_description: 即每份作业被允许匿评的人数
label_name_not_null: 名称不能为空
modal_valid_unpassing: 该分班已经存在

View File

@ -1,47 +1,45 @@
///////////////////////////////////////////////////////////////
function check_groupname(course_id) {
var $group_name = $('#group_name');
//添加分班
function add_group(url,course_id) {
var group_name = $('#group_name').val();
$.get(
'<%=valid_ajax_course_path%>',
url,
{ valid: "name",
value: document.getElementById('group_name').value,
value: group_name,
course_id: course_id },
function (data) {
if (!data.valid) {
if (data.valid) {
$("#add_group_name").submit();
}
else
{
alert(data.message);
}
});
}
function validate_groupname(value1) {
if(value1.length > 20) {
alert('<%= l(:label_limit_groupname) %>');
}
}
function checkclass(value) {
for(var i = 0; i < document.getElementsByName("check_group_name").length; i++) {
if(document.getElementsByName("check_group_name")[i].id == value) {
document.getElementById(value).className = "selected";
}
else {
document.getElementsByName("check_group_name")[i].className = "classbox";
);
}
//修改分班:修改分班时得考虑什么都不改但是点击确定的情况
function edit_group(id,url,course_id,group_id)
{
var group_name = $('#'+id).val();
$.get(
url,
{
valid: "name",
value: group_name,
course_id: course_id,
group_id: group_id
},
function (data) {
if (data.valid) {
$("#update_group_"+group_id).submit();
}
else
{
alert(data.message);
}
}
}
}
function validate_groupname_null(value1) {
value1 = value1.trim();
if(value1.length == 0 ) {
alert('<%= l(:label_limit_groupname_null) %>');
}
}
function validate_update(name) {
value1 = document.getElementById(name).value;
validate_groupname(value1);
}
function validate_add_group() {
check_groupname();
);
}
///////////////////////////////////////////////////////////////

View File

@ -290,7 +290,7 @@ a.xls{ margin-left:5px; color:#136b3b;}
.st_search{ }
.st_search span{ font-size:14px; font-weight:bold; color:#606060; margin-right:35px;}
.st_search_input{ border:1px solid #1c9ec7; background:#fff; height:20px; color:#c4c4c4; width:200px; padding-left:5px; margin-bottom:5px;}
.st_search a{ background:#1c9ec7; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:45px; height:20px; float:left; font-size:12px; }
.st_search a{ background:#1c9ec7; color:#fff;border:1px solid #1c9ec7; text-align:center; display:block; width:60px; height:20px; float:left; font-size:12px; }
.st_search a:hover{ background:#048fbb; text-decoration:none;}
.classbox{ border:1px solid #f8df8c; background:#fffce6; color:#0d90c3; padding:0 3px; float:left; margin-left:15px;}
.st_addclass{ margin-top:5px;}