Exemplo n.º 1
0
function wfConnectQuiz(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision)
{
    if (!$article || !$text) {
        return true;
    }
    if ($article->getID() == 0) {
        return true;
    }
    //first check to see if there's a [[Quiz:foo]] in the article
    $count = preg_match_all('@\\[\\[Quiz:([^\\]]*)\\]\\]@i', $text, $matches, PREG_SET_ORDER);
    if ($count) {
        $quiz_array = array();
        //cycle through and clean up the samples, check for multiples, etc.
        foreach ($matches as $match) {
            $quiz = preg_replace('@ @', '-', $match[1]);
            //check for multiple
            $quizzes_array = explode(',', $quiz);
            foreach ($quizzes_array as $quiz) {
                $quiz_array[] = $quiz;
            }
        }
        //update that link table
        foreach ($quiz_array as $quiz) {
            Quizzes::updateLinkTable($article, $quiz);
        }
        //make sure we didn't lose any
        $dbr = wfGetDB(DB_SLAVE);
        $res = $dbr->select('quiz_links', 'ql_name', array('ql_page' => $article->getID()), __METHOD__);
        foreach ($res as $row) {
            if (!in_array($row->ql_name, $quiz_array)) {
                //no longer on the page; remove it
                Quizzes::updateLinkTable($article, $row->ql_name, false);
            }
        }
    } else {
        //nothing in the article?
        //remove anything in the link table if there are mentions
        Quizzes::updateLinkTable($article, '', false);
    }
    return true;
}
Exemplo n.º 2
0
         $new_quiz['priority'] = 1;
         // if offline previously enabled then set appropriate - otherwise set to disabled
         if (isset($old_entries['$offlinequiz']) && $old_entries['$offlinequiz'] == 1) {
             $new_quiz['enableoffline'] = true;
         } else {
             $new_quiz['enableoffline'] = false;
         }
         // online is always enabled
         $new_quiz['enableonline'] = true;
         /* Save new entry */
         $qdb->addQuiz($new_quiz);
         // we do not add to the array instead we will reload the quizzes once complete
     }
 }
 // re initialise array by reloading entries
 $all_quizzes = new Quizzes();
 $quiz_array = array();
 $quiz_array = $qdb->getQuizzesAll();
 // add this one to allQuizzes
 foreach ($quiz_array as $this_quiz_array) {
     $all_quizzes->addQuiz(new Quiz($this_quiz_array));
 }
 /*** Load questions from old database and store in new database ***/
 // Connect to the old database
 $olddb = new Database($old_db_entries);
 if ($db->getStatus() != 1) {
     die("Unable to connect to database " . $old_db_entries['hostname'] . " " . $old_db_entries['database']);
 }
 // create sql to load questions
 $old_sql = "SELECT * from " . $old_entries['$dbtable'];
 // Loads all questions - note that this requires a significant
Exemplo n.º 3
0
<?php

session_start();
include '../class/config.php';
include '../class/class_quizzes.php';
$quiz = new Quizzes();
if (!isset($_SESSION['username'])) {
    header("Location: ../login.php");
}
?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>E-Blast</title>

    <!-- Bootstrap Core CSS -->
    <link href="<?php 
