Quizcreator functions - functions.php

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search
Blue Glass Arrow.svg MediaWiki logo.png
This page should be moved to MediaWiki.org.
Please do not move the page by hand. It will be imported by a MediaWiki.org administrator with the full edit history. In the meantime, you may continue to edit the page as normal.
<?php
// Define functions


// Create the quiz form.
function create_quiz_form (){
        $text .= "<form action=\"$PHP_SELF\"\" method=\"post\">\n";
                                return $text;
}

// Create the input button.
function create_input_button ($input_name, $type, $value){
                                 $text .= "<input type=\"$type\" name=\"$input_name\" value=\"$value\" size=\"15\">\n";
                                 return $text;
}
function create_input_button_radio ($input_name, $value){
                                 $text .= "<input type=\"radio\" name=\"$input_name\" value=\"$value\" >\n";
                                 return $text;
}
// Create the textarea.
function create_textarea ($textarea_name) {
                                 $text .= "<textarea rows=\"5\" cols=\"50\" name=\"$textarea_name\"></textarea>\n";
                                 return $text;
}

// Create the submit button.
function create_submit_button ($submit_name, $value){
                                 $text .= "<input type=\"submit\" name=\"$submit_name\" value=\"$value\">\n";
         $text .= "</form>\n";
                                 return $text;
}

// Create <tex> tag creator.
function create_tex_tag ($input) {
                                 
                                 $output = str_replace("<", "<", $input);
                                 $output = str_replace(">", ">", $output);
                                 
                                 return $output;
}

// Create a new copy of quiz.php with the filename of the current quiz so users
// can link to the new quizzes properly.  It's a bit inefficient, but it simplifies
// the process for the user.

function create_duplicate_quiz ($input) {
                                 
                                 $newfile_quiz = file_get_contents("quiz.php");
                                 $insert_string = "$input".".xml";
                                 $newfile_quiz = str_replace("quiz.xml", "$insert_string", $newfile_quiz);
                                 
                                 $newfile_quiz_name = "$input".".php";
                                 
                                 $fh = fopen($newfile_quiz_name, 'w') or die("can't create file");
                                 fwrite($fh, "$newfile_quiz");
                                 fclose($fh);
                                 //if (file_put_contents("$newfile_quiz_name","$newfile_quiz")) {
                                 //} else {
                                 //  echo "Can't create quiz file.  Check the permissions of your quiz folder";
                                 //      return;
                                 //}
                                 return (true);
}                               
?>
Personal tools

Variants
Actions
Navigation
Community
Beyond the Web
Print/export
Toolbox