<commit_before><?php
require_once "../../config.php";
require_once $CFG->dirroot."/pdo.php";
require_once $CFG->dirroot."/lib/lms_lib.php";
require_once $CFG->dirroot."/core/blob/blob_util.php";
require_once "peer_util.php";

session_start();

// Sanity checks
$LTI = requireData(array('user_id', 'link_id', 'role','context_id'));
$instructor = isInstructor($LTI);
if ( ! $instructor ) die("Requires instructor role");
$p = $CFG->dbprefix;

// Gets counts and max of the submissions
$query_parms = array(":LID" => $LTI['link_id']);
$orderfields = array("S.user_id", "displayname", "email", "user_key", "max_points", "min_points","count_points");
$searchfields = array("S.user_id", "displayname", "email", "user_key");

// Note that inner where is lower case and outer WHERE is upper case on purpose
$sql = 
    "SELECT S.user_id AS user_id, displayname, email, S.submit_id as _submit_id, 
        MAX(points) as max_score, MIN(points) AS min_score, COUNT(points) as scores, 
        COUNT(DISTINCT flag_id) as flagged, C.grade_count as grade_count, user_key
    FROM {$p}peer_assn AS A JOIN {$p}peer_submit as S 
        ON A.assn_id = S.assn_id
    LEFT JOIN {$p}peer_grade AS G 
        ON S.submit_id = G.submit_id
    LEFT JOIN {$p}peer_flag AS F 
        ON S.submit_id = F.submit_id<commit_msg>Adjust the sorting HTML when we are using a file other than index.php<commit_after><?php
require_once "../../config.php";
require_once $CFG->dirroot."/pdo.php";
require_once $CFG->dirroot."/lib/lms_lib.php";
require_once $CFG->dirroot."/core/blob/blob_util.php";
require_once "peer_util.php";

session_start();

// Sanity checks
$LTI = requireData(array('user_id', 'link_id', 'role','context_id'));
$instructor = isInstructor($LTI);
if ( ! $instructor ) die("Requires instructor role");
$p = $CFG->dbprefix;

// Gets counts and max of the submissions
$query_parms = array(":LID" => $LTI['link_id']);
$orderfields =  array("S.user_id", "displayname", "email", "S.updated_at", "user_key", "max_points", "min_points","count_points");
$searchfields = array("S.user_id", "displayname", "email", "S.updated_at", "user_key");

// Note that inner where is lower case and outer WHERE is upper case on purpose
$sql = 
    "SELECT S.user_id AS user_id, displayname, email, S.submit_id as _submit_id, 
        MAX(points) as max_score, MIN(points) AS min_score, COUNT(points) as scores, 
        COUNT(DISTINCT flag_id) as flagged, C.grade_count as grade_count, 
        MAX(S.updated_at) AS updated_at, user_key
    FROM {$p}peer_assn AS A JOIN {$p}peer_submit as S 
        ON A.assn_id = S.assn_id
    LEFT JOIN {$p}peer_grade AS G 
        ON S.submit_id = G.submit_id
    LEFT JOIN {$p}peer_flag AS F 
        ON S.submit_id = F.submit_id
{'fraction_non_alphanumeric': 0.15049432442328817, 'fraction_numerical': 0.0, 'mean_word_length': 4.315175097276264, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4852208', 'n_tokens_mistral': 983, 'n_tokens_neox': 954, 'n_words': 252}