Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent 01a967a391
commit 76be80f82e
  1. 154
      main/exercise/exercise.php

@ -4,12 +4,12 @@
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* Exercise list: This script shows the list of exercises for administrators and students. * Exercise list: This script shows the list of exercises for administrators and students.
* @package chamilo.exercise * @package chamilo.exercise
* @author Olivier Brouckaert, original author * @author Olivier Brouckaert, original author
* @author Denes Nagy, HotPotatoes integration * @author Denes Nagy, HotPotatoes integration
* @author Wolfgang Schneider, code/html cleanup * @author Wolfgang Schneider, code/html cleanup
* @author Julio Montoya <gugli100@gmail.com>, lots of cleanup + several improvements * @author Julio Montoya <gugli100@gmail.com>, lots of cleanup + several improvements
* Modified by hubert.borderiou (question category) * Modified by hubert.borderiou (question category)
*/ */
@ -146,13 +146,13 @@ if ($origin != 'learnpath') {
} }
} }
} else { } else {
Display :: display_reduced_header(); Display::display_reduced_header();
} }
Event::event_access_tool(TOOL_QUIZ); Event::event_access_tool(TOOL_QUIZ);
// Tool introduction // Tool introduction
Display :: display_introduction_section(TOOL_QUIZ); Display::display_introduction_section(TOOL_QUIZ);
if (!empty($errorXmlExport)) { if (!empty($errorXmlExport)) {
echo $errorXmlExport; echo $errorXmlExport;
@ -266,31 +266,49 @@ if ($is_allowedToEdit) {
'invisible', 'invisible',
$userId $userId
); );
echo Display::return_message(get_lang('VisibilityChanged'), 'confirmation'); echo Display::return_message(
get_lang('VisibilityChanged'),
'confirmation'
);
break; break;
case 'disable_results': case 'disable_results':
//disable the results for the learners //disable the results for the learners
$objExerciseTmp->disable_results(); $objExerciseTmp->disable_results();
$objExerciseTmp->save(); $objExerciseTmp->save();
echo Display::return_message(get_lang('ResultsDisabled'), 'confirmation'); echo Display::return_message(
get_lang('ResultsDisabled'),
'confirmation'
);
break; break;
case 'enable_results': case 'enable_results':
//disable the results for the learners //disable the results for the learners
$objExerciseTmp->enable_results(); $objExerciseTmp->enable_results();
$objExerciseTmp->save(); $objExerciseTmp->save();
echo Display::return_message(get_lang('ResultsEnabled'), 'confirmation'); echo Display::return_message(
get_lang('ResultsEnabled'),
'confirmation'
);
break; break;
case 'clean_results': case 'clean_results':
//clean student results //clean student results
if ($exercise_action_locked == false) { if ($exercise_action_locked == false) {
$quantity_results_deleted = $objExerciseTmp->clean_results(true); $quantity_results_deleted = $objExerciseTmp->clean_results(true);
$title = $objExerciseTmp->selectTitle(); $title = $objExerciseTmp->selectTitle();
echo Display::return_message($title.': '.sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted), 'confirmation'); echo Display::return_message(
$title.': '.sprintf(
get_lang('XResultsCleaned'),
$quantity_results_deleted
),
'confirmation'
);
} }
break; break;
case 'copy_exercise': //copy an exercise case 'copy_exercise': //copy an exercise
$objExerciseTmp->copy_exercise(); $objExerciseTmp->copy_exercise();
echo Display::return_message(get_lang('ExerciseCopied'), 'confirmation'); echo Display::return_message(
get_lang('ExerciseCopied'),
'confirmation'
);
break; break;
} }
} }
@ -327,7 +345,6 @@ if ($is_allowedToEdit) {
don't delete folder if not empty : don't delete folder if not empty :
http://support.chamilo.org/issues/2165 http://support.chamilo.org/issues/2165
*/ */
if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath.$uploadPath."/".$fld."/"))) { if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath.$uploadPath."/".$fld."/"))) {
my_delete($documentPath.$uploadPath."/".$fld."/"); my_delete($documentPath.$uploadPath."/".$fld."/");
} }
@ -499,8 +516,16 @@ if ($total > $limit) {
$i = 1; $i = 1;
$online_icon = Display::return_icon('online.png', get_lang('Visible'), array('width' => '12px')); $online_icon = Display::return_icon(
$offline_icon = Display::return_icon('offline.png', get_lang('Invisible'), array('width' => '12px')); 'online.png',
get_lang('Visible'),
array('width' => '12px')
);
$offline_icon = Display::return_icon(
'offline.png',
get_lang('Invisible'),
array('width' => '12px')
);
$exerciseList = array(); $exerciseList = array();
$list_ordered = null; $list_ordered = null;
@ -750,7 +775,12 @@ if (!empty($exerciseList)) {
// Clean exercise // Clean exercise
if ($locked == false) { if ($locked == false) {
$actions .= Display::url( $actions .= Display::url(
Display::return_icon('clean.png', get_lang('CleanStudentResults'), '', ICON_SIZE_SMALL), Display::return_icon(
'clean.png',
get_lang('CleanStudentResults'),
'',
ICON_SIZE_SMALL
),
'', '',
array( array(
'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;",
@ -758,13 +788,23 @@ if (!empty($exerciseList)) {
) )
); );
} else { } else {
$actions .= Display::return_icon('clean_na.png', get_lang('ResourceLockedByGradebook'), '', ICON_SIZE_SMALL); $actions .= Display::return_icon(
'clean_na.png',
get_lang('ResourceLockedByGradebook'),
'',
ICON_SIZE_SMALL
);
} }
// Visible / invisible // Visible / invisible
// Check if this exercise was added in a LP // Check if this exercise was added in a LP
if ($exercise->exercise_was_added_in_lp == true) { if ($exercise->exercise_was_added_in_lp == true) {
$actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'), '', ICON_SIZE_SMALL); $actions .= Display::return_icon(
'invisible.png',
get_lang('AddedToLPCannotBeAccessed'),
'',
ICON_SIZE_SMALL
);
} else { } else {
if ($row['active'] == 0 || $visibility == 0) { if ($row['active'] == 0 || $visibility == 0) {
$actions .= Display::url( $actions .= Display::url(
@ -774,8 +814,7 @@ if (!empty($exerciseList)) {
'', '',
ICON_SIZE_SMALL ICON_SIZE_SMALL
), ),
'exercise.php?'.api_get_cidreq( 'exercise.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
).'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
); );
} else { } else {
// else if not active // else if not active
@ -786,31 +825,55 @@ if (!empty($exerciseList)) {
'', '',
ICON_SIZE_SMALL ICON_SIZE_SMALL
), ),
'exercise.php?'.api_get_cidreq( 'exercise.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
).'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
); );
} }
} }
// Export qti ... // Export qti ...
$actions .= Display::url(Display::return_icon('export_qti2.png', 'IMS/QTI', '', ICON_SIZE_SMALL), 'exercise.php?choice=exportqti2&exerciseId='.$row['id'].'&'.api_get_cidreq()); $actions .= Display::url(
Display::return_icon(
'export_qti2.png',
'IMS/QTI',
'',
ICON_SIZE_SMALL
),
'exercise.php?choice=exportqti2&exerciseId='.$row['id'].'&'.api_get_cidreq()
);
} else { } else {
// not session // not session
$actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession')); $actions = Display::return_icon(
'edit_na.png',
get_lang('ExerciseEditionNotAvailableInSession')
);
// Check if this exercise was added in a LP // Check if this exercise was added in a LP
if ($exercise->exercise_was_added_in_lp == true) { if ($exercise->exercise_was_added_in_lp == true) {
$actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'), '', ICON_SIZE_SMALL); $actions .= Display::return_icon(
'invisible.png',
get_lang('AddedToLPCannotBeAccessed'),
'',
ICON_SIZE_SMALL
);
} else { } else {
if ($row['active'] == 0 || $visibility == 0) { if ($row['active'] == 0 || $visibility == 0) {
$actions .= Display::url( $actions .= Display::url(
Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL), Display::return_icon(
'invisible.png',
get_lang('Activate'),
'',
ICON_SIZE_SMALL
),
'exercise.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id'] 'exercise.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
); );
} else { } else {
// else if not active // else if not active
$actions .= Display::url( $actions .= Display::url(
Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL), Display::return_icon(
'visible.png',
get_lang('Deactivate'),
'',
ICON_SIZE_SMALL
),
'exercise.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id'] 'exercise.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']
); );
} }
@ -835,7 +898,12 @@ if (!empty($exerciseList)) {
array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteJS'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercise.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$row['id']) array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteJS'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercise.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$row['id'])
); );
} else { } else {
$actions .= Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), '', ICON_SIZE_SMALL); $actions .= Display::return_icon(
'delete_na.png',
get_lang('ResourceLockedByGradebook'),
'',
ICON_SIZE_SMALL
);
} }
} }
@ -956,7 +1024,6 @@ if (!empty($exerciseList)) {
$attempt_text = sprintf(get_lang('ExerciseWasActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time'])); $attempt_text = sprintf(get_lang('ExerciseWasActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
} }
} }
} else { } else {
//$attempt_text = get_lang('ExamNotAvailableAtThisTime'); //$attempt_text = get_lang('ExamNotAvailableAtThisTime');
if (!empty($row['start_time'])) { if (!empty($row['start_time'])) {
@ -1102,7 +1169,12 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
$item .= Display::tag('td', '-'); $item .= Display::tag('td', '-');
$actions = Display::url( $actions = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL), Display::return_icon(
'edit.png',
get_lang('Edit'),
'',
ICON_SIZE_SMALL
),
'adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path 'adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path
); );
@ -1148,7 +1220,10 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
if (!empty($attempt)) { if (!empty($attempt)) {
$actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>'; $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$attemptText = get_lang('LatestAttempt').' : '; $attemptText = get_lang('LatestAttempt').' : ';
$attemptText .= ExerciseLib::show_score($attempt['exe_result'], $attempt['exe_weighting']).' '; $attemptText .= ExerciseLib::show_score(
$attempt['exe_result'],
$attempt['exe_weighting']
).' ';
$attemptText .= $actions; $attemptText .= $actions;
} else { } else {
// No attempts. // No attempts.
@ -1161,7 +1236,11 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
$actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'. $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$item .= Display::tag('td', $actions, array('class' => 'td_actions')); $item .= Display::tag(
'td',
$actions,
array('class' => 'td_actions')
);
} }
$tableRows[] = Display::tag('tr', $item); $tableRows[] = Display::tag('tr', $item);
} }
@ -1175,7 +1254,11 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
echo '<h3>'.get_lang('Quiz').'</h3>'; echo '<h3>'.get_lang('Quiz').'</h3>';
echo Display::return_icon('quiz.png', '', array(), 64); echo Display::return_icon('quiz.png', '', array(), 64);
echo '<div class="controls">'; echo '<div class="controls">';
echo Display::url('<em class="fa fa-plus"></em> '.get_lang('NewEx'), 'exercise_admin.php?'.api_get_cidreq(), array('class' => 'btn btn-primary')); echo Display::url(
'<em class="fa fa-plus"></em> '.get_lang('NewEx'),
'exercise_admin.php?'.api_get_cidreq(),
array('class' => 'btn btn-primary')
);
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
} }
@ -1198,7 +1281,6 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
} }
$headerList = ''; $headerList = '';
foreach ($headers as $header) { foreach ($headers as $header) {
$headerList .= Display::tag('th', $header); $headerList .= Display::tag('th', $header);
} }

Loading…
Cancel
Save