<?php
/**
 * class result
 *
 * Description for class result
 *
 * @author:
*/
use core\slideResult;

class result_004_OpenEnded extends slideResult {
	public function result() {
		global $__database;

		$return = array(
			"users" => 0,
			"results" => array()
		);
		$result = array();
		
		$query = $__database->prepare("SELECT COUNT(DISTINCT `user_id`) AS `users` FROM `results` WHERE `board_id`=:id");
		$query->bindParam(":id", $this->id);
		$query->execute();
		if($row = $query->fetch()) {
			$return["users"] = $row["users"];
		}

		$query = $__database->prepare("SELECT `reply` FROM `results` WHERE `board_id`=:id GROUP BY `reply`");
		$query->bindParam(":id", $this->id);
		$query->execute();
		while($row = $query->fetch()) {
			$result[] = $row["reply"];
		}
		
		$return["results"] = $result;
		
		return $return;
	}
}
?>