Forums

WP Survey And Quiz Tool
Controlling the Post Location of the Quiz. (13 posts)

  1. filmmisery
    Member
    Posted 11 months ago #

    I just installed this plug-in and so far it's working great. However, I was wondering if there was a way to control the placement of the quiz within a post. Whenever I enter the [wpsqt_quiz name="1"] code it automatically puts the quiz above all content. I would like to display a picture and some introductory test first.

    Is there any way I can control that? Here is a sample (the image should be on top).

    http://www.filmmisery.com/?p=7379

  2. parisvega
    Member
    Posted 11 months ago #

    I'm having this same problem.

  3. Ollie Armstrong
    Member
    Posted 10 months ago #

    All,

    I have partially fixed this issue, it will now display all the content before the quiz/survey. However it also displays it after the quiz/survey. Currently working on fixing this now.

    You can grab the updated plugin from my GitHub repo.

    Hopefully will have it fully fixed for you all tomorrow.

    Ollie

  4. Ollie Armstrong
    Member
    Posted 10 months ago #

    This issue is now fully fixed. Please test and report any bugs related to this on this thread. Thanks.

    Download from my GitHub repo as usual.

    Ollie

  5. joemerchant2
    Member
    Posted 10 months ago #

    Fixed sort of...whatever is first on the page before the shortcut tag, is being duplicated.

  6. Ollie Armstrong
    Member
    Posted 10 months ago #

    Would you mind sending me the content of the page? On page edit if you could copy everything in the HTML tab and paste it to pastebin.com and give me the link. (Pastebin just saves a huge forum post because the page looks like it could have a large amount of content.

    Cheers,
    Ollie

  7. joemerchant2
    Member
    Posted 10 months ago #

    Save you from digging through the code...
    I shortened the pre-quiz content to one sentence and then displayed the page. After the CONTENT DIV and before the QUIZ DIV, I see this:

    You may begin....now.
    <br>
    <br>
    <div class="pre-content">
    You may begin....now.
    <br>
    <br>
    </div>
  8. joemerchant2
    Member
    Posted 10 months ago #

    Also, it incorrectly shows on all paginated pages of the quiz.

  9. joemerchant2
    Member
    Posted 10 months ago #

    And I took the quiz and it showed this:

    Warning: Invalid argument supplied for foreach() in /home/behindth/public_html/wpconversion/wp-content/plugins/wp-survey-and-quiz-tool/lib/Wpsqt/Shortcode.php on line 207

    Warning: Invalid argument supplied for foreach() in /home/behindth/public_html/wpconversion/wp-content/plugins/wp-survey-and-quiz-tool/lib/Wpsqt/Shortcode.php on line 372

    Warning: Invalid argument supplied for foreach() in /home/behindth/public_html/wpconversion/wp-content/plugins/wp-survey-and-quiz-tool/lib/Wpsqt/Shortcode.php on line 372

    AND

    "quiz can't be auto marked"

  10. joemerchant2
    Member
    Posted 10 months ago #

    I noticed your code reads:
    $buffer = preg_replace('/<div class="qcontent">
    However, the div ID is actually "content." I tried changing it to "content" but nothing changed. However, the function "callback($buffer)

  11. joemerchant2
    Member
    Posted 10 months ago #

    Coding a fix. Almost done.

  12. joemerchant2
    Member
    Posted 10 months ago #

    Here is a summary of the problems and what I've fixed:

    Problems
    1. Duplicate pre-quiz content
    2. Error messages on last page of multi-page quiz which also cause the score not to display and say "quiz can't be automarked."
    3. Pre and post content displays on all page - not good if the prequiz material is "Start the quiz now!"

    Here is what I got done today:
    Re-coded the content buffer function so that only one copy of the pre-quiz message is displayed. See below

    function callback($buffer) {
    	// Grabs the actual page content (with shortcodes etc.)
    	  global $post;
    	$pageContent = get_post($post->ID);
    	$content = $pageContent->post_content;
    	//load data to pass through if not a quiz/survey
    
    	// Checks if it is a quiz/survey before removing the content and replacing etc.
    	if (strpos($content, "[wpsqt_")) {
    	      // Splits it to before shortcode and after
    	      $contentSplit = preg_split('$\[wpsqt_(quiz|survey)\sname\=\"(\w|\s)*\"\]$', $content);
    	      // clear out everything in the qcontent ID
    		$buffer = preg_replace('/<div class="qcontent">(.)*?<\/div>/s', '', $buffer);
                  // clear out everything in the content and before the pre-div.
    		$startPoint='<div id="content">';
    		$endPoint='<div class="pre-content">';
    		$newText='';
    		$buffer = replaceTags($startPoint, $endPoint, $newText, $buffer);
            // Replaces the pre and post content divs with the content we split above
    	      $buffer = str_replace('<div class="pre-content"></div>', '<div class="pre-content">'.nl2br($contentSplit[0]).'</div>', $buffer);
    	      $buffer = str_replace('<div class="post-content"></div>', '<div class="post-content">'.nl2br($contentSplit[1]).'</div>', $buffer);
    
    	}
      // Returns the buffer for output
    	return $buffer;
    }
    
    function replaceTags($startPoint, $endPoint, $newText, $source) {
        return preg_replace('#('.preg_quote($startPoint).')(.*)('.preg_quote($endPoint).')#si', '$1'.$newText.'$3', $source);
    }
  13. Ollie Armstrong
    Member
    Posted 10 months ago #

    Hi,

    I've implemented your code, would you be able to download the full version from the GitHub repo and test it?

    RE: Problems
    1. I have been unable to reproduce this.
    2. This error is actually displayed due to have free text fields rather than the pagination.
    3. I have noted this and I will see if I can produce an option to disable the pre/post quiz content displaying on separate sections.

    Cheers,
    Ollie

Reply

You must log in to post.

About this Plugin

About this Topic