Merge compilatio branch

pull/2970/head
Julio Montoya 6 years ago
commit 004490f79e
  1. 17
      main/admin/configure_extensions.php
  2. 6
      main/admin/settings.php
  3. 8
      main/cron/import_csv.php
  4. 52
      main/inc/ajax/model.ajax.php
  5. 2
      main/inc/lib/api.lib.php
  6. 1
      main/inc/lib/database.constants.inc.php
  7. 16
      main/inc/lib/display.lib.php
  8. 29
      main/install/configuration.dist.php
  9. 687
      main/plagiarism/compilatio/Compilatio.php
  10. 62
      main/plagiarism/compilatio/compiladmin.php
  11. BIN
      main/plagiarism/compilatio/compilatio.gif
  12. 17
      main/plagiarism/compilatio/compilatio_ajax.php
  13. BIN
      main/plagiarism/compilatio/compilatio_na.gif
  14. 30
      main/plagiarism/compilatio/config.php
  15. 61
      main/plagiarism/compilatio/download.php
  16. 236
      main/plagiarism/compilatio/upload.php
  17. 49
      main/work/work.lib.php
  18. 333
      main/work/work_list_all.php

@ -341,6 +341,23 @@ Display::display_header($nameTool);
</div>
</div>
*/ ?>
<!-- COMPILATIO JLUCAS -->
<div id="main_compilatio">
<div id="extension_header_compilatio" class="accordion_header">
<a href="#"><?php echo get_lang('compilatioPlagiarismDetector');?></a>
</div>
<div id="extension_content_compilatio" style="display:none;padding:0;width:780px;" class="accordion_content">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<iframe frameborder="0" width="780" height="480" src="../plagiarism/compilatio/compiladmin.php"></iframe>
</td>
</tr>
</table>
</div>
</div>
</div><!-- /content -->
<?php