echo $url;
?>
css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
Exemplo n.º 4
0
// this needs to be before we output anything as it uses sessions (cookies)
$auth = new SimpleAuth($settings->getSetting('admin_login_username'), $settings->getSetting('admin_login_password'), $settings->getSetting('admin_login_expirytime'));
// if not logged in redirect to login page
$status = $auth->checkLogin();
if ($status != 1) {
    // no from as use default which goes back to this page
    header("Location: " . ADMIN_LOGIN_FILE . "?status={$status}");
    // header will redirect to a new page so we just close this script
    exit(0);
    //Important to stop script here
}
// If we reach here then login was successful
$sessionUsername = $auth->getUser();
/*** Setup some values ***/
// get all the quizzes and add to object
$all_quizzes = new Quizzes();
$quiz_array = $qdb->getQuizzesAll();
// add this one to allQuizzes
foreach ($quiz_array as $this_quiz_array) {
    $all_quizzes->addQuiz(new Quiz($this_quiz_array));
}
// header template
$templates->includeTemplate('header', 'admin');
require_once $include_dir . "adminmenu.php";
print "<div id=\"" . CSS_ID_ADMIN_MAIN . "\">\n";
print "<h1>Questions</h1>";
// question = 0 used for create new
print "<form method=\"get\" action=\"" . ADMIN_EDIT_QUIZ_FILE . "\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"new\" />\n";
print "<input type=\"submit\" value=\"Add new quiz\">\n";
print "</form>\n";
Exemplo n.º 5
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return WQuizzes the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Exemplo n.º 6
0
// Enable debugging
error_reporting(E_ALL);
ini_set('display_errors', true);
//$debug = true;
// message is used to provide feedback to the user
//eg. if we get here from an expired session
$message = '';
require_once "includes/setup.php";
// add this here as not required for some pages (which use Quiz.php instead)
require_once $include_dir . "Quizzes.php";
// debug will prevent javascript being included in headers
if ($debug) {
    print "Loading Quizzes \n";
}
// get all the quizzes and add to object
$all_quizzes = new Quizzes();
$quiz_array = $qdb->getQuizzesAll();
// add this one to allQuizzes
foreach ($quiz_array as $this_quiz_array) {
    $all_quizzes->addQuiz(new Quiz($this_quiz_array));
}
// No quizzes found - most likely not setup
if ($all_quizzes->count() < 1) {
    header("Location: " . FIRST_FILE);
    exit(0);
}
// header template - moved to later to allow embed javascript
// still use normal header / footer
// it's the javascript print option where we use offline headers instead
//$templates->includeTemplate('header', 'normal');
if ($debug) {
Exemplo n.º 7
0
 /**
  * EXECUTE
  **/
 function execute($par = '')
 {
     global $wgOut, $wgRequest, $wgHooks, $wgCanonical, $wgSquidMaxage;
     if ($wgRequest->getVal('otherquizzesfor')) {
         $others = self::getOtherQuizzes($wgRequest->getVal('otherquizzesfor'));
         $wgOut->disable();
         print_r(json_encode($others));
         return;
     }
     $quiz = preg_replace('@-@', ' ', $par);
     wfLoadExtensionMessages('Quizzes');
     //no side bar
     $wgHooks['ShowSideBar'][] = array('Quizzes::removeSideBarCallback');
     //no head section
     $wgHooks['ShowHeadSection'][] = array('Quizzes::removeHeadSectionCallback');
     //make a custom canonical url
     self::$quizURL = wfExpandUrl(self::$quizURL . $par);
     $wgHooks['GetFullURL'][] = array('Quizzes::getCanonicalUrl');
     //page title
     $page_title = wfMsg('quiz_pagetitle') . ' ' . wfMsg('howto', $quiz);
     $wgOut->setHTMLTitle(wfMsg('pagetitle', $page_title));
     //css & js for quizzes
     $wgOut->addHeadItem('quiz_css', HtmlSnips::makeUrlTags('css', array('quizzes.css'), 'extensions/wikihow/quizzes', false));
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('quizzes.js'), 'extensions/wikihow/quizzes', false));
     //$wgOut->addScript(HtmlSnips::makeUrlTags('js', array('interstitialCookie.js'), 'extensions/wikihow/wikihowAds', false));
     $html = $this->displayContainer($par);
     if (!$html) {
         //nothin'
         $wgOut->setStatusCode(404);
         $html = '<p>' . wfMsg('quiz-no-quiz-err') . '</p>';
     } else {
         //http caching headers
         $wgOut->setSquidMaxage($wgSquidMaxage);
         //meta tags
         $wgOut->addMeta('description', 'Test yourself on How to ' . $quiz . ' with a fun and challenging quiz from wikiHow. See how well you score.');
         $wgOut->setRobotPolicy('index,follow');
     }
     $wgOut->addHTML($html);
 }
