multiple-choice-class

Gesponsorde koppelingen

PHP script bestanden

  1. multiple-choice-class

« Lees de omschrijving en reacties

De onderstaande klasse in voor PHP 5 en zal niet werken op PHP 4 systemen:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php

class multipleChoice {


  public $form = false;
  const NL    = "\r\n";


  public function __construct($action = '', $method = 'post', $extra = null) {
  
    if (isset($action) == true && strlen($action) > 0) {
    
      echo '<form action="' .$action. '" method="' .$method. '"';
      
      if ($extra != null)
        echo ' ' .$extra. '>' . self::NL;
      else
        echo '>' . self::NL;
        
      $this->form = true;
    }
  }

  
  
  public function addCategory($category) {
  
    echo '<h3 class="subtitle">' .$category. '</h3>' . self::NL;  
  }

  
  
  public function addOption($option) {
  
    echo '    <option value="' .$option. '">' .$option. '</option>' . self::NL;
  }

  

  public function addQuestion($question, $arguments = false) {
  
    if ($arguments != false) {
    
      echo '  <p>' .$question. '</p>' . self::NL;
      
      echo '  <select name="multipleChoise">' . self::NL;
      
      for ($i = 0; $i < count($arguments); $i++)
        $this->addOption($arguments[$i]);
      
      echo '  </select>' . self::NL;
      echo '  <br /> <br />' .self::NL . self::NL;
    }

    else
      echo $question;
  }

  
  
  public function addSubmit($name = null, $value = null, $extra = null) {
  
    echo '  <input type="submit" name="' .$name. '" value="' .$value. '" ';
      
    if ($extra != null)      
      echo $extra. ' />' . self::NL;
    else
      echo '/>' . self::NL;
    
    echo '</form>' . self::NL . self::NL;  
  }

  
  
  public function addTitle($title) {
  
    echo '<h1 class="title">' .$title. '</h1>' . self::NL;  
  }

  
  
  public function close($name = null, $value = null, $extra = null) {
  
    if ($this->form == true && $name != null && $value != null) {
      
      $this->addSubmit($name, $value, $extra);
    }
  }
}


?>



De onderstaande code is voor PHP 4 en zal eveneens werken op PHP 5 systemen:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php

define('NL', "\r\n");

class multipleChoice {


  var
$form = false;


  function
multipleChoice($action = '', $method = 'post', $extra = null) {
  
    if (isset($action) == true && strlen($action) > 0) {
    
      echo '<form action="' .$action. '" method="' .$method. '"';
      
      if ($extra != null)
        echo ' ' .$extra. '>' . NL;
      else
        echo '>' . NL;
        
      $this->form = true;
    }
  }
  
  
  function
addCategory($category) {
  
    echo '<h3 class="subtitle">' .$category. '</h3>' . NL;  
  }
  
  
  function
addOption($option) {
  
    echo '    <option value="' .$option. '">' .$option. '</option>' . NL;
  }
  

  function
addQuestion($question, $arguments = false) {
  
    if ($arguments != false) {
    
      echo '  <p>' .$question. '</p>' . NL;
      
      echo '  <select name="multipleChoise">' . NL;
      
      for ($i = 0; $i < count($arguments); $i++)
        $this->addOption($arguments[$i]);
      
      echo '  </select>' . NL;
      echo '  <br /> <br />' .NL . NL;
    }

    else
      echo $question;
  }
  
  
  function
addSubmit($name = null, $value = null, $extra = null) {
  
    echo '  <input type="submit" name="' .$name. '" value="' .$value. '" ';
      
    if ($extra != null)      
      echo $extra. ' />' . NL;
    else
      echo '/>' . NL;
    
    echo '</form>' . NL . NL;  
  }
  
  
  function
addTitle($title) {
  
    echo '<h1 class="title">' .$title. '</h1>' . NL;  
  }
  
  
  function
close($name = null, $value = null, $extra = null) {
  
    if ($this->form == true && $name != null && $value != null) {
      
      $this->addSubmit($name, $value, $extra);
    }
  }
}


?>


Als iemand nog foutjes ontdekt, dan hoor ik het wel :c)

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.