diff --git a/queries/get_practice_problems b/queries/get_practice_problems index 01e3feaf2..51d92b6b1 100644 --- a/queries/get_practice_problems +++ b/queries/get_practice_problems @@ -1,11 +1,11 @@ SELECT SKIP @firstRowIndex@ FIRST @pageSize@ -* +* FROM table(MULTISET( SELECT p.problem_id -, c.component_id +, c.component_id , ro.room_id , rc.round_id , rc.division_id @@ -16,63 +16,18 @@ SELECT WHEN (p.problem_type_id = 1 AND p.proposed_difficulty_id = 3) THEN 'Hard'::nvarchar(50) END AS difficulty , rc.points -, NVL(CASE WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id < 120 - AND cs.component_id = c.component_id - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id < 120 - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ) THEN 'New'::nvarchar(50) - WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id = 150 - AND cs.component_id = c.component_id - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id = 150 - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ) THEN 'Solved'::nvarchar(50) - WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id >= 120 - AND cs.component_id = c.component_id - AND cs.status_id != 150 - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id >= 120 - AND pcs.component_id = c.component_id - AND pcs.status_id != 150 - AND pcs.coder_id = @userId@ - ) THEN 'Viewed'::nvarchar(50) - END, 'New') AS status -, NVL(( - SELECT - points - FROM practice_component_state pcs - WHERE pcs.round_id = rc.round_id - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ), 0) AS my_points +, NVL( CASE WHEN pcs.status_id < 120 THEN 'New'::nvarchar(50) + WHEN pcs.status_id = 150 THEN 'Solved'::nvarchar(50) + WHEN pcs.status_id >= 120 AND pcs.status_id != 150 THEN 'Viewed'::nvarchar(50) + END, 'New') AS status +, NVL(pcs.points, 0) AS my_points FROM problem p +INNER JOIN problem_type_lu ptl ON ptl.problem_type_id = p.problem_type_id INNER JOIN component c ON c.problem_id = p.problem_id INNER JOIN round_component rc ON rc.component_id = c.component_id -INNER JOIN round r ON r.round_id = rc.round_id AND r.status = 'A' +INNER JOIN round r ON r.round_id = rc.round_id AND r.status = 'A' AND r.round_type_id = 3 INNER JOIN room ro ON ro.round_id = rc.round_id AND ro.room_type_id = 3 -- practice room -INNER JOIN problem_type_lu ptl ON ptl.problem_type_id = p.problem_type_id -WHERE p.status_id = 90 +LEFT JOIN practice_component_state pcs ON pcs.round_id = rc.round_id AND pcs.component_id = c.component_id AND pcs.coder_id = @userId@ )) srp WHERE 1=1 ORDER BY @sortColumn@ @sortOrder@ diff --git a/queries/get_practice_problems_count b/queries/get_practice_problems_count index b447e2ea7..a6017b30c 100644 --- a/queries/get_practice_problems_count +++ b/queries/get_practice_problems_count @@ -13,62 +13,17 @@ SELECT WHEN (p.problem_type_id = 1 AND p.proposed_difficulty_id = 3) THEN 'Hard'::nvarchar(50) END AS difficulty , rc.points -, NVL(CASE WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id < 120 - AND cs.component_id = c.component_id - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id < 120 - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ) THEN 'New'::nvarchar(50) - WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id = 150 - AND cs.component_id = c.component_id - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id = 150 - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ) THEN 'Solved'::nvarchar(50) - WHEN EXISTS ( - SELECT 1 - FROM component_state cs - WHERE cs.status_id >= 120 - AND cs.component_id = c.component_id - AND cs.status_id != 150 - AND cs.coder_id = @userId@ - UNION ALL - SELECT 1 - FROM practice_component_state pcs - WHERE pcs.status_id >= 120 - AND pcs.component_id = c.component_id - AND pcs.status_id != 150 - AND pcs.coder_id = @userId@ - ) THEN 'Viewed'::nvarchar(50) - END, 'New') AS status -, NVL(( - SELECT - points - FROM practice_component_state pcs - WHERE pcs.round_id = rc.round_id - AND pcs.component_id = c.component_id - AND pcs.coder_id = @userId@ - ), 0) AS my_points +, NVL( CASE WHEN pcs.status_id < 120 THEN 'New'::nvarchar(50) + WHEN pcs.status_id = 150 THEN 'Solved'::nvarchar(50) + WHEN pcs.status_id > 120 AND pcs.status_id != 150 THEN 'Viewed'::nvarchar(50) + END, 'New') AS status +, NVL(pcs.points, 0) AS my_points FROM problem p +INNER JOIN problem_type_lu ptl ON ptl.problem_type_id = p.problem_type_id INNER JOIN component c ON c.problem_id = p.problem_id INNER JOIN round_component rc ON rc.component_id = c.component_id -INNER JOIN round r ON r.round_id = rc.round_id AND r.status = 'A' +INNER JOIN round r ON r.round_id = rc.round_id AND r.status = 'A' AND r.round_type_id = 3 INNER JOIN room ro ON ro.round_id = rc.round_id AND ro.room_type_id = 3 -- practice room -INNER JOIN problem_type_lu ptl ON ptl.problem_type_id = p.problem_type_id -WHERE p.status_id = 90 +LEFT JOIN practice_component_state pcs ON pcs.round_id = rc.round_id AND pcs.component_id = c.component_id AND pcs.coder_id = @userId@ )) srp WHERE 1=1 diff --git a/test/sqls/srmPracticeProblems/informixoltp__insert_test_data b/test/sqls/srmPracticeProblems/informixoltp__insert_test_data index fade3ca15..a7894cb14 100644 --- a/test/sqls/srmPracticeProblems/informixoltp__insert_test_data +++ b/test/sqls/srmPracticeProblems/informixoltp__insert_test_data @@ -4,7 +4,7 @@ INSERT INTO component(component_id, problem_id, result_type_id, method_name, cla INSERT INTO component(component_id, problem_id, result_type_id, method_name, class_name, component_type_id, status_id) VALUES (3002, 2001, 1, 'method_2', 'TestProblem', 2, 1); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4001, "SRM 4001", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5001, 4001, "Practice 4001", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5001, 4001, "Practice 4001", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5001, 5001, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5001, 3001, 2, 1, 500); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7001, 5001, 132456, 3001, 0, 120, 1); @@ -12,7 +12,7 @@ INSERT INTO practice_component_state(component_state_id, round_id, coder_id, com INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(5001, 1, '2014-09-20 00:00:00', '2014-09-21 00:00:00', 'P'); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4002, "SRM 4002", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5002, 4002, "Practice 4002", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5002, 4002, "Practice 4002", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5002, 5002, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5002, 3001, 2, 1, 250); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7003, 5002, 132456, 3001, 200, 150, 1); @@ -20,7 +20,7 @@ INSERT INTO practice_component_state(component_state_id, round_id, coder_id, com INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(5002, 1, '2014-09-15 00:00:00', '2014-09-18 00:00:00', 'P'); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4003, "SRM 4003", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5003, 4003, "Practice 4003", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5003, 4003, "Practice 4003", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5003, 5003, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5003, 3002, 2, 1, 400); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7005, 5003, 132456, 3002, 100, 150, 1); @@ -28,7 +28,7 @@ INSERT INTO practice_component_state(component_state_id, round_id, coder_id, com INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(5003, 1, '2014-09-25 00:00:00', '2014-09-26 00:00:00', 'P'); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4004, "SRM 4004", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5004, 4004, "Practice 4004", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5004, 4004, "Practice 4004", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5004, 5004, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5004, 3002, 2, 1, 300); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7007, 5004, 132456, 3002, 50, 150, 1); @@ -41,7 +41,7 @@ INSERT INTO problem(problem_id, name, status_id, problem_type_id, proposed_diffi INSERT INTO component(component_id, problem_id, result_type_id, method_name, class_name, component_type_id, status_id) VALUES (3003, 2002, 18, 'method_2', 'problem_class2', 1, 1); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4005, "SRM 4005", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5005, 4005, "Practice 4005", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5005, 4005, "Practice 4005", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5005, 5005, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5005, 3003, 2, 1, 200); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7009, 5005, 132456, 3003, 0, 120, 1); @@ -55,7 +55,7 @@ INSERT INTO component(component_id, problem_id, result_type_id, method_name, cla INSERT INTO component(component_id, problem_id, result_type_id, method_name, class_name, component_type_id, status_id) VALUES (3005, 2003, 1, 'method_4', 'TestProblem', 2, 1); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4006, "SRM 4006", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5006, 4006, "Practice 4006", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5006, 4006, "Practice 4006", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5006, 5006, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5006, 3004, 2, 1, 100); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7011, 5006, 132456, 3004, 80, 150, 1); @@ -63,7 +63,7 @@ INSERT INTO practice_component_state(component_state_id, round_id, coder_id, com INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(5006, 1, '2014-09-20 00:00:00', '2014-09-21 00:00:00', 'P'); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4007, "SRM 4007", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5007, 4007, "Practice 4007", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5007, 4007, "Practice 4007", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5007, 5007, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5007, 3005, 2, 1, 450); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7013, 5007, 132456, 3005, 100, 150, 1); @@ -79,14 +79,14 @@ INSERT INTO component(component_id, problem_id, result_type_id, method_name, cla INSERT INTO contest (contest_id, name, status, group_id) VALUES (4008, "SRM 4008", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5008, 4008, "Practice 4008", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5008, 4008, "Practice 4008", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5008, 5008, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5008, 3006, 2, 1, 100); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7015, 5008, 132456, 3006, 80, 150, 1); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id, submission_number) VALUES(7016, 5008, 132457, 3006, 0, 130, 1, 001); INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VALUES(5008, 1, '2014-09-20 00:00:00', '2014-09-21 00:00:00', 'P'); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5009, 4008, "Practice 4008", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5009, 4008, "Practice 4008", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5009, 5009, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5009, 3006, 2, 1, 100); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7017, 5009, 132456, 3006, 80, 150, 1); @@ -95,7 +95,7 @@ INSERT INTO round_segment(round_id, segment_id, start_time, end_time, status) VA INSERT INTO contest (contest_id, name, status, group_id) VALUES (4009, "SRM 4009", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5010, 4009, "Practice 4009", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5010, 4009, "Practice 4009", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5010, 5010, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5010, 3007, 2, 1, 450); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7019, 5010, 132456, 3007, 100, 150, 1); @@ -108,7 +108,7 @@ INSERT INTO problem(problem_id, name, status_id, problem_type_id, proposed_diffi INSERT INTO component(component_id, problem_id, result_type_id, method_name, class_name, component_type_id, status_id) VALUES (3008, 2005, 18, 'method_2', 'problem_class2', 1, 1); INSERT INTO contest (contest_id, name, status, group_id) VALUES (4010, "SRM 4010", "A", -1); -INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5011, 4010, "Practice 4010", "A", 2, 0); +INSERT INTO round (round_id, contest_id, name, status, round_type_id, rated_ind) VALUES (5011, 4010, "Practice 4010", "A", 3, 0); INSERT INTO room(room_id, round_id, name, room_type_id) VALUES(5011, 5011, 'room ', 3); INSERT INTO round_component(round_id, component_id, difficulty_id, division_id, points) VALUES(5011, 3008, 2, 1, 200); INSERT INTO practice_component_state(component_state_id, round_id, coder_id, component_id, points, status_id, language_id) VALUES(7020, 5011, 132456, 3008, 0, 110, 1); diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_1.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_1.json index 87620ccc3..b57260226 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_1.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_1.json @@ -20,7 +20,7 @@ "problemType": "Long", "problemId": 2001, "componentId": 3001, - "status": "Solved", + "status": "Viewed", "roundId": 5001, "roomId": 5001, "problemName": "Problem 2001", diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_11.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_11.json index 251b12046..95a483c49 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_11.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_11.json @@ -8,7 +8,7 @@ "problemType": "Long", "problemId": 2001, "componentId": 3001, - "status": "Solved", + "status": "Viewed", "roundId": 5001, "roomId": 5001, "problemName": "Problem 2001", diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_2.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_2.json index 00e6c2dbd..ab83f415b 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_2.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_2.json @@ -32,7 +32,7 @@ "problemType": "Long", "problemId": 2001, "componentId": 3002, - "status": "Solved", + "status": "Viewed", "roundId": 5003, "roomId": 5003, "problemName": "Problem 2001", diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_3.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_3.json index 11299fc6d..278af8359 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_3.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_3.json @@ -8,7 +8,7 @@ "problemType": "Long", "problemId": 2001, "componentId": 3001, - "status": "Solved", + "status": "Viewed", "roundId": 5001, "roomId": 5001, "problemName": "Problem 2001", diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_8.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_8.json index 97f6575c5..43b08499c 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_8.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_8.json @@ -20,7 +20,7 @@ "problemType": "Long", "problemId": 2001, "componentId": 3001, - "status": "Solved", + "status": "Viewed", "roundId": 5001, "roomId": 5001, "problemName": "Problem 2001", diff --git a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_9.json b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_9.json index bb49a945a..39581312b 100644 --- a/test/test_files/srmPracticeProblems/expected_srm_practice_problems_9.json +++ b/test/test_files/srmPracticeProblems/expected_srm_practice_problems_9.json @@ -1,8 +1,20 @@ { "pageIndex": 1, "pageSize": 10, - "total": 1, + "total": 0, "data": [ + { + "myPoints": 0, + "problemType": "Long", + "problemId": 2001, + "componentId": 3001, + "status": "Viewed", + "roundId": 5001, + "roomId": 5001, + "problemName": "Problem 2001", + "points": 500, + "divisionId": 1 + }, { "myPoints": 0, "problemType": "Single",