diff --git a/classes/quiz.class.php b/classes/quiz.class.php new file mode 100644 index 0000000..44971e0 --- /dev/null +++ b/classes/quiz.class.php @@ -0,0 +1,64 @@ +select( self::tb_str, array(), array( 'id' => $id_int ) ); + if ( empty( $rows_arr ) ){ + throw new \RuntimeException( 'Invalid quiz ID' ); + } + + $this->id_int = $rows_arr[0]['id']; + $this->name_str = $rows_arr[0]['name']; + $this->maxScore_int = $rows_arr[0]['max_score']; + } + + /** + * Get a list of quiz IDs and names + * + * @return string[] Array of quiz names keyed by id + */ + public static function getList(){ + $db = DB::getDB(); + + $quiz_arr = $db->select( self::tb_str, array( 'id', 'name' ) ); + + return $quiz_arr; + } + + /** + * Get name of Quiz + * + * @return string Name + */ + public function getName(){ + return $this->name_str; + } + + /** + * Get Maximum possible Score of quiz + * + * @return int Max score + */ + public function getMaxScore(){ + return $this->maxScore_int; + } + +} diff --git a/index.php b/index.php index 7664e4a..4b3d5f7 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,8 @@ @@ -12,11 +15,38 @@ require_once 'init.php';
-
-

Basic PHP Quiz

+
+

Basic PHP Quiz

-
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+