Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent 9df170dbc2
commit ad9e92ee69
  1. 6
      main/exercise/TestCategory.php
  2. 4
      main/exercise/UniqueAnswerImage.php
  3. 9
      main/exercise/hotpotatoes.lib.php
  4. 13
      main/exercise/hotpotatoes_exercise_report.php
  5. 113
      main/exercise/hotpotatoes_exercise_result.class.php
  6. 8
      main/exercise/hotspot_actionscript_admin.as.php
  7. 65
      main/exercise/hotspot_lang_conversion.php
  8. 32
      main/exercise/hotspot_save.inc.php
  9. 4
      main/exercise/hotspot_savescore.inc.php
  10. 14
      main/exercise/hotspot_updatescore.inc.php
  11. 2
      main/exercise/matching.class.php
  12. 17
      main/exercise/question_create.php
  13. 21
      main/exercise/recalculate.php
  14. 12
      main/exercise/showinframes.php
  15. 1
      main/exercise/tests_category.php
  16. 16
      main/exercise/unique_answer_no_option.class.php

@ -745,8 +745,10 @@ class TestCategory
*
* @return string
*/
public static function get_stats_table_by_attempt($exerciseId, $category_list = array())
{
public static function get_stats_table_by_attempt(
$exerciseId,
$category_list = array()
) {
if (empty($category_list)) {
return null;
}

@ -220,7 +220,8 @@ class UniqueAnswerImage extends UniqueAnswer
$selectQuestion
);
$group['url'.$i] = $form->createElement(
'text', 'url'.$i,
'text',
'url'.$i,
get_lang('Other').': ',
array(
'class' => 'col-md-2',
@ -317,7 +318,6 @@ class UniqueAnswerImage extends UniqueAnswer
{
$destinationStr.=$destination_id.';';
} */
$goodAnswer = $correct == $i ? true : false;
if ($goodAnswer) {
$nbrGoodAnswers++;

@ -14,7 +14,8 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
/**
* Creates a hotpotato directory.
*
* If a directory of that name already exists, don't create any. If a file of that name exists, remove it and create a directory.
* If a directory of that name already exists, don't create any.
* If a file of that name exists, remove it and create a directory.
* @param string $base_work_dir Wanted path
* @return boolean Always true so far
*/
@ -95,7 +96,9 @@ function GetComment($path, $courseCode = '')
* Sets the comment in the database for a particular path.
* @param string $path File path
* @param string $comment Comment to set
* @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway)
* @return Doctrine\DBAL\Driver\Statement|null
* Result of the database operation
* (Database::query will output some message directly on error anyway)
*/
function SetComment($path, $comment)
{
@ -346,7 +349,7 @@ function GenerateHpFolder($folder)
if (is_dir($full_name)) {
$filelist[] = $file;
}
}
}
}
}
}

@ -290,10 +290,17 @@ function exportExcel() {
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
echo Display::grid_js(
'results',
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
if ($is_allowedToEdit || $is_tutor) { ?>
//setSearchSelect("status");
//
//view:true, del:false, add:false, edit:false, excel:true}

@ -19,6 +19,7 @@ class HotpotatoesExerciseResult
* @param string The document path (for HotPotatoes retrieval)
* @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
* @param string $document_path
* @return bool
*/
public function getExercisesReporting($document_path, $hotpotato_name)
{
@ -226,17 +227,37 @@ class HotpotatoesExerciseResult
}
if ($with_column_user) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Email')
);
$column++;
if (api_is_western_name_order()) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++;
} else {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++;
}
}
@ -267,19 +288,47 @@ class HotpotatoesExerciseResult
}
}
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Title')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('StartDate')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('EndDate')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Duration').' ('.get_lang('MinMinutes').')'
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Score')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Total')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Status')
);
$line++;
foreach ($this->results as $row) {
@ -298,14 +347,46 @@ class HotpotatoesExerciseResult
$column++;
if (api_is_western_name_order()) {
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['first_name']),
ENT_QUOTES,
$charset
)
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['last_name']),
ENT_QUOTES,
$charset
)
);
$column++;
} else {
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['last_name']),
ENT_QUOTES,
$charset
)
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['first_name']),
ENT_QUOTES,
$charset
)
);
$column++;
}
}

