PHP Classes

Great for tutorials

Recommend this page to a friend!

      PHP Secret URL Path  >  PHP Secret URL Path package blog  >  PHP Site Gamification...  >  All threads  >  Great for tutorials  >  (Un) Subscribe thread alerts  
Subject:Great for tutorials
Summary:In-game tutorials made simple
Messages:2
Author:Jon Lennryd
Date:2017-01-11 13:03:06
 

  1. Great for tutorials   Reply   Report abuse  
Picture of Jon Lennryd Jon Lennryd - 2017-01-11 13:03:06
I found this idea great for in-game tutorials, where the tutorial should inform the user on where to go next on every page.
I have not tried this yet, but imagine the $userNotice can be different on each step in the path, like for example "Great. Now click on 'Add Fancy Building'."
Also complicated sites could benefit from this tutorial idea, for example terribly complicated betting-sites or stockmarket-sites.

  2. Re: Great for tutorials   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-01-11 16:37:48 - In reply to message 1 from Jon Lennryd
I had not considered making the secret path not such a secret and informing the user what to do next. The authorization test is just returning true or false, so we need to make a couple of changes to make it work.

1) We need to make the userPath public so that we can access where they are in the path. In secretpath.class.php, change...

private $userPath;

TO...

public $userPath;

2) Using the code from the article, replace this block...

if( $secpth->validatePath( false ) === true ) {
$userNotice = 'Congratulations, you completed the path';
$secpth = new secretPath( 'link', '*', 4,9);
} elseif( !empty($_SESSION['secpth']) ){
$userNotice = ( $secpth->testUserPath() ) ? 'You are on the right track' : 'Wrong track, try again';
}

WITH...

$noticeArray = array(
'',
'Click on Link 1',
'Click on Link 2',
'Click on Link 3',
'Click on Link 4',
'Click on Link 5',
'Click on Link 6',
'Click on Link 7',
'Click on Link 8',
'Click on Link 9',
);
$path = $secpth->getSecPath();
if( $secpth->validatePath(false) === true ){
$userNotice = 'Congratulations, you completed the path. ';
$secpth = new secretPath('link','*',4,9);
$userNotice .= $noticeArray[$path[0]];
}elseif( !empty($_SESSION['secpth']) ){
$userCount = ( !empty($secpth->userPath) ) ? count($secpth->userPath) : 0;
$userNotice = ( $secpth->testUserPath() ) ? 'You are on the right track. '.$noticeArray[$path[$userCount]] : 'Wrong track, try again. '.$noticeArray[$path[0]];
}else{
$userNotice = $noticeArray[$path[0]];
}

We have created a $noticeArray which will inform the user which link to click and used the users current successful clicks to display that message for the next correct link.

Dave