| 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.self_assessment_test_sentnece_voting.php');
$sats_voting_obj = new Self_assessment_test_sentence_voting();
require_once('functions.test_voting.php');
$test_voting_obj = new Test_voting();
require_once('functions.self_assessment_test_sentence_suggestions.php');
$sats_suggestions_obj = new Self_assessment_test_sentence_suggestions();
$data['is_test_level_upgraded'] = 0;
if (isset($_POST['sid']) && isset($_POST['suid']) && isset($_SESSION['tm_id'])) {
//Get max no. of voting for sentence value
$max_voting_count = $sats_voting_obj->getSelfAssessmentTestMaxNoOfVotingForSentnece();
$sentence_id = base64_decode($_POST['sid']);
$suggestion_id = base64_decode($_POST['suid']);
$user_id = $_SESSION['tm_id'];
//get user's current test level
$test_level = $test_voting_obj->getTestVotingLevelByUserId( $user_id );
if ( is_numeric($sentence_id) && $sentence_id > 0 && is_numeric($suggestion_id) && $suggestion_id > 0 ) {
//get success self assessment test sentence voting count for sentence
$success_voting_count = $sats_voting_obj->get_success_sats_voting_count_by_sentence_id( $sentence_id );
//check success voting count less than maximum voting (11)
if ( $success_voting_count < $max_voting_count ) {
//update voting started at date
$sats_voting_obj->updateSelfAssessmentTestSentenceVotingStartedAtDate( $sentence_id );
//get sentence count which user has not voted for sentence
$user_voting_count = $sats_voting_obj->get_user_empty_vote_count_by_satsv_sentence_id_and_user_id($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 = $sats_voting_obj->applySuccessUserVoteForSelfAssessmentTestSentenceSuggestion( $suggestion_id, $sentence_id, $user_id, $test_level );
if ($resultUpdateS == true) {
//after submit again check success vote count for sentence
$success_voting_count2 = $sats_voting_obj->get_success_sats_voting_count_by_sentence_id($sentence_id);
//get no. of success voting to single suggestion
$no_of_success_voting_to_single_suggestion = $sats_voting_obj->getNoOfSuccessVotingToSingleSuggestion();
//get count - sentence has reached No. of Target Success Voting To a Particular Suggestion
$check_sentence_reached_no_of_success_voting_suggestion = $sats_voting_obj->checkSatsHasReachedNoOfSuccessVotesForSuggestion($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_voting_count || $check_sentence_reached_no_of_success_voting_suggestion >= 1 ) {
// Close Sentence for voting. Voting completed for sentence suggestion
$sats_voting_obj->closeVotingForSelfAssessmentTestSentence( $sentence_id );
require_once('functions.winning_sats_suggestion_voting_credits.php');
$wssvc_obj = new Winning_Sats_Suggestion_Voting_Credits();
//Process winning suggestion user credits and winning suggestion voted user id credits by sentence id
$wssvc_obj->processWinningSatsSuggestionVotingCreditsBySentenceId( $sentence_id );
}
$data['status'] = 200;
$data['msg'] = "Vote submitted successfully.";
//test level upgrade started
//$sat_suggestion_voting_test_level_arr = array( 3, 4, 5, 8, 9, 10 );
$sat_suggestion_voting_test_level_arr = array( 5, 6, 7, 8, 9, 10 );
if( in_array( $test_level, $sat_suggestion_voting_test_level_arr ) ) {
//get user total success suggestion count for current level
$user_success_sats_suggestion_count_for_test_level = $sats_suggestions_obj->getUserSubmittedSuccessSatsSuggestionCountByUserIdAndLevel( $user_id, $test_level );
//get max no. of suggestion user can submit for current test level
$max_submit_suggestions_for_test_level = $sats_suggestions_obj->getMaxNoOfSuggestionUserCanSubmitForTestLevel();
//get user total success voting count for current test level
$user_success_sats_voting_count_for_test_level = $sats_voting_obj->getUserSubmittedSuccessSatsVotingCountByUserIdAndTestLevel( $user_id, $test_level );
//get max no. of voting user can submit for current level
$max_submit_votings_for_test_level = $sats_voting_obj->getMaxNoOfSatsVoteUserCanSubmitForTestLevel();
if( $user_success_sats_suggestion_count_for_test_level >= $max_submit_suggestions_for_test_level && $user_success_sats_voting_count_for_test_level >= $max_submit_votings_for_test_level ) {
//upgrade test level
$result_upgrade_test_level = $sats_voting_obj->upgradeUserSatsSuggestionVotingTestLevel($user_id,$test_level);
if( $result_upgrade_test_level == true ) {
$data['is_test_level_upgraded'] = 1;
}
}
}
//test level upgrade end
} 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.
$sats_voting_obj->makeUserSatsVoteFailedBySentenceIdAndUserId($sentence_id,$user_id);
$data['status'] = 300;
$data['msg'] = "This sentence has already reached " . $max_voting_count . " 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);