@ -97,10 +97,10 @@ for ($i = 1; $i <= $nbrAnswers; $i++) {
}*/
}
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0) {
$nmbrTries++;
}
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0) {
$nmbrTries++;
}
$hotSpot['coord'] = $answers['hotspot_coordinates'][$i];
$data['hotspots'][] = $hotSpot;

@ -1,58 +1,51 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Hotspot language conversion
* @package chamilo.exercise
* @author
* Hotspot language conversion
* @package chamilo.exercise
* @author
* @deprecated ?
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
require_once __DIR__.'/../inc/global.inc.php';
$hotspot_lang_file = api_get_path(SYS_LANG_PATH);
if (isset($_GET['lang'])) {
//$search = array('../','\\0','\\');
$lang = urldecode($_GET['lang']);
if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
if (file_exists($hotspot_lang_file.$lang.'/hotspot.inc.php'))
$hotspot_lang_file .= $lang.'/hotspot.inc.php';
else
$hotspot_lang_file .= 'english/hotspot.inc.php';
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
//$search = array('../','\\0','\\');
$lang = urldecode($_GET['lang']);
if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
if (file_exists($hotspot_lang_file.$lang.'/hotspot.inc.php')) {
$hotspot_lang_file .= $lang.'/hotspot.inc.php';
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
$file = file($hotspot_lang_file);
$temp = array();
foreach ($file as $value)
{
$explode = explode('=', $value);
foreach ($file as $value) {
$explode = explode('=', $value);
if (count($explode) > 1)
{
$explode[0] = trim($explode[0]);
$explode[0] = '&'.substr($explode[0], 1, strlen($explode[0]));
if (count($explode) > 1) {
$explode[0] = trim($explode[0]);
$explode[0] = '&'.substr($explode[0], 1, strlen($explode[0]));
$explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = str_replace('"', '', $explode[1]);
$explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = str_replace('"', '', $explode[1]);
$temp[] = $explode[0].'='.$explode[1];
}
$temp[] = $explode[0].'='.$explode[1];
}
}
foreach ($temp as $value)
{
echo $value.' ';
foreach ($temp as $value) {
echo $value.' ';
}
?>

@ -15,24 +15,24 @@ $questionId = intval($_GET['questionId']);
$answerId = intval($_GET['answerId']);
if ($_GET['type'] == "square" || $_GET['type'] == "circle") {
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
}
if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") {
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",", $_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord) {
if ($i % 2 == 0) {
$delimiter = ";";
} else {
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
$i++;
}
$hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2);
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",", $_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord) {
if ($i % 2 == 0) {
$delimiter = ";";
} else {
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
$i++;
}
$hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2);
}
$course_id = api_get_course_int_id();
$sql = "UPDATE $TBL_ANSWER SET

@ -25,8 +25,8 @@ if ($_GET['answerId'] == "0") {
// user clicked ON a hotspot
$hit = 1;
$answerId = api_substr($_GET['answerId'], 22, 2);
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
//round-up the coordinates
$coords = explode('/', $coordinates);

@ -20,16 +20,16 @@ $hotspotId = $_GET['hotspotId'];
$exerciseId = $objExercise->selectId();
if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
$hit = 0;
$answerId = $hotspotId;
$answerId = $hotspotId;
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
} else { // user clicked ON a hotspot
$hit = 1;
$answerId = $hotspotId;
$hit = 1;
$answerId = $hotspotId;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
//round-up the coordinates

@ -63,7 +63,7 @@ class Matching extends Question
$nb_matches++;
$nb_options++;
}
} else if (!empty($this->id)) {
} elseif (!empty($this->id)) {
if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) {

@ -51,17 +51,17 @@ $sql = "SELECT id,title,type,description, results_disabled
$result = Database::query($sql);
$exercises['-'] = '-'.get_lang('SelectExercise').'-';
while ($row = Database :: fetch_array($result)) {
$exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
$exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
}
$form->addElement('select', 'exercise', get_lang('Exercise'), $exercises);
// generate default content
$form->addElement(
'checkbox',
'is_content',
null,
get_lang('GenerateDefaultContent'),
array('checked' => true)
'checkbox',
'is_content',
null,
get_lang('GenerateDefaultContent'),
array('checked' => true)
);
// the submit button
@ -93,7 +93,7 @@ if ($form->validate()) {
}
header('Location: admin.php?exerciseId='.$values['exercise'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);
exit;
} else {
} else {
// header
Display::display_header($nameTools);
@ -108,7 +108,8 @@ if ($form->validate()) {
Display::display_footer();
}
function check_question_type($parameter) {
function check_question_type($parameter)
{
$question_list = Question::get_question_type_list();
foreach ($question_list as $key => $value) {
$valid_question_types[] = $key;

@ -21,24 +21,23 @@ $trackedExercise = $em
->getRepository('ChamiloCoreBundle:TrackEExercises')
->find(intval($_REQUEST['id']));
if (
$trackedExercise->getExeUserId() != intval($_REQUEST['user']) ||
if ($trackedExercise->getExeUserId() != intval($_REQUEST['user']) ||
$trackedExercise->getExeExoId() != intval($_REQUEST['exercise'])
) {
api_not_allowed(true);
exit;
}
$attemps = $em->getRepository('ChamiloCoreBundle:TrackEAttempt')
$attempts = $em->getRepository('ChamiloCoreBundle:TrackEAttempt')
->findBy([
'exeId' => $trackedExercise->getExeId(),
'userId' => $trackedExercise->getExeUserId()
]);
$newResult = 0;
foreach ($attemps as $attemp) {
$questionId = $attemp->getQuestionId();
/** @var \Chamilo\CoreBundle\Entity\TrackEAttempt $attempt */
foreach ($attempts as $attempt) {
$questionId = $attempt->getQuestionId();
$question = $em->find('ChamiloCourseBundle:CQuizQuestion', $questionId);
@ -52,20 +51,16 @@ foreach ($attemps as $attemp) {
]);
$newMarks = 0;
foreach ($answers as $answer) {
if ($answer->getId() != $attemp->getAnswer()) {
if ($answer->getId() != $attempt->getAnswer()) {
continue;
}
$newMarks += $answer->getPonderation();
}
$newResult += $newMarks;
$attemp->setMarks($newMarks);
$em->merge($attemp);
$attempt->setMarks($newMarks);
$em->merge($attempt);
}
$trackedExercise->setExeResult($newResult);

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -28,10 +28,10 @@ my_delete($full_file_path.$user_id.'.t.html');
$content = ReadFileCont($full_file_path.$user_id.'.t.html');
if ($content == '') {
$content = ReadFileCont($full_file_path);
$content = ReadFileCont($full_file_path);
// Do not move this like:
$mit = "function Finish(){";
$js_content = "
$mit = "function Finish(){";
$js_content = "
// Code added - start
var SaveScoreVariable = 0;
function mySaveScore() {

@ -5,6 +5,7 @@
hubert.borderiou
Manage tests category page
*/
$htmlHeadXtra[] = '
<script>
function confirmDelete(in_txt, in_id) {

@ -397,19 +397,19 @@ class UniqueAnswerNoOption extends Question
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save($exercise);
}
}
/**
* @inheritdoc
*/
public function return_header($exercise, $counter = null, $score = null)
public function return_header($exercise, $counter = null, $score = null)
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'.get_lang("ExpectedChoice").'</th>
<th>'.get_lang("Answer").'</th>';
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'.get_lang("ExpectedChoice").'</th>
<th>'.get_lang("Answer").'</th>';
$header .= '<th>'.get_lang("Comment").'</th>';
$header .= '</tr>';

Loading…
Cancel
Save