| Server IP : 64.202.187.69 / Your IP : 216.73.216.192 Web Server : Apache System : Linux 69.187.202.64.host.secureserver.net 3.10.0-1160.144.1.el7.tuxcare.els6.x86_64 #1 SMP Fri May 29 16:22:24 UTC 2026 x86_64 User : transmarket ( 1001) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/transmarket/translator/controllers/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include 'connection.php';
require_once('functions.test_sentences_voting.php');
$test_sentence_voting_obj = new Test_sentences_voting();
if (isset($_POST['sid']) && isset($_POST['suid']) && isset($_SESSION['tm_id'])) {
$sentence_id = $_POST['sid'];
$suggestion_id = $_POST['suid'];
$user_id = $_SESSION['tm_id'];
if (is_numeric($sentence_id) && is_numeric($suggestion_id)) {
//get success voting count for sentence
$success_voting_count = $test_sentence_voting_obj->get_success_test_sentence_voting_count_by_sentence_id($sentence_id);
$max_votes_per_sentences = $test_sentence_voting_obj->acceptMaxVotesForTestSentence();
//check success voting count less than maximum voting (11)
if ( $success_voting_count < $max_votes_per_sentences ) {
//update voting started at date (if not updated yet)
$test_sentence_voting_obj->updateTestSentenceVotingStartedDate( $sentence_id );
//get sentence count which user has not voted for sentence
$user_voting_count = $test_sentence_voting_obj->get_user_empty_test_sentence_vote_count($sentence_id, $user_id);
//check if user not voted count is 1
if( $user_voting_count == 1 ) {
//apply user vote. update user vote for sentence suggestion to success
$resultUpdateS = $test_sentence_voting_obj->applySuccessUserVoteForTestSentence($suggestion_id,$sentence_id,$user_id);
if ($resultUpdateS == true) {
//after submit again check success vote count for sentence
$success_voting_count2 = $test_sentence_voting_obj->get_success_test_sentence_voting_count_by_sentence_id($sentence_id);
//get no. of success voting to a single suggestion to win sentence
$no_of_success_voting_to_single_suggestion = $test_sentence_voting_obj->maxVoteToSingleSuggestionToWin();
//get count - sentence has reached No. of Target Success Voting To a Particular Suggestion
$check_sentence_reached_no_of_success_voting_suggestion = $test_sentence_voting_obj->checkTestSentenceHasReachedNoOfSuccessVotesForSuggestion($sentence_id, $no_of_success_voting_to_single_suggestion);
//check count greater or equal to maximum voting count (11) or if any sentence suggestion got max no. of success voting (5) then return 1
if( $success_voting_count2 >= $max_votes_per_sentences || $check_sentence_reached_no_of_success_voting_suggestion >= 1 ) {
// Close Sentence for voting. Voting completed for sentence suggestion
$test_sentence_voting_obj->closeVotingForTestSentence($sentence_id);
//Process winning suggestion user credits and winning suggestion voted user id credits by sentence id
$test_sentence_voting_obj->processWinningTestSentenceVotingCreditsBySentenceId( $sentence_id );
}
$data['status'] = 200;
$data['msg'] = "Vote submitted successfully.";
} else {
$data['status'] = 300;
$data['msg'] = "Vote timed out took more than 5 mins";
}
} else {
$data['status'] = 300;
$data['msg'] = "You have already submitted vote for this suggestion.";
}
} else {
//make user vote failed.
$test_sentence_voting_obj->makeUserTestSentenceVoteFailedBySentenceIdAndUserId($sentence_id,$user_id);
$data['status'] = 300;
$data['msg'] = "This sentence has already reached " . $max_votes_per_sentences . " votes.<br> Please skip this and contribute on a new one.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
echo json_encode($data);