| 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;
require_once('functions.real_sentences_suggestions.php');
$real_sentences_sugg_obj = new Real_sentences_suggestions();
require_once('functions.real_sentences_voting.php');
$real_sentences_voting_obj = new Real_sentences_voting();
$user_id = $_SESSION['tm_id'];
$voting_max_submit_time_mins = $real_sentences_voting_obj->getVotingMaxSubmiTimeMins();
$max_voting_count = $real_sentences_voting_obj->getMaxNoOfVotingCount();
//ini_set('display_errors',1);
//error_reporting(E_ALL);
?>
<div class="col-lg-12">
<div id="accordion">
<?php
$rs_language_id = $_SESSION['tm_language_id'];
$real_sentences_file_id = $_GET['rs_file_id'];
//get language direction text alignment
$language_direction_alignment = $real_sentences_voting_obj->getLanguageDirectionAlignment( $rs_language_id );
// SQL for marking the suggestion sentence failed if time more than 5 minutes of submission
$real_sentences_sugg_obj->makeRealSentenceSuggestionsFailedOverMaxTime();
//SQL for marking the voting failed if time more than 5 minutes of submission
$real_sentences_voting_obj->makeRealSentenceVotingFailedMaxSubmitTimeOver();
//Code for fetching all the sentence ID those are having 3 success suggestions and update those sentences is suggestion completed status to 1
$real_sentences_sugg_obj->update_all_previous_real_sentences_suggestion_completed();
//get currently assigned real sentences suggestions sentence ids
$not_in_assigned_suggestions_sentence_id_str = $real_sentences_sugg_obj->getCurrentlyAssignedRealSentencesSuggestionsSentenceIds();
//get user submitted success suggestions sentence ids from real_sentences_suggestions db table
$not_in_user_suggestion_id_str = $real_sentences_sugg_obj->getUserSuccessSuggestionsSentenceIdsByUserId( $user_id );
//get user submitted success voting sentence ids
$not_in_user_voting_id_str = $real_sentences_voting_obj->getUserSuccessVotingSentenceIdsByUserId( $user_id );
//checking currently assigned sentence for voting
$not_in_assigned_voting_sentence_id_str = $real_sentences_voting_obj->getCurrentlyAssignedRealSentenceIdsForVoting( $max_voting_count );
//get user skipped sentence ids
$skipped_sentence_ids = $real_sentences_sugg_obj->getSkippedRealSentenceIdsByUserID( $user_id );
//$real_sentences_file_id = 2;
//$sql_get_real_sentences = "SELECT * FROM real_sentences WHERE language_id = " . $rs_language_id . " AND real_sentences_file_id = ". $real_sentences_file_id ." AND id NOT IN ( {$not_in_user_suggestion_id_str} ) AND id NOT IN ( {$not_in_user_voting_id_str} ) AND id NOT IN ( {$not_in_assigned_suggestions_sentence_id_str} ) AND id NOT IN ( {$not_in_assigned_voting_sentence_id_str} ) AND id NOT IN ( {$skipped_sentence_ids} ) AND is_voting_completed = 0 ORDER BY id ";
//get all sentences from document
$sql_get_real_sentences = "SELECT * FROM real_sentences WHERE language_id = " . $rs_language_id . " AND real_sentences_file_id = ". $real_sentences_file_id ." ORDER BY id ";
$result_real_sentences = $mysqli->query( $sql_get_real_sentences );
if( $result_real_sentences->num_rows > 0 ) {
$i = 0;
//get one sentence from document which is available for suggestion or voting
$sql_get_real_sentence_to_assign = "SELECT * FROM real_sentences WHERE language_id = " . $rs_language_id . " AND real_sentences_file_id = ". $real_sentences_file_id ." AND id NOT IN ( {$not_in_user_suggestion_id_str} ) AND id NOT IN ( {$not_in_user_voting_id_str} ) AND id NOT IN ( {$not_in_assigned_suggestions_sentence_id_str} ) AND id NOT IN ( {$not_in_assigned_voting_sentence_id_str} ) AND id NOT IN ( {$skipped_sentence_ids} ) AND is_voting_completed = 0 ORDER BY id LIMIT 1 ";
$result_real_sentence_to_assign = $mysqli->query( $sql_get_real_sentence_to_assign );
$rs_to_assign_id = 0;
if( $result_real_sentence_to_assign->num_rows > 0 ) {
while( $row_real_sentences_to_assign = $result_real_sentence_to_assign->fetch_object() ) {
$rs_to_assign_id = $row_real_sentences_to_assign->id;
}
}
while( $row_real_sentences = $result_real_sentences->fetch_object() ) {
$i++;
//get real sentence status background color
$rs_bg_color = $real_sentences_voting_obj->getRealSentenceStatusBgColor( $row_real_sentences->id );
//if( $i == 1 ) {
if( $row_real_sentences->id == $rs_to_assign_id ) {
$area_expanded = 'true';
$collapse = 'show';
$collapsed = '';
} else {
$area_expanded = 'false';
$collapse = '';
$collapsed = 'collapsed';
}
?>
<div class="card">
<!-- Original Sentence -->
<div class="card-header" id="heading<?php echo $i; ?>" style="background-color: <?php echo $rs_bg_color; ?>">
<h5 class="mb-0">
<button class="btn btn-link <?php echo $collapsed; ?> text-decoration-none btn-sentence-heading" data-toggle="collapse" data-target="#collapse<?php echo $i; ?>" aria-expanded="<?php echo $area_expanded; ?>" aria-controls="collapse<?php echo $i; ?>" style="text-transform: none;">
<?php echo $row_real_sentences->original_sentence; ?>
</button>
</h5>
</div>
<?php
//if( $i == 1 ) {
if( $row_real_sentences->id == $rs_to_assign_id ) {
?>
<div id="collapse<?php echo $i; ?>" class="collapse <?php echo $collapse; ?>" aria-labelledby="heading<?php echo $i; ?>" data-parent="#accordion">
<div class="card-body">
<?php
//get real sentences success suggestions count for sentence
$success_suggestions_count = $real_sentences_sugg_obj->getRealSentencesSuccessSuggestionsCountBySentenceId( $row_real_sentences->id );
?>
<?php
if( $success_suggestions_count < 3 ) {
//check if sentence is not already assigned to user for suggestion
$result2 = $real_sentences_sugg_obj->checkRealSentenceAsissngedToUserForSuggestion( $row_real_sentences->id, $user_id );
if ( $result2->num_rows == 0 ) {
//Initial assign sentence to user for submit suggestion
$last_inserted_id = $real_sentences_sugg_obj->insertInitialRealSentenceSuggestionAndGetId( $row_real_sentences->id, $user_id, $global_time_mins );
} elseif( $result2->num_rows >= 1 ){
$row2 = $result2->fetch_object();
$last_inserted_id = $row2->id;
}
?>
<div class="accordion-suggestion-div">
<div>
Translated Sentence
</div>
<div class="mt-2 mb-2 <?php echo $language_direction_alignment; ?>">
<?php echo $row_real_sentences->translated_sentence; ?>
</div>
<!-- input states -->
<div class="form-group">
<textarea class="form-control <?php echo $language_direction_alignment; ?>" rows="5" placeholder="Suggest a better translation" id="suggestion"></textarea>
<input type="hidden" id="rs_id" value="<?php echo $row_real_sentences->id; ?>" />
<input type="hidden" id="rss_id" value="<?php echo $last_inserted_id; ?>" />
</div>
<div class="display-flex mobile-justify-center">
<button type="button" id="btn-skip-suggestion" class="btn btn-info waves-effect waves-light">Skip Suggestion</button>
<button type="button" id="btn-submit-suggestion" class="btn btn-success waves-effect waves-light">Submit Suggestion</button>
</div>
</div>
<?php } else {
//get user empty vote count
$user_empty_vote_count = $real_sentences_voting_obj->get_user_empty_vote_count_by_real_sentence_id_and_user_id( $row_real_sentences->id, $user_id );
//check user empty vote count
if( $user_empty_vote_count == 0 ) {
//Insert initial user vote entry into self_assessment_test_sentence_voting table
$real_sentences_voting_obj->saveInitialUserRealSentenceVoteEntry( $row_real_sentences->id, $user_id, $voting_max_submit_time_mins );
}
?>
<div class="accordion-voting-div">
<?php
//get real sentences success suggestions
$success_suggestions_result = $real_sentences_sugg_obj->getRealSentencesSuccessSuggestionsBySentenceId( $row_real_sentences->id );
while( $row_suggestions = $success_suggestions_result->fetch_object() ) {
?>
<div class="form-group">
<div class="custom-control custom-radio <?php echo $language_direction_alignment; ?>">
<input class="custom-control-input suggestion-radio-input" type="radio" value="<?php echo $row_real_sentences->id; ?>_<?php echo $row_suggestions->id; ?>" id="customRadio_<?php echo $row_real_sentences->id; ?>_<?php echo $row_suggestions->id; ?>" name="suggestionRadio">
<label for="customRadio_<?php echo $row_real_sentences->id; ?>_<?php echo $row_suggestions->id; ?>" class="custom-control-label"><?php echo $row_suggestions->suggested_text; ?></label>
</div>
</div>
<?php } ?>
<!-- None of the above translated correctly Option -->
<div class="form-group">
<div class="custom-control custom-radio <?php echo $language_direction_alignment; ?>">
<input class="custom-control-input suggestion-radio-input" type="radio" value="<?php echo $row_real_sentences->id; ?>_<?php echo 'none'; ?>" id="customRadio_suggestion_none" name="suggestionRadio">
<label for="customRadio_suggestion_none" class="custom-control-label">None of the above is translated correctly.</label>
</div>
</div>
<div class="display-flex mobile-justify-center">
<input type="hidden" id="rs_id" value="<?php echo $row_real_sentences->id; ?>" />
<!--button type="button" id="btn-skip-vote" class="btn btn-info waves-effect waves-light">Skip Vote</button-->
<button type="button" class="btn btn-success waves-effect waves-light btn-submit-vote">Submit Vote</button>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php } ?>
</div>
<?php }
} else {
echo "No sentences found!";
}
?>
</div>
</div>