| Server IP : 64.202.187.69 / Your IP : 216.73.217.74 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';
//ini_set('display_errors',1);
//error_reporting(E_ALL);
require_once('functions.test_voting.php');
$test_voting_obj = new Test_voting();
if ( isset($_POST['ttvsm_id']) && isset($_POST['sid']) && isset($_POST['suid']) && isset($_SESSION['tm_id'])) {
$sentence_id = $_POST['sid'];
$suggestion_id = $_POST['suid'];
$user_id = $_SESSION['tm_id'];
$ttvsm_id = $_POST['ttvsm_id'];
if (is_numeric($ttvsm_id) && is_numeric($ttvsm_id)) {
// SQL for marking the test voting failed if time more than 1 day of submission
//$test_voting_obj->makeTestVotingFailedMaxSubmitTimeOver( $user_id );
//get test voting sentence row by (sentence) id
$result_test_voting_sentence = $test_voting_obj->getTestVotingSentenceRowById( $sentence_id );
if ($result_test_voting_sentence->num_rows > 0 ) {
//get original test voting sentence correct suggestion id
while ($row_test_voting_sentence = $result_test_voting_sentence->fetch_object()){
$correct_suggestion_id = $row_test_voting_sentence->correct_suggestion_id;
}
//check user submitted suggestion and original sentence suggestion is equal
if( $correct_suggestion_id == $suggestion_id ) {
//answer is correct
$is_correct_answer = 1;
} else {
//answer is wrong
$is_correct_answer = 0;
}
//apply user vote. update translator vote in test voting sentence map
$resultUpdateS = $test_voting_obj->applyUserVoteForAssignedTestVotingSentence($ttvsm_id,$user_id,$sentence_id,$suggestion_id,$is_correct_answer);
if ($resultUpdateS == true) {
//calculate user test voting success percentage and upgrade level/profile
$is_successfully_upgraded = $test_voting_obj->calculateUserTestVotingSuccessPercentageAndUpgrade( $user_id );
if($is_successfully_upgraded) {
$data['status'] = 400;
$data['msg'] = "Voting completed! Profile Upgraded Successfully!";
} else {
$data['status'] = 200;
$data['msg'] = "Vote submitted successfully.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong! Vote could not submit at the moment, Please try again.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
} 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);