<commit_before><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 *Form Feedback Class
 *
 * @package     Data
 * @category    Controller
 * @author      <NAME>
 * @link        http://sacids.org
 */
class Feedback extends CI_Controller
{

	function __construct()
	{
		parent::__construct();
		$this->load->model(array('Feedback_model', 'User_model'));
		$this->load->library('form_auth');
		$this->load->helper(array('url', 'string'));
		log_message('debug', 'Feedback controller initialized');

		//$this->output->enable_profiler(TRUE);
	}


	/**
	 * XML submission class
	 * @return response
	 */

	function get_feedback()
	{
		//get form_id and last_feedback_id
		$username = $this->input->get("username");
		$form_id = $this->input->get('form_id');
		$last_id = $this->input->get('last_id');

		$user = $this->User_model->find_by_username($username);
		$feedback = $this->Feedback_model->get_feedback($user->id, $form_id, $last_id);

		if ($feedback) {
			$response = array("feedback" => $feedback, "status" => "success");
			$this->output
				->set_status_header(200)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		} else {
			$response = array("status" => "success", "message" => "No content");
			$this->output
				->set_status_header(204)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		}
	}

	function post_feedback()
	{

		$username = $this->input->post("username");

		$feedback = array(
			"username" => $username,
			"form_id" => $this->input->post("form_id"),
			"message" => $this->input->post("message")
		);

		$user = $this->User_model->find_by_username($username);

		if ($user) {
			if ($this->Feedback_model->create_feedback($feedback)) {
				$response = array("message" => "Feedback was received successfully", "status" => "success");
				$this->output
					->set_status_header(200)
					->set_content_type('application/json', 'utf-8')
					->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
					->_display();
			} else {
				$response = array(
					"status" => "failed",
					"message" => "Unknown error occured"
				);
				$this->output
					->set_status_header(400)
					->set_content_type('application/json', 'utf-8')
					->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
					->_display();
			}
		} else {
			$response = array(
				"status" => "failed",
				"message" => "user does not exist"
			);
			$this->output
				->set_status_header(400)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		}

	}
}<commit_msg>Added user_id t when adding feedback<commit_after><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 *Form Feedback Class
 *
 * @package     Data
 * @category    Controller
 * @author      <NAME>
 * @link        http://sacids.org
 */
class Feedback extends CI_Controller
{

	function __construct()
	{
		parent::__construct();
		$this->load->model(array('Feedback_model', 'User_model'));
		$this->load->library('form_auth');
		$this->load->helper(array('url', 'string'));
		log_message('debug', 'Feedback controller initialized');

		//$this->output->enable_profiler(TRUE);
	}


	/**
	 * XML submission class
	 *
	 * @return response
	 */

	function get_feedback()
	{
		//get form_id and last_feedback_id
		$username = $this->input->get("username");
		$form_id = $this->input->get('form_id');
		$last_id = $this->input->get('last_id');

		$user = $this->User_model->find_by_username($username);
		$feedback = $this->Feedback_model->get_feedback($user->id, $form_id, $last_id);

		if ($feedback) {
			$response = array("feedback" => $feedback, "status" => "success");
			$this->output
				->set_status_header(200)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		} else {
			$response = array("status" => "success", "message" => "No content");
			$this->output
				->set_status_header(204)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		}
	}

	function post_feedback()
	{
		$username = $this->input->post("username");

		$user = $this->User_model->find_by_username($username);


		if ($user) {
			$feedback = array(
				"user_id" => $user->id,
				"form_id" => $this->input->post("form_id"),
				"message" => $this->input->post("message"),
				"created_at" => date("c")
			);

			if ($this->Feedback_model->create_feedback($feedback)) {
				$response = array("message" => "Feedback was received successfully", "status" => "success");
				$this->output
					->set_status_header(200)
					->set_content_type('application/json', 'utf-8')
					->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
					->_display();
			} else {
				$response = array(
					"status" => "failed",
					"message" => "Unknown error occured"
				);
				$this->output
					->set_status_header(400)
					->set_content_type('application/json', 'utf-8')
					->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
					->_display();
			}
		} else {
			$response = array(
				"status" => "failed",
				"message" => "user does not exist"
			);
			$this->output
				->set_status_header(400)
				->set_content_type('application/json', 'utf-8')
				->set_output(json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
				->_display();
		}
	}
}
{'fraction_non_alphanumeric': 0.17771134363062613, 'fraction_numerical': 0.006643414715163594, 'mean_word_length': 4.169098712446352, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2474593', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2063, 'n_words': 333}