<?php
require '../../conn/codeblocs.php';

$get = $_GET;
$rbid = $get['rbid'] ?? '';

$responses = doPDOQ("SELECT r.*, q.question_name, q.question_datatype, q.section_id, q.rating_scale_id, o.scale_option
FROM survey_responses r 
INNER JOIN survey_questions q USING(question_id) 
LEFT JOIN rating_scale_options o ON (o.rating_scale_id = q.rating_scale_id AND o.scale_option_rank = r.response_data)
WHERE response_batch_id = ?", [$rbid]);
// preprint($responses);
?>
<div class="container-table100">

<div class="wrap-table100">
    <div class="table100">
        <table>
            <thead>
                <tr class="table100-head">
                    <th class="first-column">Question</th>
                    <th class="">Rate</th>
                    <th class="">Response</th>
                    <th class="">Option</th>
                    <th class="last-column">DataType</th>
                    
                </tr>
            </thead>
            <tbody>
                <?php foreach($responses as $response):?>
                <tr>
                    <td class=""><?=$response['question_name']?></td>
                    <td class=""><?=$response['response_data']?></td>
                    <td class=""><?=$response['rating_scale_id']?></td>
                    <td class=""><?=$response['scale_option']?></td>
                    <td class=""><?=$response['question_datatype']?></td>
                </tr>
                <?php endforeach?>

            
            </tbody>
        </table>
    </div>
</div>
</div>