| 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';
require_once('functions.self_assessment_test_sentence_suggestions.php');
$sats_suggestions_obj = new Self_assessment_test_sentence_suggestions();
require_once('functions.test_voting.php');
$test_voting_obj = new Test_voting();
if (isset($_POST['sid']) && isset($_SESSION['tm_id']) && isset($_POST['suggestion'])) {
$sentence_id_arr = explode( '~', base64_decode($_POST['sid']) ) ;
$sentence_id = $sentence_id_arr[0];
$suggestion_id = $sentence_id_arr[1];
$user_id = $_SESSION['tm_id'];
$language_id = $_SESSION['tm_language_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 self assessment test success suggestion count
$success_suggestion_count = $sats_suggestions_obj->getSelfAssessmentTestSuccessSuggestionCountBySentenceId( $sentence_id );
//check sentence suggested success less than 3
if ($success_suggestion_count < 3) {
//accept the suggestion, update sentence suggestion make lock and success suggestion
$resultUpdateS = $sats_suggestions_obj->submitSelfAssessmentTestSuggestionAndUpdateToSuccess( addslashes($_POST['suggestion']), $suggestion_id, $test_level );
if ($resultUpdateS == true) {
//update suggestion started at date in self_assessment_test_sentences, after received suggestion if date is null
$sats_suggestions_obj->updateSelfAssessmentTestSentenceSuggestionStartedAtDate( $sentence_id );
//after submit again rerun success count query
$success_suggestion_count2 = $sats_suggestions_obj->getSelfAssessmentTestSuccessSuggestionCountBySentenceId( $sentence_id );
//check suggested success count
if( $success_suggestion_count2 >= 3 ) {
//close the self assessment test sentence for suggestion
$sats_suggestions_obj->closeSelfAssessmentTestSentenceForSuggestions( $sentence_id );
//start voting at
//$sats_suggestions_obj->updateSelfAssessmentTestSentenceVotingStartedAtDate( $sentence_id );
}
echo json_encode(array("status" => "200", "msg" => "Suggestion submitted successfully"));
}else{
echo json_encode(array("status" => "300", "msg" => "Submission timed out took more than 5 mins"));
}
} else {
//make suggestion fail in self assessment test suggestion
$sats_suggestions_obj->makeSelfAssessmentTestSentenceSuggestionFailed( $suggestion_id );
echo json_encode(array("status" => "300", "msg" => "This sentence has already reached 3 suggestions.<br>
Please skip this and contribute on a new one."));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'Something went wrong, Please try again.'));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'User not found'));
}