@ -381,6 +381,9 @@ $action_images['shibboleth'] = 'shibboleth.png';
$action_images['facebook'] = 'facebook.png';
$action_images['crons'] = 'crons.png';
$action_images['webservices'] = 'webservices.png';
if (api_get_configuration_value('allow_compilatio_tool')) {
$action_images['plagiarism'] = 'plagiarism.png';
}
$action_array = [];
$resultcategories = [];
@ -407,6 +410,9 @@ $resultcategories[] = ['category' => 'Shibboleth'];
$resultcategories[] = ['category' => 'Facebook'];
$resultcategories[] = ['category' => 'Crons'];
$resultcategories[] = ['category' => 'WebServices'];
if (api_get_configuration_value('allow_compilatio_tool')) {
$resultcategories[] = ['category' => 'Plagiarism'];
}
foreach ($resultcategories as $row) {
$url = [];

@ -1226,16 +1226,12 @@ class ImportCsv
$update = false;
$item = null;
if (!isset($event[$extraFieldName])) {
$this->logger->addInfo(
"No external_calendar_itemID found. Skipping ..."
);
$this->logger->addInfo('No external_calendar_itemID found. Skipping ...');
continue;
} else {
$externalEventId = $event[$extraFieldName];
if (empty($externalEventId)) {
$this->logger->addInfo(
"external_calendar_itemID was set but empty. Skipping ..."
);
$this->logger->addInfo('external_calendar_itemID was set but empty. Skipping ...');
continue;
}

@ -1215,6 +1215,10 @@ switch ($action) {
);
break;
case 'get_work_user_list_all':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] === 'simple') {
$columns = [
'fullname',
@ -1222,18 +1226,20 @@ switch ($action) {
'qualification',
'sent_date',
'qualificator_id',
'correction',
'actions',
];
'correction',
];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else {
$columns = [
'fullname',
'title',
'qualification',
'sent_date',
'correction',
'actions',
'correction',
];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
}
$whereCondition = " AND $whereCondition ";
@ -1248,12 +1254,21 @@ switch ($action) {
);
break;
case 'get_work_user_list_others':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] === 'simple') {
$columns = [
'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions',
'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id',
];
} else {
$columns = ['type', 'firstname', 'lastname', 'title', 'sent_date', 'actions'];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else {
$columns = array('type', 'firstname', 'lastname', 'title', 'sent_date');
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
}
if (trim($whereCondition) === '1 = 1') {
@ -1271,14 +1286,21 @@ switch ($action) {
);
break;
case 'get_work_user_list':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] == 'simple') {
$columns = [
'type', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions',
$columns = [
'type', 'title', 'qualification', 'sent_date', 'qualificator_id'
];
} else {
$columns = ['type', 'title', 'qualification', 'sent_date', 'actions'];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else {
$columns = ['type', 'title', 'qualification', 'sent_date'];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
}
$documents = getAllDocumentToWork($work_id, api_get_course_int_id());
if (trim($whereCondition) === '1 = 1') {
@ -1286,7 +1308,7 @@ switch ($action) {
}
if (empty($documents)) {
$whereCondition .= " AND u.user_id = ".api_get_user_id();
$whereCondition .= ' AND u.user_id = '.api_get_user_id();
$result = get_work_user_list(
$start,
$limit,
@ -2301,7 +2323,7 @@ $allowed_actions = [
'get_exercise_categories',
];
//5. Creating an obj to return a json
// 5. Creating an obj to return a json
if (in_array($action, $allowed_actions)) {
$response = new stdClass();
$response->page = $page;

@ -150,6 +150,7 @@ define('TOOL_NOTEBOOK', 'notebook');
define('TOOL_ATTENDANCE', 'attendance');
define('TOOL_COURSE_PROGRESS', 'course_progress');
define('TOOL_PORTFOLIO', 'portfolio');
define('TOOL_PLAGIARISM', 'compilatio');
// CONSTANTS defining Chamilo interface sections
define('SECTION_CAMPUS', 'mycampus');
@ -2258,6 +2259,7 @@ function api_format_course_array($course_data)
$_course['registration_code'] = !empty($course_data['registration_code']) ? sha1($course_data['registration_code']) : null;
$_course['disk_quota'] = $course_data['disk_quota'];
$_course['course_public_url'] = $webCourseHome.'/index.php';
$_course['course_sys_path'] = $courseSys.'/';
if (array_key_exists('add_teachers_to_sessions_courses', $course_data)) {
$_course['add_teachers_to_sessions_courses'] = $course_data['add_teachers_to_sessions_courses'];

@ -161,6 +161,7 @@ define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT', 'student_publication_assignment')
define('TABLE_STUDENT_PUBLICATION_REL_DOCUMENT', 'student_publication_rel_document');
define('TABLE_STUDENT_PUBLICATION_REL_USER', 'student_publication_rel_user');
define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT', 'student_publication_comment');
define('TABLE_PLAGIARISM', 'plagiarism_compilatio_docs');
// Course forum tables
define('TABLE_FORUM_CATEGORY', 'forum_category');

@ -1441,13 +1441,17 @@ class Display
}
}
if (api_get_configuration_value('allow_compilatio_tool')) {
$obj->gridComplete = 'function () { compilatioInit() }';
}
if (!empty($extra_params['viewrecords'])) {
$obj->viewrecords = $extra_params['viewrecords'];
}
$beforeSelectRow = null;
if (isset($extra_params['beforeSelectRow'])) {
$beforeSelectRow = "beforeSelectRow: ".$extra_params['beforeSelectRow'].", ";
$beforeSelectRow = 'beforeSelectRow: '.$extra_params['beforeSelectRow'].', ';
unset($extra_params['beforeSelectRow']);
}
@ -1507,6 +1511,16 @@ class Display
$json_encode = str_replace('"formatter":"extra_formatter"', 'formatter:extra_formatter', $json_encode);
$json_encode = str_replace(['{"first":"first",', '"end":"end"}'], '', $json_encode);
if (api_get_configuration_value('allow_compilatio_tool') &&
(strpos($_SERVER['REQUEST_URI'], 'work/work.php') !== false ||
strpos($_SERVER['REQUEST_URI'], 'work/work_list_all.php') != false
)
) {
$json_encode = str_replace('"function () { compilatioInit() }"',
'function () { compilatioInit() }',
$json_encode
);
}
// Creating the jqgrid element.
$json .= '$("#'.$div_id.'").jqGrid({';
//$json .= $beforeSelectRow;

@ -1242,6 +1242,35 @@ $_configuration['required_extra_fields_in_profile'] = [
// Show languages flags by country in the language switcher.
//$_configuration['language_flags_by_country'] = false;
// Allow compilatio plagiarism prevention tool
/*
CREATE TABLE c_plagiarism_compilatio_docs (
id INT AUTO_INCREMENT NOT NULL,
c_id int(11) NOT NULL,
document_id int(11) NOT NULL,
compilatio_id varchar(32) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
// If table exists already
ALTER TABLE c_plagiarism_compilatio_docs drop primary key;
ALTER TABLE c_plagiarism_compilatio_docs ADD COLUMN id INT AUTO_INCREMENT NOT NULL PRIMARY KEY;
ALTER TABLE c_plagiarism_compilatio_docs CHANGE COLUMN id_doc document_id INT NOT NULL;*/
//$_configuration['allow_compilatio_tool'] = false;
//$_configuration['compilatio_tool'] = [
// 'settings' => [
// 'key' => '',
// 'soap_url' => '',
// 'proxy_host' => '',
// 'proxy_port' => '',
// 'max_filesize' => '',
// 'transport_mode' => '',
// 'wget_uri' => '',
// 'wget_login' => '',
// 'wget_password' => '',
// ]
//];
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -0,0 +1,687 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Build the comunication with the SOAP server Compilatio.net
* call severals methods for the file management in Compilatio.net
*
* Date: 26/05/16
* @version:1.0
*/
class Compilatio
{
/** Identification key for the Compilatio account*/
public $key;
/** Webservice connection*/
public $soapcli;
private $transportMode;
private $maxFileSize;
private $wgetUri;
private $wgetLogin;
private $wgetPassword;
private $proxyHost;
private $proxyPort;
/**
* Compilatio constructor.
*
*/
public function __construct()
{
if (empty(api_get_configuration_value('allow_compilatio_tool')) ||
empty(api_get_configuration_value('compilatio_tool'))
) {
throw new Exception('Compilation not available');
}
$settings = api_get_configuration_value('compilatio_tool');
$key = $this->key = $settings['key'];
$urlsoap = $settings['soap_url'];
$proxyHost = $this->proxyHost = $settings['proxy_host'];
$proxyPort = $this->proxyPort = $settings['proxy_port'];
$this->transportMode = $settings['transport_mode'];
$this->maxFileSize = $settings['max_filesize'];
$this->wgetUri = $settings['wget_uri'];
$this->wgetLogin = $settings['wget_login'];
$this->wgetPassword = $settings['wget_password'];
try {
if (!empty($key)) {
$this->key = $key;
if (!empty($urlsoap)) {
if (!empty($proxyHost)) {
$param = array(
'trace' => false,
'soap_version' => SOAP_1_2,
'exceptions' => true,
'proxy_host' => '"'.$proxyHost.'"',
'proxy_port' => $proxyPort,
);
} else {
$param = array(
'trace' => false,
'soap_version' => SOAP_1_2,
'exceptions' => true,
);
}
$this->soapcli = new SoapClient($urlsoap, $param);
} else {
$this->soapcli = 'WS urlsoap not available';
}
} else {
$this->soapcli = 'API key not available';
}
} catch (SoapFault $fault) {
$this->soapcli = "Error constructor compilatio ".$fault->faultcode." ".$fault->faultstring;
} catch (Exception $e) {
$this->soapcli = "Error constructor compilatio with urlsoap".$urlsoap;
}
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @param mixed $key
*
* @return Compilatio
*/
public function setKey($key)
{
$this->key = $key;
return $this;
}
/**
* @return mixed
*/
public function getTransportMode()
{
return $this->transportMode;
}
/**
* @param mixed $transportMode
*
* @return Compilatio
*/
public function setTransportMode($transportMode)
{
$this->transportMode = $transportMode;
return $this;
}
/**
* @return mixed
*/
public function getMaxFileSize()
{
return $this->maxFileSize;
}
/**
* @param mixed $maxFileSize
*
* @return Compilatio
*/
public function setMaxFileSize($maxFileSize)
{
$this->maxFileSize = $maxFileSize;
return $this;
}
/**
* @return mixed
*/
public function getWgetUri()
{
return $this->wgetUri;
}
/**
* @param mixed $wgetUri
*
* @return Compilatio
*/
public function setWgetUri($wgetUri)
{
$this->wgetUri = $wgetUri;
return $this;
}
/**
* @return mixed
*/
public function getWgetLogin()
{
return $this->wgetLogin;
}
/**
* @param mixed $wgetLogin
*
* @return Compilatio
*/
public function setWgetLogin($wgetLogin)
{
$this->wgetLogin = $wgetLogin;
return $this;
}
/**
* @return mixed
*/
public function getWgetPassword()
{
return $this->wgetPassword;
}
/**
* @param mixed $wgetPassword
*
* @return Compilatio
*/
public function setWgetPassword($wgetPassword)
{
$this->wgetPassword = $wgetPassword;
return $this;
}
/**
* @return mixed
*/
public function getProxyHost()
{
return $this->proxyHost;
}
/**
* @param mixed $proxyHost
*
* @return Compilatio
*/
public function setProxyHost($proxyHost)
{
$this->proxyHost = $proxyHost;
return $this;
}
/**
* @return mixed
*/
public function getProxyPort()
{
return $this->proxyPort;
}
/**
* @param mixed $proxyPort
*
* @return Compilatio
*/
public function setProxyPort($proxyPort)
{
$this->proxyPort = $proxyPort;
return $this;
}
/**
* Method for the file load
*
* @param $title
* @param $description
* @param $filename
* @param $mimeType
* @param $content
*
* @return string
*/
public function sendDoc($title, $description, $filename, $mimeType, $content)
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$idDocument = $this->soapcli->__call(
'addDocumentBase64',
array(
$this->key,
utf8_encode(urlencode($title)),
utf8_encode(urlencode($description)),
utf8_encode(urlencode($filename)),
utf8_encode($mimeType),
base64_encode($content),
)
);
return $idDocument;
} catch (SoapFault $fault) {
return ("Erreur sendDoc()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* Method for recover a document's information
*
* @param $compiHash
*
* @return string
*/
public function getDoc($compiHash)
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$param = array($this->key, $compiHash);
$idDocument = $this->soapcli->__call('getDocument', $param);
return $idDocument;
} catch (SoapFault $fault) {
return ("Erreur getDoc()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* method for recover an url document's report
*
* @param $compiHash
*
* @return string
*/
public function getReportUrl($compiHash)
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$param = array($this->key, $compiHash);
$idDocument = $this->soapcli->__call('getDocumentReportUrl', $param);
return $idDocument;
} catch (SoapFault $fault) {
return ("Erreur getReportUrl()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* Method for deleting a Compialtio's account document
*
* @param $compiHash
*
* @return string
*/
public function deldoc($compiHash)
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$param = array($this->key, $compiHash);
$this->soapcli->__call('deleteDocument', $param);
} catch (SoapFault $fault) {
return ("Erreur deldoc()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* Method for start the analysis for a document
*
* @param $compiHash
*
* @return string
*/
public function startAnalyse($compiHash)
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$param = array($this->key, $compiHash);
$this->soapcli->__call('startDocumentAnalyse', $param);
} catch (SoapFault $fault) {
return ("Erreur startAnalyse()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* Method for recover the account's quota
* @return string
*/
public function getQuotas()
{
try {
if (!is_object($this->soapcli)) {
return ("Error in constructor compilatio() ".$this->soapcli);
}
$param = array($this->key);
$resultat = $this->soapcli->__call('getAccountQuotas', $param);
return $resultat;
} catch (SoapFault $fault) {
return ("Erreur getQuotas()".$fault->faultcode." ".$fault->faultstring);
}
}
/**
* Method for identify a file extension and the possibility that the document can be managed by Compilatio
*
* @param $filename
*
* @return bool
*/
public static function verifiFileType($filename)
{
$types = array('doc', 'docx', 'rtf', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'pdf', 'txt', 'htm', 'html');
$extension = substr($filename, strrpos($filename, '.') + 1);
$extension = strtolower($extension);
return in_array($extension, $types);
}
/**
* Fonction affichage de la barre de progression d'analyse version 3.1
*
* @param string $status From the document
* @param $pour
* @param string $imagesPath
* @param array $text Array includes the extract from the text
*
* @return unknown_type
*/
public static function getProgressionAnalyseDocv31($status, $pour = 0, $imagesPath = '', $text = [])
{
$refreshReturn = "<a href='javascript:window.location.reload(false);'><img src='"
.$imagesPath
."ajax-loader_green.gif' title='"
.$text['refresh']
."' alt='"
.$text['refresh']
."'/></a> ";
$startReturn = "<table cellpadding='0' cellspacing='0' style='border:0;margin:0;padding:0;'><tr>";
$startReturn .= "<td width='25' style='border:0;margin:0;padding:0;'>&nbsp;</td>";
$startReturn .= "<td valign='middle' align='right' style='border:0;margin:0;padding-right:10px;'>"
.$refreshReturn
."</td>";
$startReturn .= "<td style='border:0;margin:0;padding:0;'>";
$startReturnLittleWidth = "<table cellpadding='0' cellspacing='0' style='border:0;margin:0;padding:0;'><tr>";
$startReturnLittleWidth .= "<td width='25' valign='middle' align='right' style='border:0;margin:0;padding:0;'>"
.$refreshReturn
."</td>";
$finretour = "</td></tr></table>";
if ($status == 'ANALYSE_IN_QUEUE') {
return $startReturn."<span style='font-size:11px'>".$text['analysisinqueue']."</span>".$finretour;
}
if ($status == 'ANALYSE_PROCESSING') {
if ($pour == 100) {
return $startReturn
."<span style='font-size:11px'>"
.$text['analysisinfinalization']
."</span>"
.$finretour;
} else {
return $startReturnLittleWidth
."<td align=\"right\" style=\"border:0;margin:0;padding-right:10px;\">"
.$pour
."%</td><td style=\"border:0;margin:0;padding:0;\"><div style=\"background"
.":transparent url("
.$imagesPath
."mini-jauge_fond.png) no-repeat scroll 0;height:12px;padding:0 0 0 2px;width:55px;\"><div style=\""
."background:transparent url("
.$imagesPath
."mini-jauge_gris.png) no-repeat scroll 0;height:12px;width:"
.$pour / 2
."px;\"></div></div>"
.$finretour;
}
}
}
/**
* Method for display the PomprseuilmankBar (% de plagiat)
*
* @param $percentagePumping
* @param $weakThreshold
* @param $highThreshold
* @param $imagesPath
* @param $text : array includes the extract from the text
*
* @return unknown_type
*/
public static function getPomprankBarv31($pourcentagePompage, $weakThreshold, $highThreshold, $chemin_images = '', $texte = '')
{
$pourcentagePompage = round($pourcentagePompage);
$pour = round((50 * $pourcentagePompage) / 100);
$return = '';
if ($pourcentagePompage < $weakThreshold) {
$couleur = "vert";
} else {
if ($pourcentagePompage >= $weakThreshold && $pourcentagePompage < $highThreshold) {
$couleur = "orange";
} else {
$couleur = "rouge";
}
}
$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 $return;
}
/**
* Method for validation of hash
* @param $hash
* @return bool
*
*/
public static function isMd5($hash)
{
return preg_match('`^[a-f0-9]{32}$`', $hash);
}
/*
* Method for identify Internet media type
* @param $filename
*/
public static function typeMime($filename)
{
if (preg_match("@Opera(/| )([0-9].[0-9]{1,2})@", $_SERVER['HTTP_USER_AGENT'], $resultats)) {
$navigateur = "Opera";
} elseif (preg_match("@MSIE ([0-9].[0-9]{1,2})@", $_SERVER['HTTP_USER_AGENT'], $resultats)) {
$navigateur = "Internet Explorer";
} else {
$navigateur = "Mozilla";
$mime = parse_ini_file("mime.ini");
$extension = substr($filename, strrpos($filename, ".") + 1);
}
if (array_key_exists($extension, $mime)) {
$type = $mime[$extension];
} else {
$type = ($navigateur != "Mozilla") ? 'application/octetstream' : 'application/octet-stream';
}
return $type;
}
/**
* function for delete a document of the compilatio table if plagiarismTool is Compilatio
* @param int $courseId
* @param int $itemId
*/
public static function plagiarismDeleteDoc($courseId, $itemId)
{
if (api_get_configuration_value('allow_compilatio_tool')) {
return false;
}
$table = Database:: get_course_table(TABLE_PLAGIARISM);
$params = [$courseId, $itemId];
Database::delete($table, ['c_id = ? AND document_id = ?' => $params]);
}
/**
* @param int $courseId
* @param int $documentId
* @param int $compilatioId
*/
public function saveDocument($courseId, $documentId, $compilatioId)
{
$documentId = (int) $documentId;
$courseId = (int) $courseId;
$compilatioId = (int) $compilatioId;
$table = Database::get_course_table(TABLE_PLAGIARISM);
$params = [
'c_id' => $courseId,
'document_id' => $documentId,
'compilatio_id' => $compilatioId,
];
Database::insert($table, $params);
}
/**
* @param int $itemId
* @param int $courseId
*
* @return int
*/
public function getCompilatioId($itemId, $courseId)
{
$itemId = (int) $itemId;
$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);
if ($result) {
return (int) $result->compilatio_id;
}
return 0;
}
/**
* @param $workId
*
* @return string
*/
public function giveWorkIdState($workId)
{
$text = '';
$compilatioImgFolder = api_get_path(WEB_CODE_PATH).'plagiarism/compilatio/img/';
$courseId = api_get_course_int_id();
$compilatioId = $this->getCompilatioId($workId, $courseId);
$actionCompilatio = '';
if (!empty($compilatioId)) {
if (self::isMd5($compilatioId)) {
// if compilatio_id is a hash md5, we call the function of the compilatio's webservice who return the document's status
$soapRes = $this->getDoc($compilatioId);
$status = '';
if (isset($soapRes->documentStatus)) {
$status = $soapRes->documentStatus->status;
}
} else {
// if the compilatio's hash is not a valide hash md5, we return à specific status (cf : IsInCompilatio() )
$status = 'NOT_IN_COMPILATIO';
$actionCompilatio = "<div style='font-style:italic'>"
.get_lang('compilatioDocumentTextNotImage')
."<br/>"
.get_lang('compilatioDocumentNotCorrupt')
."</div>";
}
if ($status === 'ANALYSE_COMPLETE') {
$urlRapport = $this->getReportUrl($compilatioId);
$actionCompilatio .= self::getPomprankBarv31(
$soapRes->documentStatus->indice,
10,
35,
$compilatioImgFolder,
$text
)
."<br/><a href='"
.$urlRapport
."' target='_blank'>"
.get_lang('compilatioSeeReport')
."</a>";
} elseif ($status === 'ANALYSE_PROCESSING') {
$actionCompilatio .= "<div style='font-weight:bold;text-align:left'>"
.get_lang('compilatioAnalysisInProgress')
."</div>";
$actionCompilatio .= "<div style='font-size:80%;font-style:italic;margin-bottom:5px;'>"
.get_lang('compilatioAnalysisPercentage')
."</div>";
$text['analysisinqueue'] = get_lang('compilatioWaitingAnalysis');
$text['analysisinfinalization'] = get_lang('compilatioAnalysisEnding');
$text['refresh'] = get_lang('Refresh');
$actionCompilatio .= self::getProgressionAnalyseDocv31(
$status,
$soapRes->documentStatus->progression,
$compilatioImgFolder,
$text
);
} elseif ($status == 'ANALYSE_IN_QUEUE') {
$actionCompilatio .= "<img src='"
.$compilatioImgFolder
."/ajax-loader2.gif' style='margin-right:10px;' />"
.get_lang('compilatioAwaitingAnalysis');
} elseif ($status == 'BAD_FILETYPE') {
$actionCompilatio .= "<div style='font-style:italic'>"
.get_lang('compilatioFileisnotsupported')
."<br/>"
.get_lang('compilatioProtectedPdfVerification')
."</div>";
} elseif ($status == 'BAD_FILESIZE') {
$actionCompilatio .= "<div style='font-style:italic'>"
.get_lang('compilatioTooHeavyDocument')
."</div>";
} elseif ($status != 'NOT_IN_COMPILATIO') {
$actionCompilatio .= "<div style='font-style:italic'>"
.get_lang('compilatioMomentarilyUnavailableResult')
." : [ "
.$status
."].</div>";
}
}
$result = $workId.'|'.$actionCompilatio.'|'.$status.'|';
return $result;
}
}

@ -0,0 +1,62 @@
<?php
/* For licensing terms, see /license.txt */
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('default_socket_timeout', '1000');
require_once '../../inc/global.inc.php';
$compilatio = new Compilatio();
$use_space = number_format($quotas->usedSpace / 1000000, 2);
$total_space = $quotas->space / 1000000;
echo "<h3>".get_lang('compilatioDescription')."</h3>";
echo "<b>"
.get_lang('compilatioQuota')
.":"
." </b><br>"
.get_lang('compilatioCredit')
.": "
.$quotas->usedCredits
.get_lang('compilatioOn')
.$quotas->credits;
?>
<br><br>
<?
if (!isset($_GET['action']))
{
?>
<body style="margin:0px;padding:0px">
<form style="margin:0px;" method="GET">
<input type="submit" name="action" value="Test de Connexion SOAP">
</form>
<?
} else {
echo get_lang('compilatioConnectionTestSoap')."<br>";
echo "1) ".get_lang('compilatioServerConnection')."<br>";
$compilatio = new Compilatio();
if ($compilatio) {
echo get_lang('compilatioConnectionAccomplished')."<br>";
echo "2) ".get_lang('compilatioSendTextToServer')."<br>";
$text = get_lang('compilatioTestSendText').$compilatio->getKey();
$id_compi = $compilatio->SendDoc(
'Doc de test',
'test',
'test',
'text/plain',
$text
);
if (Compilatio::isMd5($id_compi)) {
echo get_lang('compilatioSuccessfulTransfer')."<br>";
} else {
echo get_lang('compilatioFailedTransfer')."<br>";
}
} else {
echo get_lang('compilatioNotConnection')."<br>";
echo get_lang('compilatioParamVerification')."<br>";
}
}
?>
</body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,17 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../../inc/global.inc.php';
if (isset($_GET['workid'])) {
$workIdList = $_GET['workid']; // list of workid separate by the :
$result = '';
$tabWorkId = explode('a', $workIdList);
$compilatio = new Compilatio();
for ($i = 0; $i < count($tabWorkId); $i++) {
if (is_numeric($tabWorkId[$i])) {
$result .= $compilatio->giveWorkIdState($tabWorkId[$i]);
}
}
echo $result;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/*Compilatio's key*/
$compilatioParameter['key'] = api_get_setting('compilatioParamKey');
$compilatioParameter['version'] = '1.2';
/* Url from soap Compilatio server */
/* You can choice the SSL version if you want */
$compilatioParameter['$urlsoap'] = api_get_setting('compilatioParamURLSoap');
/* Parameter form your server's proxy (for call SOAP), don't enter it if you dont have one */
$compilatioParameter['proxy_host'] = '';
$compilatioParameter['proxy_port'] = '';
/* Method to data transmission */
/* Nothing by default, the data transmission is done by SOAP */
/* Wget: the Compilatio's server download the file for the analysis */
$compilatioParameter['mode_transport'] = '';
/* if the selected data transmission method is wget, you can set up a special url acces */
$compilatioParameter['wget_uri'] = '';
/* If the selected data transmission method is wget, you can specify a login/password acces to the directory */
$compilatioParameter['wget_login'] = '';
$compilatioParameter['wget_password'] = '';
/*Document's maximum size*/
$compilatioParameter['max_filesize'] = 10000000; // 10Mo

@ -0,0 +1,61 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.work
*/
session_cache_limiter('public');
require_once '../../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$this_section = SECTION_COURSES;
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
api_protect_course_script(true);
$id = (int) $_GET['id'];
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
api_not_allowed(true);
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($courseInfo['real_id'])) {
$sql = 'SELECT * FROM '.$tbl_student_publication.'
WHERE c_id = '.$courseInfo['real_id'].' AND id = "'.$id.'"';
$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(api_get_course_int_id(), 'work', $row['id']);
if (empty($item_info)) {
exit;
}
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']);
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 {
api_not_allowed();
}
}
}
exit;

@ -0,0 +1,236 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../../inc/global.inc.php';
require_once '../../work/work.lib.php';
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('default_socket_timeout', '1000');
$courseId = api_get_course_int_id();
$courseInfo = api_get_course_info();
$typeMessage = 0;
$errorCodeNotValid = get_lang('compilatioError').get_lang('documentCodeNotValid');
$errorLoadError = get_lang('compilatioLoadError').get_lang('compilatioContactAdmin');
/*message to the user for be patient*/
$msgWait = get_lang('PleaseWaitThisCouldTakeAWhile');
$compilatio = new Compilatio();
/* if we have to upload severals documents*/
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'multi') {
$docs = preg_split("/a/", $_REQUEST['doc']);
for ($k = 0; $k < sizeof($docs) - 1; $k++) {
/* We have to modify the timeout server for send the heavy files */
set_time_limit(600);
$documentId = 0;
if (intval($docs[$k])) {
$documentId = (int) $docs[$k];
}
/**
* File problem in the url field that no longer have the file extension,
* Compilatio's server refuse the files
* we renames in the FS and the database with the file extension that is found in the title field
*/
compilatioUpdateWorkDocument($documentId, $courseId);
$compilatioId = $compilatio->getCompilatioId($documentId, $courseId);
if (!empty($compilatioId)) {
/*The document is already in Compilatio, we do nothing*/
} else {
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$query = "SELECT * FROM $workTable WHERE id='".$documentId."' AND c_id= $courseId";
$sqlResult = Database::query($query);
$doc = Database::fetch_object($sqlResult);
if ($doc) {
/*We load the document in compilatio through the webservice */
$currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/';
$WrkUrl = $currentCourseRepositoryWeb.$doc->url;
$LocalWrkUrl = $courseInfo['course_sys_path'].$doc->url;
$LocalWrkTitle = $doc->title;
$mime = Compilatio::typeMime($LocalWrkTitle);
if ($compilatio->getTransportMode() === 'wget') {
/*Compilatio's server recover tjre file throught wget like this:
username:password@http://somedomain.com/reg/remotefilename.tar.gz */
if (strlen($compilatio->getWgetUri()) > 2) {
$filename = preg_replace(
'/$',
'',
$compilatio->getWgetUri()
).'/'.$courseInfo['path'].'/'.$doc->url;
} else {
$filename = $WrkUrl;
}
if (strlen($compilatio->getWgetLogin()) > 2) {
$filename = $compilatio->getWgetLogin().':'.$compilatio->getWgetPassword().'@'.$filename;
}
$mime = 'text/plain';
$compilatioId = $compilatio->sendDoc($doc->title, '', $filename, $mime, 'get_url');
} else {
/* we use strictly the SOAP for the data trasmission */
$pieces = explode('/', $doc->url);
$nbPieces = count($pieces);
$filename = $pieces[$nbPieces - 1];
$compilatioId = $compilatio->sendDoc(
$doc->title,
'',
$filename,
$mime,
file_get_contents($LocalWrkUrl)
);
}
/*we associate in the database the document chamilo to the document compilatio*/
/*we verify that the docmuent's id is an hash_md5*/
if (Compilatio::isMd5($compilatioId)) {
$compilatio->saveDocument($courseId, $doc->id, $compilatioId);
$soapRes = $compilatio->startAnalyse($compilatioId);
}
}
}
}
} else {
// non multiple
$documentId = $_GET['doc'];
compilatioUpdateWorkDocument($documentId, $courseId);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$query = "SELECT * FROM $workTable
WHERE id= $documentId AND c_id= $courseId";
$sqlResult = Database::query($query);
$doc = Database::fetch_object($sqlResult);
$currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/';
$WrkUrl = $currentCourseRepositoryWeb.$doc->url;
$WrkTitle = $doc->title;
$LocalWrkUrl = $courseInfo['course_sys_path'].$doc->url;
$mime = Compilatio::typeMime($WrkTitle);
$compilatio = new Compilatio();
if ($compilatio->getTransportMode() === 'wget') {
if (strlen($compilatio->getWgetUri()) > 2) {
$filename = preg_replace('/$', '', $compilatio->getWgetUri()).'/'.$_course['path'].'/'.$doc->title;
} else {
$filename = $WrkUrl;
}
if (strlen($compilatio->getWgetLogin()) > 2) {
$filename = $compilatio->getWgetLogin().':'.$compilatio->getWgetPassword().'@'.$filename;
}
$compilatioId = $compilatio->sendDoc($doc->title, '', $filename, 'text/plain', 'get_url');
} else {
$pieces = explode('/', $doc->url);
$nbPieces = count($pieces);
$filename = $pieces[$nbPieces - 1];
$compilatioId = $compilatio->sendDoc($doc->title, '', $filename, $mime, file_get_contents($LocalWrkUrl));
}
if (Compilatio::isMd5($compilatioId)) {
$compilatio->saveDocument($courseId, $doc->id, $compilatioId);
$soapRes = $compilatio->startAnalyse($compilatioId);
Display::addFlash(Display::return_message(get_lang('Uploaded')));
} else {
Display::addFlash(Display::return_message(get_lang('Error')));
}
}
/**
* function for show and recovery the extension from a file
*
* @param $docId
* @param $courseId
*
* @return string
*/
function workDocExtension($docId, $courseId)
{
$dbTitle = getWorkTitle($docId, $courseId);
$res = getFileExtension($dbTitle);
return $res;
}
function getFileExtension($filename)
{
$res = '';
preg_match("/.*\.([^.]+)/", $filename, $dbTitle);
if (count($dbTitle) > 1) {
$res = $dbTitle[1];
}
return $res;
}
function getWorkTitle($docId, $courseId)
{
$docId = (int) $docId;
$courseId = (int) $courseId;
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT title FROM $workTable
WHERE c_id= $courseId AND id = $docId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$data = Database::fetch_array($res);
$res = $data['title'];
}
return $res;
}
function getFilename($txt)
{
$res = $txt;
preg_match('|.*/([^/]+)|', $txt, $urlList);
if (count($urlList) > 0) {
$res = $urlList[1];
}
return $res;
}
function getWorkFolder($txt)
{
$res = '';
preg_match('|(.*/)[^/]+|', $txt, $urlList);
if (count($urlList) > 0) {
$res = $urlList[1];
}
return $res;
}
function getShortFilename($txt)
{
$res = $txt;
if (strlen($txt) > 10) {
$res = substr($txt, 0, 10);
}
return $res;
}
function compilatioUpdateWorkDocument($docId, $courseId)
{
$_course = api_get_course_info();
$docId = (int) $docId;
$courseId = (int) $courseId;
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$extensionFile = workDocExtension($docId, $courseId);
$urlFile = get_work_path($docId);
$filename = getFilename($urlFile);
$work_folder = getWorkFolder($urlFile);
$urlFile_ext = getFileExtension($urlFile);
$coursePath = $_course['course_sys_path'];
$workTitle = getWorkTitle($docId, $courseId);
if ($extensionFile != '' && $urlFile_ext == '') {
/* Rename the files in the FS whit the extension*/
$shortFilename = $filename;
$cleanWorkTitle = api_replace_dangerous_char($workTitle);
$newestFilename = $shortFilename.'_'.$cleanWorkTitle;
rename($coursePath.$urlFile, $coursePath.$work_folder.$newestFilename);
/*rename the db's input with the extension*/
$sql = "UPDATE $workTable SET url='".$work_folder.$newestFilename."'
WHERE c_id=$courseId AND id=$docId";
Database::query($sql);
}
}

@ -1797,6 +1797,12 @@ function get_work_user_list(
$column = !empty($column) ? Database::escape_string($column) : 'sent_date';
$compilatio_web_folder = api_get_path(WEB_CODE_PATH).'plagiarism/compilatio/';
$compilation = null;
if (api_get_configuration_value('allow_compilatio_tool')) {
$compilation = new Compilatio();
}
if (!in_array($direction, ['asc', 'desc'])) {
$direction = 'desc';
}
@ -1952,6 +1958,10 @@ function get_work_user_list(
while ($work = Database::fetch_array($result, 'ASSOC')) {
$item_id = $work['id'];
/* JLUCAS COMPILATIO */
$dbTitle = $work['title'];
/* FIN JLUCAS COMPILATIO */
// Get the author ID for that document from the item_property table
$is_author = false;
$can_read = false;
@ -2225,7 +2235,42 @@ function get_work_user_list(
$work['qualificator_id'] = $qualificator_id.' '.$hasCorrection;
$work['actions'] = '<div class="work-action">'.$linkToDownload.$action.'</div>';
$work['correction'] = $correction;
$works[] = $work;
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."'>
<img src='".$compilatio_web_folder."/img/ajax-loader2.gif' style='margin-right:10px'/>"
.get_lang('compilatioConnectionWithServer')
."</div>";
} else {
if (!Compilatio::verifiFileType($dbTitle)) {
$actionCompilatio = "<div style='font-style:italic'>"
.get_lang('compilatioFileisnotsupported')
."</div>";
} elseif (filesize($workDirectory."/".$work['url']) > $compilation->getMaxFileSize()) {
$sizeFile = round(filesize($workDirectory."/".$work['url']) / 1000000);
$actionCompilatio = "<div style='font-style:italic'>"
.get_lang('compilatioTooHeavyDocument')
.": "
.$sizeFile
." Mo.<br/></div>";
} else {
$actionCompilatio = "<div id='id_avancement".$item_id."'>"
."<a href='javascript:void(0)' class=\"getSingleCompilatio\" onClick='getSingleCompilatio("
.$item_id
.");'>"
.get_lang('compilatioAnalyse')
." </a>"
.get_lang('compilatioWithCompilatio')
."</div>";
}
}
$work['compilatio'] = $actionCompilatio;
}
$works[] = $work;
}
}
@ -4527,6 +4572,8 @@ function deleteWorkItem($item_id, $courseInfo)
WHERE c_id = $course_id AND publication_id = $item_id";
Database::query($sql);
Compilatio::plagiarismDeleteDoc($course_id, $item_id);
api_item_property_update(
$courseInfo,
'work',

@ -209,6 +209,23 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
echo Display::toolbarAction('toolbar-worklist', [$actionsLeft]);
$plagiarismListJqgridColumn = [];
$plagiarismListJqgridLine = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
require_once api_get_path(SYS_CODE_PATH).'/plagiarism/compilatio/config.php';
$plagiarismListJqgridColumn = ['Compilatio'];
$plagiarismListJqgridLine = [
[
'name'=>'compilatio',
'index'=>'compilatio',
'width'=>'40',
'align'=>'left',
'search' => 'false',
'sortable'=>'false'
]
];
}
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
}
@ -233,9 +250,10 @@ if (!empty($work_data['enable_qualification']) &&
get_lang('Score'),
get_lang('Date'),
get_lang('Status'),
get_lang('UploadCorrection'),
get_lang('Actions'),
get_lang('UploadCorrection'),
];
$columns = array_merge($columns, $plagiarismListJqgridColumn);
$columns[] = get_lang('Actions');
$column_model = [
[
@ -284,14 +302,15 @@ if (!empty($work_data['enable_qualification']) &&
'sortable' => 'false',
'title' => 'false',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
$column_model = array_merge($column_model, $plagiarismListJqgridLine);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
];
} else {
$type = 'complex';
@ -301,8 +320,9 @@ if (!empty($work_data['enable_qualification']) &&
get_lang('Feedback'),
get_lang('Date'),
get_lang('UploadCorrection'),
get_lang('Actions'),
];
$columns = array_merge($columns, $plagiarismListJqgridColumn);
$columns[] = get_lang('Actions');
$column_model = [
[
@ -344,16 +364,17 @@ if (!empty($work_data['enable_qualification']) &&
'sortable' => 'false',
'title' => 'false',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '30',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
//'wrap_cell' => 'true',
],
];
$column_model = array_merge($column_model, $plagiarismListJqgridLine);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
];
}
$extra_params = [
@ -450,4 +471,274 @@ echo '<table style="display:none; width:100%" class="files data_table">
</tr>
</table>';
echo '</div></div></div>';
Display :: display_footer();
if (api_get_configuration_value('allow_compilatio_tool')) {
$workTable = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$courseId = $courseInfo['real_id'];
$form_action['analyseCompilatio'] = [
'label' => get_lang('compilatioStartAnalysis'),
'data-action' => get_lang('compilatioStartAnalysis'),
'onClick' => "onclick='getMultiCompilatio()'",
];
$html = '<form id ="mes_actions" class="form-search" method="post" name="form_actions">';
$html .= '<input type="hidden" name="action">';
$html .= '<table style="width:100%;">';
$html .= '<tr>';
$html .= '<td>';
if (count($form_action) > 0) {
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn btn-default" href="?'
. '&amp;'
. "gbox_results"
. '&amp;'
. 'selectall=1" onclick="javascript: setCheckbox(true, \''
. "gbox_results". '\'); return false;">'
. get_lang('SelectAll')
. '</a>';
$html .= '<a class="btn btn-default" href="?'
. '" onclick="javascript: setCheckbox(false, \''
. "gbox_results"
. '\'); return false;">'
. get_lang('UnSelectAll')
. '</a> ';
$html .= '</div>';
$html .= '<div class="btn-group">
<button class="btn btn-default" onclick="javascript:return false;">'
. get_lang('Actions')
. '</button>'
. '<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
. '<span class="caret"></span>'
. '</button>';
$html .= '<ul class="dropdown-menu">';
/*ORIGINAL*/
// foreach ($form_action as $action => & $label) {
// $html .= '<li><a data-action ="' . $action . '" href="#" onclick="javascript:action_click(this, \'' . "gbox_results" . '\');">' . $label . '</a></li>';
// }
/*fin original*/
foreach ($form_action as $action ) {
$html .= '<li>
<a data-action ="'.$action['data-action'].'" href="#" '.$action['onClick'].'>'
.$action['label'].'</a>
</li>';
}
$html .= '</ul>';
$html .= '</div>';//btn-group
$html .= '</div>'; //toolbar
$html .= '</td></tr></table></form>';
}
echo $html;
$compTable = Database::get_course_table(TABLE_PLAGIARISM);
$listCompilatioDocId = [];
$compilatioQuery = "SELECT * FROM $compTable WHERE c_id= $courseId";
$compilatioResult = Database::query($compilatioQuery);
while ($compilatioData = Database::fetch_array($compilatioResult)) {
array_push($listCompilatioDocId, $compilatioData['document_id']);
}
$javascriptWorkId = '';
$sql = "SELECT * FROM $workTable WHERE c_id= $courseId AND parent_id= $workId AND active = 1";
$res = Database::query($sql);
while ($data = Database::fetch_array($res)) {
if (in_array($data['id'], $listCompilatioDocId)) {
$javascriptWorkId .= $data['id'].'a';
}
}
}
Display::display_footer();
?>
<!--
Lets display the javascript AJAX tools for refreshing datas that needed to be refreshed
Only document with state ANALYSE_IN_QUEUE or ANALYSE_PROCESSING need to ask server
for a new state
Hubert Borderiou - Grenoble Universites - avril 2013
-->
<script>
var xhrObject; // the htmlhttprequest object
var analyseComplete = "ANALYSE_COMPLETE";
var analyseProcessing = "ANALYSE_PROCESSING";
var analyseInQueue = "ANALYSE_IN_QUEUE";
var refreshDelaisAfter = 30000;
var allWorkId = "<?php echo $javascriptWorkId?>";
var workFolderId = "<?php echo $workId; ?>";
var compilationWebUrl = "<?php echo api_get_path(WEB_CODE_PATH) . 'plagiarism/compilatio/' ?>";
var divExisteTimer = null;
var msgWaitJS = '<?php echo Display::display_confirmation_message(get_lang('PleaseWaitThisCouldTakeAWhile')); ?>';
var div = document.createElement('div');
var referent = document.getElementById('toolbar-worklist');
var Analyse = '<?php echo get_lang('compilatioAnalyse'); ?>';
var compiReport = '<?php echo get_lang('compilatioSeeReport'); ?>';
var compiNonToAnalyse = '<?php echo Display::display_error_message(get_lang('compilatioNonToAnalyse')); ?>';
var clickTrigger = false;
function compilatioInit() {
if (isWorkFolder()) {
searchAdvancement();
setInterval("searchAdvancement()", refreshDelaisAfter);
if(!clickTrigger) {
clickTrigger = true;
$('.getSingleCompilatio').on('click', function () {
var parts = $(this).parent().attr('id').split('id_avancement');
getSingleCompilatio(parts[1]);
});
}
}
}
// true if we are in a work folder
function isWorkFolder() {
var res = false;
if (workFolderId.match(/[0-9]+/)) {
res = true;
}
return res;
}
// check all compilatio docs
function checkAllCompilatio(action) {
$("input").each(function() {
if ($(this).attr("id")) {
objId = $(this).attr("id");
listObjId = objId.match(/jqg_results_(\d+)/)
if (listObjId.length > 1) {
$(this).prop('checked', action);
}
}
});
}
function getSingleCompilatio(itemId) {
if (div.id == "status_message") {
referent.removeChild(div);
}
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
referent.appendChild(div);
$.ajax({
url: compilationWebUrl + "upload.php?doc="+itemId,
type: "get",
dataType: "html",
success: function(message) {
allWorkId += itemId+"a";
compilatioInit();
if (message.trim() != ""){
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>'+message+'</div>';
referent.appendChild(div);
}
}
});
}
function getMultiCompilatio() {
if (div.id == "status_message") {
referent.removeChild(div);
}
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
referent.appendChild(div);
multi_compilatio = "";
$("input:checked").each(function() {
if ($(this).attr("id")) {
objId = $(this).attr("id");
listObjId = objId.match(/jqg_results_(\d+)/)
if(listObjId){
objClick = document.getElementById('id_avancement'+listObjId[1]);
if (objClick){
objLink = objClick.getElementsByTagName('a');
if (objLink){
stringLink = [].map.call( objLink, function(node){
return node.textContent || node.innerText || "";
}).join("");
if(stringLink.trim() == Analyse.trim()){
if (listObjId && listObjId.length > 1) {
multi_compilatio += listObjId[1]+"a";
}
}
}
}
}
}
});
if ($("#verif")) {
$("#verif").append(multi_compilatio);
}
// run compilatio
if (multi_compilatio != "") {
$.ajax({
url: compilationWebUrl + "upload.php",
data: { doc: multi_compilatio, type: "multi"}, // on envoie $_GET['id_region'] *// idz
success: function(message) { // idz
allWorkId = multi_compilatio;//idz
compilatioInit();
if (message.trim() != ""){
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>'+message+'</div>';
referent.appendChild(div);
}
}
});
} else {
//multi_compilatio is empty
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + compiNonToAnalyse + '</div>';
referent.appendChild(div);
}
}
function searchAdvancement(workId) {
$.ajax({
url: compilationWebUrl + "compilatio_ajax.php?workid=" + allWorkId,
type: "get",
dataType: "html",
error: function(){
showData("<?php echo get_lang('compilatioComunicationAjaxImpossible');?>");
},
success: function( strData ){
showData( strData );
}
});
}
function deleteIdListeRefresh(id) {
var regexp = eval("/"+id+":/");
allWorkId = allWorkId.replace(regexp, "");
}
function showData(res) {
var listRes = new Array();
// for debugging
$("#verif").html("");
// parse the answer string
listRes = res.split("|");
for (var i=0; i < listRes.length; i=i+3) {
if (listRes[i] != "") {
var workId = listRes[i];
if (i < listRes.length) {
var HTMLcode = listRes[i+1];
}
if (i < listRes.length + 1) {
var idStatus = listRes[i+2];
if (idStatus != analyseInQueue && idStatus != analyseProcessing) {
deleteIdListeRefresh(workId);
}
$("#verif").append(workId+":"+idStatus+"<br/>");
}
$("#"+"id_avancement"+workId).html(HTMLcode);
}
}
}
</script>

Loading…
Cancel
Save