<commit_before><?php 
if (!isset($_REQUEST["questionID"])){
    echo "error";
    die();
}
require dirname(__DIR__) . "/connection.php";
require dirname(__DIR__) . "/language.php";

$questionID = intval($_REQUEST["questionID"]);
$result = $conn->query("SELECT title FROM dsgvo_training_questions WHERE id = $questionID");
$title = $result->fetch_assoc()["title"];
$result = $conn->query(
    "SELECT userID, correct, firstname, lastname, tcq.version, tries, tcq.duration
     FROM dsgvo_training_questions tq 
     INNER JOIN dsgvo_training_completed_questions tcq ON tcq.questionID = tq.id 
     INNER JOIN UserData ON UserData.id = tcq.userID
     WHERE tq.id = $questionID"
);
echo $conn->error;
$nameArray = array();
$triesArray = array();
$timesArray = array();
$triesColorsArray = array();
$timesColorsArray = array();
?>
<form method="POST">
<div class="modal fade">
    <div class="modal-dialog modal-content modal-md">
    <div class="modal-header">Auswertung von <?php echo $title ?></div>
    <div class="modal-body" style="overflow:scroll;">
        <?php
        if(!$result || $result->num_rows == 0){
            echo "Noch keine Daten vorhanden";
        }else{
        ?>
        <table class="table">
            <thead>
                <tr>
                    <th><?php echo $lang['USERS']?></th>
                    <th><?php echo $lang['ANSWER']?></th>
                    <th>Version</th>
                    <th><?php echo $lang['TRIES']?></th>
                </tr>
            </thead>
            <tbody>
       <?php 
            $right = $wrong = $unanswered = 0;
            while($row = $result->fetch_assoc()){
                $name = "${row['firstname']} ${row['lastname']}";
                $correct = $lang['TRAINING_QUESTION_CORRECT'][$row['correct']];
                $tries = $row['tries'];
                $version = $row['version'];
                if($row['correct'] == 'TRUE'){
                    $right++;
                }else{
                    $wrong++;
                }
                $nameArray[] = $name;
                $triesArray[] = $tries;
                $timesArray[] = $row["duration"];
                $triesColorsArray[] = "orange";
                $timesColorsArray[] = "blue";
                echo "<tr>";
                echo "<td>$name</td>";
                echo "<td>$correct</td>";
                echo "<td>$version</td>";
                echo "<td>$tries</td>";
                echo "</tr>";
            }
            $result = $conn->query(
                "SELECT ud.id, firstname, lastname
                 FROM dsgvo_training_questions tq 
                 INNER JOIN UserData ud
                 WHERE tq.id = $questionID AND NOT EXISTS (SELECT questionID FROM dsgvo_training_completed_questions WHERE userID = ud.id AND questionID = tq.id)"
            );
            while($row = $result->fetch_assoc()){
                $name = "${row['firstname']} ${row['lastname']}";
                $unanswered++;
                $correct = $lang['TRAINING_QUESTION_CORRECT']['UNANSWERED'];
                $nameArray[] = $name;
                $triesArray[] = 0;
                $timesArray[] = 0;
                $triesColorsArray[] = "orange";
                $timesColorsArray[] = "blue";
                echo "<tr>";
                echo "<td>$name</td>";
                echo "<td>$correct</td>";
                echo "<td>$correct</td>";
                echo "<td>$correct</td>";
                echo "</tr>";
            }
       ?>
            </tbody><commit_msg>show only assigned users in charts<commit_after><?php 
if (!isset($_REQUEST["questionID"])){
    echo "error";
    die();
}
require dirname(__DIR__) . "/connection.php";
require dirname(__DIR__) . "/language.php";

$questionID = intval($_REQUEST["questionID"]);
$result = $conn->query("SELECT title FROM dsgvo_training_questions WHERE id = $questionID");
$title = $result->fetch_assoc()["title"];
$result = $conn->query(
    "SELECT userID, correct, firstname, lastname, tcq.version, tries, tcq.duration
     FROM dsgvo_training_questions tq 
     INNER JOIN dsgvo_training_completed_questions tcq ON tcq.questionID = tq.id 
     INNER JOIN UserData ON UserData.id = tcq.userID
     WHERE tq.id = $questionID"
);
echo $conn->error;
$nameArray = array();
$triesArray = array();
$timesArray = array();
$triesColorsArray = array();
$timesColorsArray = array();
?>
<form method="POST">
<div class="modal fade">
    <div class="modal-dialog modal-content modal-md">
    <div class="modal-header">Auswertung von <?php echo $title ?></div>
    <div class="modal-body" style="overflow:scroll;">
        <?php
        if(!$result || $result->num_rows == 0){
            echo "Noch keine Daten vorhanden";
        }else{
        ?>
        <table class="table">
            <thead>
                <tr>
                    <th><?php echo $lang['USERS']?></th>
                    <th><?php echo $lang['ANSWER']?></th>
                    <th>Version</th>
                    <th><?php echo $lang['TRIES']?></th>
                </tr>
            </thead>
            <tbody>
       <?php 
            $right = $wrong = $unanswered = 0;
            while($row = $result->fetch_assoc()){
                $name = "${row['firstname']} ${row['lastname']}";
                $correct = $lang['TRAINING_QUESTION_CORRECT'][$row['correct']];
                $tries = $row['tries'];
                $version = $row['version'];
                if($row['correct'] == 'TRUE'){
                    $right++;
                }else{
                    $wrong++;
                }
                $nameArray[] = $name;
                $triesArray[] = $tries;
                $timesArray[] = $row["duration"];
                $triesColorsArray[] = "orange";
                $timesColorsArray[] = "blue";
                echo "<tr>";
                echo "<td>$name</td>";
                echo "<td>$correct</td>";
                echo "<td>$version</td>";
                echo "<td>$tries</td>";
                echo "</tr>";
            }
            //users who didn't answer yet

            $result = $conn->query(
                "SELECT dsgvo_training_user_relations.userID, ud.firstname, ud.lastname FROM dsgvo_training_user_relations
                 LEFT JOIN dsgvo_training_questions ON dsgvo_training_questions.trainingID = dsgvo_training_user_relations.trainingID
                 INNER JOIN UserData ud ON ud.id = dsgvo_training_user_relations.userID
                 WHERE dsgvo_training_questions.id = $questionID AND NOT EXISTS (SELECT questionID FROM dsgvo_training_completed_questions WHERE userID = ud.id AND questionID = $questionID)
                 UNION
                 SELECT teamRelationshipData.userID, ud.firstname, ud.lastname FROM dsgvo_training_team_relations
                 INNER JOIN teamRelationshipData ON teamRelationshipData.teamID = dsgvo_training_team_relations.teamID
                 LEFT JOIN dsgvo_training_questions ON dsgvo_training_questions.trainingID = dsgvo_training_team_relations.trainingID
                 INNER JOIN UserData ud ON ud.id = teamRelationshipData.userID
                 WHERE dsgvo_training_questions.id = $questionID AND NOT EXISTS (SELECT questionID FROM dsgvo_training_completed_questions WHERE userID = ud.id AND questionID = $questionID)"
            );
            echo $conn->error;
            while($row = $result->fetch_assoc()){
                $name = "${row['firstname']} ${row['lastname']}";
                $unanswered++;
                $correct = $lang['TRAINING_QUESTION_CORRECT']['UNANSWERED'];
                $nameArray[] = $name;
                $triesArray[] = 0;
                $timesArray[] = 0;
                $triesColorsArray[] = "orange";
                $timesColorsArray[] = "blue";
                echo "<tr>";
                echo "<td>$name</td>";
                echo "<td>$correct</td>";
                echo "<td>$correct</td>";
                echo "<td>$correct</td>";
                echo "</tr>";
            }
       ?>
            </tbody>
{'fraction_non_alphanumeric': 0.14974587826949298, 'fraction_numerical': 0.0009916945580761127, 'mean_word_length': 1.8814285714285715, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 116, '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': '2636891', 'n_tokens_mistral': 2424, 'n_tokens_neox': 2268, 'n_words': 489}