Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to find the quiz id on the page template? #95

Open
advcha opened this issue Jul 28, 2020 · 0 comments
Open

How to find the quiz id on the page template? #95

advcha opened this issue Jul 28, 2020 · 0 comments

Comments

@advcha
Copy link

advcha commented Jul 28, 2020

I created a simple plugin to set and get a pdf path like this:

<?php
...
add_action('wpProQuiz_quizEdit_tab_content_plugins', 'pdf_path');

function pdf_path()
{
    $quizId = isset($_GET['quizId']) ? (int)$_GET['quizId'] : 0;
    $pdf_path = '';
    if($quizId){
        $quiz = new WpProQuiz_Model_QuizMapper();
        $quiz_data = $quiz->fetch($quizId);
        $quiz_plugin = $quiz_data->getPluginContainer();
        if($quiz_plugin){
            $pdf_path = $quiz_plugin->get("'pdf_path'");
        }
    }
?>
    <div class="postbox">
        <h3 class="hndle">PDF Handbook (Optional)</h3>

        <div class="inside">
            <p class="description">
                Please upload the pdf handbook file first via <a href="<?php echo admin_url(); ?>upload.php">media upload</a> then copy the path on the box below.                
            </p>
            <div>
                Pdf Handbook Path : <input type="text" name="plugin['pdf_path']" size="100" value="<?php echo $pdf_path; ?>">
            </div>
        </div>
    </div>
<?php
}
?>

but on the page template (frontpage) I can't find a way to get the current quiz id. I put the quiz shortcode on the page with customized template but I dont know how to find put the quiz id. it should be like this:

<?php
            $quizId = 1; //hardcoded. how to get the current quiz id???
            $pdf_path = '';
            
            $quiz = new WpProQuiz_Model_QuizMapper();
            $quiz_data = $quiz->fetch($quizId);
            $quiz_plugin = $quiz_data->getPluginContainer();
            if($quiz_plugin){
                $pdf_path = $quiz_plugin->get("'pdf_path'");
            }
            
            if($pdf_path){
        ?>

Also I found a problem on Wp-Pro-Quiz/lib/model/WpProQuiz_Model_PluginContainer.php. the 'exists' function supposed to be like this

    public function exists($name)
    {
        //return isset($name);//--> not correct
        return isset($this->_data[$name]);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant