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 * @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)
{ {
@ -346,7 +349,7 @@ function GenerateHpFolder($folder)
if (is_dir($full_name)) { if (is_dir($full_name)) {
$filelist[] = $file; $filelist[] = $file;
} }
} }
} }
} }
} }

@ -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++;
} }
} }

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

@ -1,58 +1,51 @@
<?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';
$hotspot_lang_file = api_get_path(SYS_LANG_PATH); $hotspot_lang_file = api_get_path(SYS_LANG_PATH);
if (isset($_GET['lang'])) { if (isset($_GET['lang'])) {
//$search = array('../','\\0','\\'); //$search = array('../','\\0','\\');
$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 { }
$hotspot_lang_file .= 'english/hotspot.inc.php'; } else {
} $hotspot_lang_file .= 'english/hotspot.inc.php';
}
} else { } else {
$hotspot_lang_file .= 'english/hotspot.inc.php'; $hotspot_lang_file .= 'english/hotspot.inc.php';
} }
$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]));
$explode[1] = trim($explode[1]); $explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1); $explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = str_replace('"', '', $explode[1]); $explode[1] = str_replace('"', '', $explode[1]);
$temp[] = $explode[0].'='.$explode[1]; $temp[] = $explode[0].'='.$explode[1];
} }
} }
foreach ($temp as $value) foreach ($temp as $value) {
{ echo $value.' ';
echo $value.' ';
} }
?>

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

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

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

@ -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++) {

@ -51,17 +51,17 @@ $sql = "SELECT id,title,type,description, results_disabled
$result = Database::query($sql); $result = Database::query($sql);
$exercises['-'] = '-'.get_lang('SelectExercise').'-'; $exercises['-'] = '-'.get_lang('SelectExercise').'-';
while ($row = Database :: fetch_array($result)) { 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); $form->addElement('select', 'exercise', get_lang('Exercise'), $exercises);
// generate default content // generate default content
$form->addElement( $form->addElement(
'checkbox', 'checkbox',
'is_content', 'is_content',
null, null,
get_lang('GenerateDefaultContent'), get_lang('GenerateDefaultContent'),
array('checked' => true) array('checked' => true)
); );
// the submit button // 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); 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);

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

@ -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) {

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

Loading…
Cancel
Save