Exemplo n.º 8
0
$no_session = true;
require_once "includes/setup.php";
// add this here as not required for some pages (which use Quiz.php instead)
require_once $include_dir . "Quizzes.php";
// parameter for path to quiz - ie. what we add before index.php
if ($quizpath) {
    // quick check to validate path is validate
    if (preg_match('#^[\\w-_%/]+$#', $quizpath)) {
        $path = $quizpath;
    }
}
if ($debug) {
    print "Loading Quizzes \n";
}
// get all the quizzes and add to object
$all_quizzes = new Quizzes();
$quiz_array = $qdb->getQuizzesAll();
// add this one to allQuizzes
foreach ($quiz_array as $this_quiz_array) {
    $all_quizzes->addQuiz(new Quiz($this_quiz_array));
}
// No quizzes found - most likely not setup
if ($all_quizzes->count() < 1) {
    header("Location: " . $path . FIRST_FILE);
    exit(0);
}
if ($debug) {
    print "Reading parameters \n";
}
printMenu($path, $all_quizzes);
// Debug mode - display any errors / warnings
Exemplo n.º 9
0
// message is used to provide feedback to the user
//eg. if we get here from an expired session
$message = '';
// action should be new or edit
// note edit rather than save (save is used in post) as that is what we are doing in this
$action = '';
$quizname = '';
// adminsetup is within the admin directory - this will load the main setup.php as well
require_once "adminsetup.php";
// Authentication class required for admin functions
require_once $include_dir . "SimpleAuth.php";
// add this here as not required for some pages (which use Quiz.php instead)
require_once $include_dir . "Quizzes.php";
/*** Further setup ***/
// get all the quizzes and add to object (use to check unique quizname)
$all_quizzes = new Quizzes();
$quiz_array = $qdb->getQuizzesAll();
// add this one to allQuizzes
foreach ($quiz_array as $this_quiz_array) {
    $all_quizzes->addQuiz(new Quiz($this_quiz_array));
}
// get list of all quizzes to show / check for updates
$quiz_array = $all_quizzes->getQuizNameArray();
/*** Authentication ***/
// user must be logged in for any admin functions
// this needs to be before we output anything as it uses sessions (cookies)
$auth = new SimpleAuth($settings->getSetting('admin_login_username'), $settings->getSetting('admin_login_password'), $settings->getSetting('admin_login_expirytime'));
// if not logged in redirect to login page
$status = $auth->checkLogin();
if ($status != 1) {
    // no from as use default which goes back to this page
Exemplo n.º 10
0
// must add this before we require the menu
$admin_menu = 'edit';
//$debug = true;
// message is used to provide feedback to the user
//eg. if we get here from an expired session
$message = '';
$questionid = -1;
// adminsetup is within the admin directory - this will load the main setup.php as well
require_once "adminsetup.php";
// Authentication class required for admin functions
require_once $include_dir . "SimpleAuth.php";
// add this here as not required for some pages (which use Quiz.php instead)
require_once $include_dir . "Quizzes.php";
/*** Further setup ***/
// get all the quizzes and add to object
$all_quizzes = new Quizzes();
$quiz_array = $qdb->getQuizzesAll();
// add this one to allQuizzes
foreach ($quiz_array as $this_quiz_array) {
    $all_quizzes->addQuiz(new Quiz($this_quiz_array));
}
// get list of all quizzes to show / check for updates
$quiz_array = $all_quizzes->getQuizNameArray();
/*** Authentication ***/
// user must be logged in for any admin functions
// this needs to be before we output anything as it uses sessions (cookies)
$auth = new SimpleAuth($settings->getSetting('admin_login_username'), $settings->getSetting('admin_login_password'), $settings->getSetting('admin_login_expirytime'));
// if not logged in redirect to login page
$status = $auth->checkLogin();
if ($status != 1) {
    // no from as use default which goes back to this page