Add compilation fixes see BT#15698

pull/2970/head
Julio Montoya 6 years ago
parent e13c12ed89
commit 8874f72f5f
  1. 73
      main/inc/lib/Compilatio.php
  2. 10
      main/plagiarism/compilatio/compilatio_ajax.php
  3. 27
      main/plagiarism/compilatio/download.php
  4. 2
      main/plagiarism/compilatio/upload.php
  5. 15
      main/work/work.lib.php
  6. 7
      main/work/work_list_all.php

@ -463,50 +463,30 @@ class Compilatio
/**
* Method for display the PomprseuilmankBar (% de plagiat).
*
* @param $percentagePumping
* @param $index
* @param $weakThreshold
* @param $highThreshold
* @param $chemin_images
* @param $text : array includes the extract from the text
*
* @return string
*/
public static function getPomprankBarv31(
$pourcentagePompage,
$index,
$weakThreshold,
$highThreshold,
$chemin_images = '',
$texte = ''
$highThreshold
) {
$pourcentagePompage = round($pourcentagePompage);
$pour = round((50 * $pourcentagePompage) / 100);
$index = round($index);
$pour = round((50 * $index) / 100);
$return = '';
if ($pourcentagePompage < $weakThreshold) {
$couleur = 'vert';
$class = 'error';
if ($index < $weakThreshold) {
$class = 'success';
} else {
if ($pourcentagePompage >= $weakThreshold && $pourcentagePompage < $highThreshold) {
$couleur = 'orange';
} else {
$couleur = 'rouge';
if ($index >= $weakThreshold && $index < $highThreshold) {
$class = 'warning';
}
}
$return .= "<div style='float:left;margin-right:2px;'><img src='"
.$chemin_images."mini-drapeau_$couleur.png' title='"
.$texte['result']
."' alt='faible' width='15' height='15' /></div>";
$return .= "<div style='float:left; margin-right:5px;width:45px;text-align:right;'>"
.$pourcentagePompage
." %</div>";
$return .= "<div style='float:left;background:transparent url("
.$chemin_images
."mini-jauge_fond.png) no-repeat scroll 0;height:12px;margin-top:5px;padding:0 0 0 2px;width:55px;'>";
$return .= "<div style='float:left;background:transparent url("
.$chemin_images
."mini-jauge_"
.$couleur
.".png) no-repeat scroll 0;height:12px;width:"
.$pour
."px'></div></div>";
$return .= Display::label($index.'% - '.$pour, $class);
return $return;
}
@ -553,7 +533,6 @@ class Compilatio
{
$documentId = (int) $documentId;
$courseId = (int) $courseId;
$compilatioId = (int) $compilatioId;
$table = Database::get_course_table(TABLE_PLAGIARISM);
$params = [
@ -565,31 +544,31 @@ class Compilatio
}
/**
* @param int $itemId
* @param int $documentId
* @param int $courseId
*
* @return int
* @return string md5 value
*/
public function getCompilatioId($itemId, $courseId)
public function getCompilatioId($documentId, $courseId)
{
$itemId = (int) $itemId;
$documentId = (int) $documentId;
$courseId = (int) $courseId;
$table = Database::get_course_table(TABLE_PLAGIARISM);
$sql = "SELECT compilatio_id FROM $table
WHERE document_id = $itemId AND c_id= $courseId";
$compiSqlResult = Database::query($sql);
$result = Database::fetch_object($compiSqlResult);
WHERE document_id = $documentId AND c_id= $courseId";
$result = Database::query($sql);
$result = Database::fetch_object($result);
if ($result) {
return (int) $result->compilatio_id;
return (string) $result->compilatio_id;
}
return 0;
}
/**
* @param $workId
* @param int $workId
*
* @return string
*/
@ -624,12 +603,10 @@ class Compilatio
$actionCompilatio .= self::getPomprankBarv31(
$soapRes->documentStatus->indice,
10,
35,
$compilatioImgFolder,
$text
35
)
."<br/><a href='".$urlRapport."' target='_blank'>"
.get_lang('compilatioSeeReport')
.get_lang('CompilatioAnalysis')
."</a>";
break;
case 'ANALYSE_PROCESSING':
@ -651,11 +628,11 @@ class Compilatio
break;
case 'ANALYSE_IN_QUEUE':
$loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
$actionCompilatio .= $loading.'&nbsp;'.get_lang('compilatioAwaitingAnalysis');
$actionCompilatio .= $loading.'&nbsp;'.get_lang('CompilatioAwaitingAnalysis');
break;
case 'BAD_FILETYPE':
$actionCompilatio .= get_lang('CompilatioFileIsNotSupported')
."<br/>"
.'<br/>'
.get_lang('CompilatioProtectedPdfVerification');
break;
case 'BAD_FILESIZE':

@ -7,12 +7,12 @@ api_protect_course_script();
if (isset($_GET['workid'])) {
$workIdList = $_GET['workid']; // list of workid separate by the :
$result = '';
$tabWorkId = explode('a', $workIdList);
$workList = explode('a', $workIdList);
$compilatio = new Compilatio();
for ($i = 0; $i < count($tabWorkId); $i++) {
if (is_numeric($tabWorkId[$i])) {
$result .= $compilatio->giveWorkIdState($tabWorkId[$i]);
$result = '';
foreach ($workList as $workId) {
if (!empty($workId)) {
$result .= $compilatio->giveWorkIdState($workId);
}
}
echo $result;

@ -11,10 +11,9 @@ exit;
*
* @package chamilo.work
*/
session_cache_limiter('public');
require_once '../../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$current_course_tool = TOOL_STUDENTPUBLICATION;
$this_section = SECTION_COURSES;
// IMPORTANT to avoid caching of documents
@ -28,36 +27,36 @@ $id = (int) $_GET['id'];
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
api_not_allowed(true);
api_not_allowed(true);
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($courseInfo['real_id'])) {
$courseId = $courseInfo['real_id'];
$sql = "SELECT * FROM $tbl_student_publication
$sql = "SELECT * FROM $tbl_student_publication
WHERE c_id = $courseId AND id = $id";
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = $courseInfo['course_sys_path'].$row['url'];
$item_info = api_get_item_property_info($courseId, 'work', $row['id']);
if (empty($item_info)) {
exit;
}
if ($courseInfo['show_score'] == 0 || $item_info['visibility'] == 1 && $row['accepted'] == 1 &&
if ($courseInfo['show_score'] == 0 || $item_info['visibility'] == 1 && $row['accepted'] == 1 &&
($row['user_id'] == api_get_user_id() || api_is_allowed_to_edit())
) {
$title = str_replace(' ', '_', $row['title']);
$title = str_replace(' ', '_', $row['title']);
Event::event_download($title);
if (Security::check_abs_path($full_file_name, $courseInfo['course_sys_path'])) {
DocumentManager::file_send_for_download($full_file_name, true, $title);
}
} else {
if (Security::check_abs_path($full_file_name, $courseInfo['course_sys_path'])) {
DocumentManager::file_send_for_download($full_file_name, true, $title);
}
} else {
api_not_allowed();
}
}
}
}
exit;

@ -125,8 +125,6 @@ function sendDocument($documentId, $courseInfo)
$compilatioId = $compilatio->sendDoc($doc->title, '', $filename, $mime, file_get_contents($filePath));
}
var_dump($compilatioId);
if (Compilatio::isMd5($compilatioId)) {
$compilatio->saveDocument($courseId, $doc->id, $compilatioId);
$compilatio->startAnalyse($compilatioId);

@ -2040,11 +2040,10 @@ function get_work_user_list(
if ($qualification_exists) {
$feedback .= ' ';
}
$feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang(
'View'
).'">'.
$count.' '.Display::returnFontAwesomeIcon('comments-o').'</a> ';
$feedback .= Display::url(
$count.' '.Display::returnFontAwesomeIcon('comments-o'),
$url.'view.php?'.api_get_cidreq().'&id='.$item_id
);
}
$correction = '';
@ -2235,13 +2234,11 @@ function get_work_user_list(
if (!empty($compilation)) {
$compilationId = $compilation->getCompilatioId($item_id, $course_id);
$workDirectory = api_get_path(SYS_COURSE_PATH).$course_info['directory'];
if ($compilationId) {
$actionCompilatio = "<div id='id_avancement".$item_id."'>
".$loading."&nbsp;".get_lang('CompilatioConnectionWithServer')
."</div>";
".$loading.'&nbsp;'.get_lang('CompilatioConnectionWithServer').'</div>';
} else {
$workDirectory = api_get_path(SYS_COURSE_PATH).$course_info['directory'];
if (!Compilatio::verifiFileType($dbTitle)) {
$actionCompilatio = get_lang('CompilatioFileIsNotSupported');
} elseif (filesize($workDirectory.'/'.$work['url']) > $compilation->getMaxFileSize()) {

@ -559,9 +559,9 @@ if ($allowAntiPlagiarism) {
var msgWaitJS = '<?php echo Display::return_message(get_lang('PleaseWaitThisCouldTakeAWhile')); ?>';
var div = document.createElement('div');
var referent = document.getElementById('compilation-results');
var Analyse = '<?php echo get_lang('compilatioAnalyse'); ?>';
var compiReport = '<?php echo get_lang('compilatioSeeReport'); ?>';
var compiNonToAnalyse = '<?php echo Display::return_message(get_lang('compilatioNonToAnalyse'), 'error'); ?>';
var Analyse = '<?php echo get_lang('CompilatioAnalysis'); ?>';
var compiReport = '<?php echo get_lang('CompilatioSeeReport'); ?>';
var compiNonToAnalyse = '<?php echo Display::return_message(get_lang('CompilatioNonToAnalyse'), 'error'); ?>';
var clickTrigger = false;
function compilatioInit() {
@ -613,7 +613,6 @@ if ($allowAntiPlagiarism) {
type: "get",
dataType: "html",
success: function (message) {
console.log(message);
allWorkId += itemId + "a";
compilatioInit();
if (message.trim() != "") {

Loading…
Cancel
Save