parent
4f5fe52485
commit
6a86e1c386
|
@ -1,17 +1,4 @@
|
|||
|
||||
<script type=" text/javascript" charset="utf-8">
|
||||
function change_pic(id){
|
||||
var classname = document.getElementById(id).className
|
||||
if(classname == 'st_up') {
|
||||
document.getElementById(id).className = 'st_down';
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById(id).className = 'st_up';
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div style="margin-left: 15px" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
|
||||
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
|
||||
<% if !@canShowCode %>
|
||||
|
@ -38,9 +25,13 @@
|
|||
<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)) ,:result => members,method: 'get', remote: true, :onclick => "change_pic('pic')"%>
|
||||
<a id="pic" 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)) ,:result => members,method: 'get', remote: true%>
|
||||
<% if @score_sort_by == 'desc' %>
|
||||
<a id="pic" href="#" class= "st_down"></a>
|
||||
<% else %>
|
||||
<a id="pic" href="#" class= "st_up"></a>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="ml50">
|
||||
<a href="#" >加入时间</a>
|
||||
</li>
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
class CreateSelectMemberScore < ActiveRecord::Migration
|
||||
def up
|
||||
sql_delete = ("DROP PROCEDURE IF EXISTS `member_score`;")
|
||||
sql = ("CREATE PROCEDURE `member_score`(IN courseid INT, IN groupid INT,IN start_from INT, IN nums INT, IN sort_by VARCHAR(10))
|
||||
BEGIN
|
||||
|
||||
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS mems (
|
||||
id INT ,
|
||||
user_id INT,
|
||||
course_id INT,
|
||||
created_on DATETIME,
|
||||
course_group_id INT,
|
||||
score FLOAT DEFAULT 0
|
||||
);
|
||||
TRUNCATE TABLE mems;
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS mem_home (
|
||||
id INT,
|
||||
user_id INT,
|
||||
course_id INT,
|
||||
created_on DATETIME,
|
||||
course_group_id INT,
|
||||
home_id INT,
|
||||
score FLOAT DEFAULT 0
|
||||
);
|
||||
TRUNCATE TABLE mem_home;
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS t_scores (
|
||||
|
||||
home_id INT,
|
||||
score FLOAT
|
||||
);
|
||||
TRUNCATE TABLE t_scores;
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS s_scores (
|
||||
|
||||
home_id INT,
|
||||
score FLOAT
|
||||
);
|
||||
TRUNCATE TABLE s_scores;
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS scores (
|
||||
|
||||
user_id INT,
|
||||
score FLOAT
|
||||
);
|
||||
TRUNCATE TABLE scores;
|
||||
|
||||
|
||||
|
||||
INSERT INTO mems (id, user_id, course_id, created_on, course_group_id)
|
||||
(SELECT members.id, members.user_id, members.course_id, members.created_on, members.course_group_id
|
||||
FROM members,students_for_courses WHERE members.course_id = courseid
|
||||
AND members.course_id = students_for_courses.course_id AND members.user_id =students_for_courses.student_id);
|
||||
|
||||
INSERT INTO mem_home (id, user_id, course_id, created_on, course_group_id,home_id)
|
||||
(SELECT members.id, members.user_id, members.course_id, members.created_on, members.course_group_id, homework_attaches.id
|
||||
FROM members, homework_attaches WHERE course_id = courseid
|
||||
AND members.user_id = homework_attaches.user_id AND members.user_id IN (SELECT student_id FROM students_for_courses WHERE course_id = courseid)
|
||||
AND homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses WHERE course_id = courseid ));
|
||||
|
||||
INSERT INTO t_scores (home_id, score) (SELECT rateable_id,AVG(seems_rateable_rates.stars)
|
||||
FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id IN (SELECT mem_home.home_id FROM mem_home)
|
||||
AND is_teacher_score = 1
|
||||
GROUP BY rateable_id);
|
||||
|
||||
INSERT INTO s_scores (home_id, score) (SELECT rateable_id,AVG(seems_rateable_rates.stars)
|
||||
FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id IN (SELECT mem_home.home_id FROM mem_home)
|
||||
AND is_teacher_score = 0
|
||||
GROUP BY rateable_id) ;
|
||||
|
||||
UPDATE mem_home, t_scores SET mem_home.score = t_scores.score WHERE mem_home.home_id = t_scores.home_id ;
|
||||
|
||||
UPDATE mem_home, s_scores SET mem_home.score = s_scores.score WHERE mem_home.home_id = s_scores.home_id AND mem_home.score = 0;
|
||||
|
||||
INSERT INTO scores (user_id, score) (SELECT user_id, SUM(score) FROM mem_home GROUP BY user_id);
|
||||
UPDATE mems, scores SET mems.score = scores.score WHERE mems.user_id = scores.user_id;
|
||||
IF sort_by = '' OR sort_by = 'desc' THEN
|
||||
IF groupid <> 0 THEN
|
||||
SELECT * FROM mems WHERE course_group_id = groupid ORDER BY score ;
|
||||
ELSE
|
||||
SELECT * FROM mems ORDER BY score DESC LIMIT start_from, nums ;
|
||||
END IF;
|
||||
ELSE
|
||||
IF groupid <> 0 THEN
|
||||
SELECT * FROM mems WHERE course_group_id = groupid ORDER BY score ASC ;
|
||||
ELSE
|
||||
SELECT * FROM mems ORDER BY score ASC LIMIT start_from, nums;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
")
|
||||
execute(sql_delete)
|
||||
execute(sql)
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20141230011546) do
|
||||
ActiveRecord::Schema.define(:version => 20141230034253) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue