WordPress.org

Ready to get started?Download WordPress

Forums

YOP Poll
Auto Quiz (7 posts)

  1. LaxmiBatav
    Member
    Posted 3 months ago #

    Hello, I am using WordPress for my website and I want to create a daily quiz which automatically updates a new quiz every day.

    I have a bunch of quizzes (a few hundred) and I want a new one to update every day. Some of these have 3 answers, some 4 and some 2. They will be exactly in the same style and format but just different questions and answers, I prefer to use Yop Poll as it is by far the most robust and omnipotent Poll plugin i have ever used.

    I am currently working on my website and it's private so unfortunately i am unable to share the link.

    Thank you in advance

    -The EHC Team

    https://wordpress.org/plugins/yop-poll/

  2. YOP
    Member
    Plugin Author

    Posted 3 months ago #

    Hi LaxmiBatav,

    At the moment the only option would be to use the [yop_poll id="-3"] shortcode, that generates a random poll.

    The only downside is that for each visit an user will see a different poll being displayed and different users will see different polls.

    Best wishes,

    YOP Team

  3. LaxmiBatav
    Member
    Posted 3 months ago #

    I'm sorry, but every day there is a specific poll that i want to display with the same short code, and i know there would be coding involved.
    It's just that the question and answer need to be changed.

    Thanks,

  4. LaxmiBatav
    Member
    Posted 3 months ago #

    I think that it would be done externally anyway. and i probabaly would need an expert to look at it. but after a short while of searching where the polls have been kept i have discovered them to be in my database. all we need to do is to run a sql find and search that just replaces the answer, the question and the number of answers all in one query easily.

    I'm sure there is a way to set a timer on when to run that query, that's all.

  5. YOP
    Member
    Plugin Author

    Posted 3 months ago #

    Hey LaxmiBatav,

    Unfortunately you can't have two different polls with the same shortcode so the only solution we can offer currently is to generate a random poll by using the [yop_poll id="-3" shortcode.

    Regards,

    YOP Team

  6. LaxmiBatav
    Member
    Posted 3 months ago #

    Ok, thank you

  7. LaxmiBatav
    Member
    Posted 3 months ago #

    What I ran is fairly complicated, but for those who are looking at this thread and want to do the same thing, this is what I did.

    1.Create a Sql update query in a php script file.
    2.Run a cron job at the selected time.

    ----------Step 1-------------

    <?php
    
    //Database connection
    $dbhost = '[A]';
    $dbuser = '[B]';
    $dbpass = '[C]!';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db('[D]',$conn);
    
    $sql = "UPDATE wp_yop_polls ".
           "SET question = '[New Poll(in most cases a question)]' ".
           "WHERE id = [F]" ;
    
    //Repeat This chunk as many times as you want for the number of answers (remove this line afterwards)
    
    $sql = "UPDATE wp_yop_answers ".
           "SET answer = '[New answer available (options)]' ".
           "WHERE id = [H]" ;
    
    $retval = mysql_query( $sql, $conn );
    mysql_close($conn);
    
    ?>

    All the code you need to update a sql query is in this file.
    Here are the parameters:

    [A] -your DB Host (In the form of an ip adress, eg 34.136.109.11 )
    [B] -the username for the database
    [C] -the password for the database
    [D] -the actual name for the database [the name you gave it when you created it]
    [F] -the yop poll id (found in the shortcode, eg [yop_poll id="F"]
    [H] -The hardest bit I'm afraid, in which you would have to go into your root files. Here are the steps:

    1.Login in to your hosting manager, wether it be Cpanel or whatever your host provides you.
    2.Navigate to SQL Database and click on 'Phpmyadmin'
    3.You would be navigated to this page, where you would have to login with your username and password
    4.After you login you see the name of your database on the left, click on it and you see a few dozen other links under it.
    5.Click on wp_yop_answers (somewhere down the list)
    6.Click 'browse' (in the navigation bar at the top)
    7.After you see the table you get all the answers, and you see the ids. For the desired answer you see the id, thats your [H] value.
    8.Done!

    [NOTE: DO NOT INCLUDE THE "[ AND ]"s IN THE PLACEHOLDERS.

    ----------------STEP 2-----------------

    You'd be glad to know this is much more simpler.

    Step 1.Login to your hosting manager and open 'Cron job manager'
    Step 2.Click 'create cron job'
    Step 3.Give whatever title you want to.
    Step 4.Provide the path to the above php file in your website (for conveniance just keep it in the webroot)
    Step 5.Give the frequency and time (pretty much self explanatory, just give the dates when you want it to happen or how often)
    Step 6.Click and save and voula! your done. :)

    Through this guide you would hopefully learn more on SQL databases and if you have any queries, feel free to ask them below.

    -The EHC Team

Reply

You must log in to post.

About this Plugin

About this Topic