<?php
     require_once 'db.connect.php';
     require_once '/../../helpers/func/helper.php';
     require_once '/../../helpers/classes/Question.php';
     require_once '/../../helpers/classes/Answer.php';

    $question = new Question($conn);
    $allQuestions = json_decode($question->getAllQuestionsWithModifier('week'));
    
    $answer = new Answer($conn);

    for ($i = 0; $i < count($allQuestions); $i++){
        $allAnswer = json_decode($answer->getAllByQuestionId( $allQuestions[$i]->id));
?>        
    
<li class="collection-item">
    <div class="col s3">
        <div class="col s6">
            <span>999999</span>
            <span>Votes</span>
        </div>
        <div class="col s6">
            <span><?php print count($allAnswer) ?></span>
            <span>Answers</span>
        </div>
    </div>
 
    <div class="col s9">
        <a href="question.php?id=<?php print $allQuestions[$i]->id ?>&title=<?php print replace_dashes($allQuestions[$i]->topic, true) ?>">
            <span class="title__name"><?php print $allQuestions[$i]->topic ?></span>
        </a>
        <div class="valign-wrapper">
            <small class="right-align"><?php print $allQuestions[$i]->date ?></small>
        </div>
    </div>
</li>

<?php
    }
?>