| 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';
$data = array();
$data['status'] = 300;
$offset = 0;
$user_id = $_SESSION['tm_id'];
//ini_set('display_errors',1);
///error_reporting(E_ALL);
require_once('functions.self_assessment_test_sentence_suggestions.php');
$sats_suggestions_obj = new Self_assessment_test_sentence_suggestions();
//Get max submit time in minutes to submit suggestion
$global_time_mins = $sats_suggestions_obj->getSatsSuggestionMaxSubmitTimeMins();
//get sentence suggestion max assign value (a sentence can be assigned to no. of users for suggestion)
$sentence_suggestion_max_assign_value = $sats_suggestions_obj->getSentenceSuggestionMaxAssignValue();
//skip the sentence
if(isset($_POST['skip_id']) && $_POST['skip_id'] != '0') {
$skip_id_arr = explode( '~', base64_decode($_POST['skip_id']) ) ;
$sentence_id = $skip_id_arr[0];
//insert skipped sentence record in to skipped_self_assessment_test_sentence_suggestion table
$sats_suggestions_obj->saveSkippedSelfAssessmentTestSentenceSuggestion( $sentence_id, $user_id );
}
if (isset($_SESSION['tm_language_id']) && isset($_SESSION['tm_id'])) {
$language_id = $_SESSION['tm_language_id'];
if(isset($_POST['offset']))
$offset = $_POST['offset'];
// SQL for marking the suggestion sentence failed if time more than 5 minutes of submission
$sats_suggestions_obj->makeSelfAssessmentTestSuggestionsFailedOverMaxTime();
//Code for fetching all the sentence ID those are having 3 success suggestions and update those sentences is suggestion completed status to 1
$sats_suggestions_obj->update_all_previous_self_assessment_test_sentence_suggestion_completed();
//checking currently suggested sentence
$not_in_id_str = $sats_suggestions_obj->getCurrentlyAssignedSatsSuggestionsSentenceIds();
//get user skipped sentence ids
$skipped_ids = $sats_suggestions_obj->getSkippedSelfAssessmentTestSentenceIdsByUserID( $user_id );
//fetching the self assessment test sentence for suggestion
$result = $sats_suggestions_obj->getSelfAssessmentTestSentenceForSuggestion( $language_id, $user_id, $not_in_id_str, $skipped_ids );
if ($result->num_rows > 0) {
$data['status'] = 200;
while ($row = $result->fetch_object()) {
$sentence_id = $row->id;
//Code for checking active suggestions
$active_suggestions_count = $sats_suggestions_obj->getSelfAssessmentTestActiveSuggestionsCountBySentenceId( $sentence_id );
//Code for checking if user is refreshing the page in 5 minutes
$result2 = $sats_suggestions_obj->checkSelfAssesmentTestIsUserRefreshedPage( $sentence_id, $user_id );
if ($result2->num_rows == 0 && $active_suggestions_count < $sentence_suggestion_max_assign_value) {
//Initial assign sentence to user for translation
$last_inserted_id = $sats_suggestions_obj->insertInitialSelfAssessmentTestSentenceSuggestionAndGetId($sentence_id,$user_id,$global_time_mins);
} elseif( $result2->num_rows >= 1 ){
$row2 = $result2->fetch_object();
$last_inserted_id = $row2->id;
} elseif( $active_suggestions_count >= $sentence_suggestion_max_assign_value ) {
//get next sentence for translation
$result_next = $sats_suggestions_obj->getSelfAssessmentTestNextSentenceForTranslation( $language_id, $user_id );
$row_next = $result_next->fetch_object();
$sentence_id = $row_next->id;
//Initial assign sentence to user for translation
$last_inserted_id = $sats_suggestions_obj->insertInitialSelfAssessmentTestSentenceSuggestionAndGetId($sentence_id,$user_id,$global_time_mins);
}
// database "Unlock Sentence" event will unlock all the locked sentences after 5 minutes
$sent = $row->id.'~'.$last_inserted_id;
$data['id'] = base64_encode($sent);
$data['original_message'] = stripslashes($row->original_message);
$data['translated_message'] = stripslashes($row->translated_message);
}
}
}
echo json_encode($data);