<commit_before><?php
class post extends ci_Model{
//everything related to the tracking of post status

	function message_post($post_id, $post_type, $receivers){//set message status for each receiver
		$post_from	= $this->session->userdata('user_id');
		$class_id 	= $_SESSION['current_class'];
		
		
		if(is_array($receivers)){
			foreach($receivers as $post_to){
				
				$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
							post_type='$post_type', post_from='$post_from', post_to='$post_to'");
			}
		}else{
			$post_to = $receivers;
			$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
						post_type='$post_type', post_from='$post_from', post_to='$post_to'");
		}
	}
	
	function class_post($post_id, $post_type){//set assignment, handouts and quizzes status for each member of the class excep the teacher
	/*
	post types:
	1-assignment(AS)
	2-handout(HO)
	3-assignment response(AR)
	4-quiz(QZ)
	5-message(PO)
	6-session(SS)
	7-quiz response(QR)
	*/	
	
	
		$post_from	= $this->session->userdata('user_id');
		$class_id 	= $_SESSION['current_class'];
		
		//select all people that belong to the specific class
		$people		= $this->db->query("SELECT * FROM tbl_classpeople WHERE class_id='$class_id'");
		if($people->num_rows() > 0){
			foreach($people->result() as $row){
				$post_to 	= $row->user_id;
				
				if($post_from != $post_to){
					$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
						post_type='$post_type', post_from='$post_from', post_to='$post_to'");
				}
				
			}
		}
		
		
	}
	
	function status($post_id){//returns the status of a specific post for a particular user
		$user_id	= $this->session->userdata('user_id');
		$state	= 0;
		$query	= $this->db->query("SELECT status FROM tbl_poststatus WHERE post_to='$user_id' AND post_id='$post_id'");
		if($query->num_rows() > 0){
			$row 	= $query->row();
			$state	= $row->status;
		}
		return $state;
	}
	
	function assignmentreply_status($post_id, $post_from){//quick fix refactor later
		$query = $this->db->query("SELECT status FROM tbl_poststatus WHERE post_id='$post_id' AND post_from='$post_from'");<commit_msg>a few bug fixes, changed timezones<commit_after><?php
class post extends ci_Model{
//everything related to the tracking of post status

	function message_post($post_id, $post_type, $receivers){//set message status for each receiver
		$post_from	= $this->session->userdata('user_id');
		$class_id 	= $_SESSION['current_class'];
		
		
		if(is_array($receivers)){
			foreach($receivers as $post_to){
				
				$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
							post_type='$post_type', post_from='$post_from', post_to='$post_to'");
			}
		}else{
			$post_to = $receivers;
			$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
						post_type='$post_type', post_from='$post_from', post_to='$post_to'");
		}
	}
	
	function class_post($post_id, $post_type){//set assignment, handouts and quizzes status for each member of the class excep the teacher
	/*
	post types:
	1-assignment(AS)
	2-handout(HO)
	3-assignment response(AR)
	4-quiz(QZ)
	5-message(PO)
	6-session(SS)
	7-quiz response(QR)
	*/	
	
	
		$post_from	= $this->session->userdata('user_id');
		$class_id 	= $_SESSION['current_class'];
		
		//select all people that belong to the specific class
		$people		= $this->db->query("SELECT * FROM tbl_classpeople WHERE class_id='$class_id'");
		if($people->num_rows() > 0){
			foreach($people->result() as $row){
				$post_to 	= $row->user_id;
				
				if($post_from != $post_to){
					$set_status = $this->db->query("INSERT INTO tbl_poststatus SET class_id='$class_id', post_id='$post_id', 
						post_type='$post_type', post_from='$post_from', post_to='$post_to'");
				}
				
			}
		}
		
		
	}
	
	function status($post_id){//returns the status of a specific post for a particular user
		$user_id	= $this->session->userdata('user_id');
		$state	= 0;
		$query	= $this->db->query("SELECT status FROM tbl_poststatus WHERE post_to='$user_id' AND post_id='$post_id'");
		if($query->num_rows() > 0){
			$row 	= $query->row();
			$state	= $row->status;
		}
		return $state;
	}
	
	function assignmentreply_status($post_id, $post_from){//quick fix refactor later
		$query = $this->db->query("SELECT status FROM tbl_poststatus WHERE post_id='$post_id' AND post_from='$post_from' AND status =1");
		$state = 0;
{'fraction_non_alphanumeric': 0.16335009840367373, 'fraction_numerical': 0.004810846271594139, 'mean_word_length': 4.497596153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '2821952', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1661, 'n_words': 343}