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. 7
      main/exercise/hotpotatoes.lib.php
  4. 13
      main/exercise/hotpotatoes_exercise_report.php
  5. 113
      main/exercise/hotpotatoes_exercise_result.class.php
  6. 27
      main/exercise/hotspot_lang_conversion.php
  7. 2
      main/exercise/matching.class.php
  8. 5
      main/exercise/question_create.php
  9. 21
      main/exercise/recalculate.php
  10. 1
      main/exercise/tests_category.php

@ -745,8 +745,10 @@ class TestCategory
* *
* @return string * @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)) { if (empty($category_list)) {
return null; return null;
} }

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

@ -14,7 +14,8 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
/** /**
* Creates a hotpotato directory. * 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 * @param string $base_work_dir Wanted path
* @return boolean Always true so far * @return boolean Always true so far
*/ */
@ -95,7 +96,9 @@ function GetComment($path, $courseCode = '')
* Sets the comment in the database for a particular path. * Sets the comment in the database for a particular path.
* @param string $path File path * @param string $path File path
* @param string $comment Comment to set * @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) function SetComment($path, $comment)
{ {

@ -290,10 +290,17 @@ function exportExcel() {
$(function() { $(function() {
<?php <?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) { ?> if ($is_allowedToEdit || $is_tutor) { ?>
//setSearchSelect("status"); //setSearchSelect("status");
// //
//view:true, del:false, add:false, edit:false, excel:true} //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 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 integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
* @param string $document_path * @param string $document_path
* @return bool
*/ */
public function getExercisesReporting($document_path, $hotpotato_name) public function getExercisesReporting($document_path, $hotpotato_name)
{ {
@ -226,17 +227,37 @@ class HotpotatoesExerciseResult
} }
if ($with_column_user) { if ($with_column_user) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Email')
);
$column++; $column++;
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++; $column++;
} else { } else {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++; $column++;
} }
} }
@ -267,19 +288,47 @@ class HotpotatoesExerciseResult
} }
} }
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Title')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('StartDate')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('EndDate')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')'); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Duration').' ('.get_lang('MinMinutes').')'
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Score')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Total')
);
$column++; $column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status')); $worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Status')
);
$line++; $line++;
foreach ($this->results as $row) { foreach ($this->results as $row) {
@ -298,14 +347,46 @@ class HotpotatoesExerciseResult
$column++; $column++;
if (api_is_western_name_order()) { 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++; $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++; $column++;
} else { } 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++; $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++; $column++;
} }
} }

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

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

@ -93,7 +93,7 @@ if ($form->validate()) {
} }
header('Location: admin.php?exerciseId='.$values['exercise'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type); header('Location: admin.php?exerciseId='.$values['exercise'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);
exit; exit;
} else { } else {
// header // header
Display::display_header($nameTools); Display::display_header($nameTools);
@ -108,7 +108,8 @@ if ($form->validate()) {
Display::display_footer(); Display::display_footer();
} }
function check_question_type($parameter) { function check_question_type($parameter)
{
$question_list = Question::get_question_type_list(); $question_list = Question::get_question_type_list();
foreach ($question_list as $key => $value) { foreach ($question_list as $key => $value) {
$valid_question_types[] = $key; $valid_question_types[] = $key;

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

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

Loading…
Cancel
Save