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

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

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

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

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

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

Loading…
Cancel
Save