wiki:AdminTips

Version 9 (modified by Pan Luo, 12 years ago) ( diff )

--

Database

Find student who saved the evaluation but not submit yet

SET @EVENTID=EVENT_ID;
SELECT * FROM users 
WHERE id IN 
    (SELECT distinct(evaluator) FROM evaluation_mixevals WHERE event_id = @EVENTID AND evaluator NOT IN 
        (SELECT distinct(submitter_id) FROM evaluation_submissions WHERE event_id = @EVENTID)
    );

Replace EVENT_ID to event id.

Submit for those students

SET @EVENTID=EVENT_ID, @COURSEID=COURSE_ID;
INSERT INTO evaluation_submissions 
    SELECT NULL,@EVENTID, group_events.id, user_id,1,NOW(),'A',1,NOW(),NULL,NOW() 
    FROM groups 
    LEFT JOIN groups_members ON groups.id = groups_members.group_id 
    LEFT JOIN group_events ON group_events.group_id = groups.id 
    WHERE
        course_id = @COURSEID
        AND event_id = @EVENTID
        AND user_id IN 
            (SELECT distinct(evaluator) FROM evaluation_mixevals WHERE event_id = @EVENTID AND evaluator NOT IN 
                (SELECT distinct(submitter_id) FROM evaluation_submissions WHERE event_id = @EVENTID)
            );

Replace EVENT_ID to event id and COURSE_ID to course id.

Merge Students with Duplicated Accounts (the accounts starts with "s" and without)

DROP PROCEDURE IF EXISTS merge_students;

delimiter //

CREATE PROCEDURE merge_students()
BEGIN
        DECLARE old, new INT;
        DECLARE done INT DEFAULT FALSE;
        DECLARE cur CURSOR FOR (SELECT u1.id, u2.id FROM users as u1 JOIN users as u2 ON u2.username = CONCAT("s", u1.username) WHERE u1.username REGEXP '[0-9]{8}');
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
        
        OPEN cur;
        
        read_loop: LOOP
                FETCH cur INTO old, new;
                IF done THEN
                        LEAVE read_loop;
                END IF;
          SELECT CONCAT("Merging user ", new, " into ", old) as "";
        update groups_members set user_id = old where user_id = new; 
        update user_enrols set user_id = old where user_id = new; 
        update survey_inputs set user_id = old where user_id = new; 
        update evaluation_submissions set submitter_id = old where submitter_id = new; 
        update evaluation_simples set evaluator = old where evaluator = new; 
        update evaluation_simples set evaluatee = old where evaluatee = new; 
        update evaluation_rubrics set evaluator = old where evaluator = new; 
        update evaluation_rubrics set evaluatee = old where evaluatee = new; 
        update evaluation_mixevals set evaluator = old where evaluator = new; 
        update evaluation_mixevals set evaluatee = old where evaluatee = new; 
        delete from users where id = new;

        END LOOP;
        
        CLOSE cur;
END;

CALL merge_students();

Statistics

New course

select * from courses where created between "2011-09-01 0:0:0" and "2011-12-31 23:59:59";

New evaluation

select * from events where created between "2011-09-01 0:0:0" and "2011-12-31 23:59:59";

New instructor

select * from users where role LIKE "I" AND created between "2011-09-01 0:0:0" and "2011-12-31 23:59:59";

New student

select * from users where role LIKE "S" AND created between "2011-09-01 0:0:0" and "2011-12-31 23:59:59";

Total student

select * from users where role LIKE "S";
Note: See TracWiki for help on using the wiki.