Minor - Format code

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent d6de2d68e0
commit 582be37cf3
  1. 90
      main/exercice/hotspot_admin.inc.php

@ -7,7 +7,6 @@
* @package chamilo.exercise * @package chamilo.exercise
* @author Toon Keppens * @author Toon Keppens
*/ */
use \ChamiloSession as Session; use \ChamiloSession as Session;
$modifyAnswers = intval($_GET['hotspotadmin']); $modifyAnswers = intval($_GET['hotspotadmin']);
@ -54,6 +53,7 @@ if ($modifyIn) {
// construction of the duplicated Answers // construction of the duplicated Answers
$objAnswer = new Answer($questionId); $objAnswer = new Answer($questionId);
} }
$color = unserialize($color); $color = unserialize($color);
$reponse = unserialize($reponse); $reponse = unserialize($reponse);
$comment = unserialize($comment); $comment = unserialize($comment);
@ -82,6 +82,7 @@ if ($submitAnswers || $buttonBack) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
$comment[$i] = trim($comment[$i]); $comment[$i] = trim($comment[$i]);
$weighting[$i] = $weighting[$i]; // it can be float $weighting[$i] = $weighting[$i]; // it can be float
@ -115,12 +116,15 @@ if ($submitAnswers || $buttonBack) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
$comment[$i] = trim($comment[$i]); $comment[$i] = trim($comment[$i]);
$weighting[$i] = ($weighting[$i]); //it can be float $weighting[$i] = ($weighting[$i]); //it can be float
if ($weighting[$i]) { if ($weighting[$i]) {
$questionWeighting+=$weighting[$i]; $questionWeighting+=$weighting[$i];
} }
// creates answer // creates answer
$objAnswer->createAnswer( $objAnswer->createAnswer(
$reponse[$i], $reponse[$i],
@ -143,6 +147,7 @@ if ($submitAnswers || $buttonBack) {
unset($modifyAnswers); unset($modifyAnswers);
echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>'; echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>';
} }
if ($debug > 0) { if ($debug > 0) {
echo '$modifyIn was set - end' . "<br />\n"; echo '$modifyIn was set - end' . "<br />\n";
} }
@ -150,6 +155,7 @@ if ($submitAnswers || $buttonBack) {
if ($debug > 0) { if ($debug > 0) {
echo '$submitAnswers or $buttonBack was set' . "<br />\n"; echo '$submitAnswers or $buttonBack was set' . "<br />\n";
} }
$questionWeighting = $nbrGoodAnswers = 0; $questionWeighting = $nbrGoodAnswers = 0;
$select_question = $_POST['select_question']; $select_question = $_POST['select_question'];
$try = $_POST['try']; $try = $_POST['try'];
@ -212,6 +218,7 @@ if ($submitAnswers || $buttonBack) {
} else { } else {
$question_str = $select_question[$i]; $question_str = $select_question[$i];
} }
$destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; $destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str;
// checks if field is empty // checks if field is empty
@ -281,6 +288,7 @@ if ($submitAnswers || $buttonBack) {
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
$comment[$i] = trim($comment[$i]); $comment[$i] = trim($comment[$i]);
$weighting[$i] = ($weighting[$i]); //it can be float $weighting[$i] = ($weighting[$i]); //it can be float
if ($weighting[$i]) { if ($weighting[$i]) {
$questionWeighting+=$weighting[$i]; $questionWeighting+=$weighting[$i];
} }
@ -330,6 +338,7 @@ if ($modifyAnswers) {
// construction of the Answer object // construction of the Answer object
$objAnswer = new Answer($objQuestion->id); $objAnswer = new Answer($objQuestion->id);
Session::write('objAnswer', $objAnswer); Session::write('objAnswer', $objAnswer);
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 2) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 2) . '$answerType is HOT_SPOT' . "<br />\n";
} }
@ -353,12 +362,14 @@ if ($modifyAnswers) {
if (!$nbrAnswers) { if (!$nbrAnswers) {
$nbrAnswers = $objAnswer->selectNbrAnswers(); $nbrAnswers = $objAnswer->selectNbrAnswers();
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
// the magic happens here ... // the magic happens here ...
// we do this to not count the if no error section // we do this to not count the if no error section
if ($nbrAnswers >= 2) if ($nbrAnswers >= 2)
$nbrAnswers--; $nbrAnswers--;
} }
$reponse = array(); $reponse = array();
$comment = array(); $comment = array();
$weighting = array(); $weighting = array();
@ -369,9 +380,11 @@ if ($modifyAnswers) {
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
$reponse[$i] = $objAnswer->selectAnswer($i); $reponse[$i] = $objAnswer->selectAnswer($i);
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$comment[$i] = $objAnswer->selectComment($i); $comment[$i] = $objAnswer->selectComment($i);
} }
$weighting[$i] = $objAnswer->selectWeighting($i); $weighting[$i] = $objAnswer->selectWeighting($i);
$hotspot_coordinates[$i] = $objAnswer->selectHotspotCoordinates($i); $hotspot_coordinates[$i] = $objAnswer->selectHotspotCoordinates($i);
$hotspot_type[$i] = $objAnswer->selectHotspotType($i); $hotspot_type[$i] = $objAnswer->selectHotspotType($i);
@ -409,12 +422,15 @@ if ($modifyAnswers) {
$_SESSION['tmp_answers'] = array(); $_SESSION['tmp_answers'] = array();
$_SESSION['tmp_answers']['answer'] = $reponse; $_SESSION['tmp_answers']['answer'] = $reponse;
if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($objExercise->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$_SESSION['tmp_answers']['comment'] = $comment; $_SESSION['tmp_answers']['comment'] = $comment;
} }
$_SESSION['tmp_answers']['weighting'] = $weighting; $_SESSION['tmp_answers']['weighting'] = $weighting;
$_SESSION['tmp_answers']['hotspot_coordinates'] = $hotspot_coordinates; $_SESSION['tmp_answers']['hotspot_coordinates'] = $hotspot_coordinates;
$_SESSION['tmp_answers']['hotspot_type'] = $hotspot_type; $_SESSION['tmp_answers']['hotspot_type'] = $hotspot_type;
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
$_SESSION['tmp_answers']['destination'] = $destination; $_SESSION['tmp_answers']['destination'] = $destination;
} }
@ -477,7 +493,6 @@ if ($modifyAnswers) {
} }
} }
$moreOARAnswers = isset($_POST['moreOARAnswers']) ? true : false; $moreOARAnswers = isset($_POST['moreOARAnswers']) ? true : false;
if ($moreOARAnswers) { if ($moreOARAnswers) {
@ -499,9 +514,11 @@ if ($modifyAnswers) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 2) . '$usedInSeveralExercises is untrue' . "<br />\n"; echo str_repeat('&nbsp;', 2) . '$usedInSeveralExercises is untrue' . "<br />\n";
} }
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
$hotspot_colors = array( $hotspot_colors = array(
"", "",
@ -538,11 +555,12 @@ if ($modifyAnswers) {
} }
Display::tag('h3', get_lang('Question') . ": " . $questionName . ' <img src="../img/info3.gif" title="' . strip_tags(get_lang('HotspotChoose')) . '" alt="' . strip_tags(get_lang('HotspotChoose')) . '" />'); Display::tag('h3', get_lang('Question') . ": " . $questionName . ' <img src="../img/info3.gif" title="' . strip_tags(get_lang('HotspotChoose')) . '" alt="' . strip_tags(get_lang('HotspotChoose')) . '" />');
if (!empty($msgErr)) { if (!empty($msgErr)) {
Display::display_normal_message($msgErr); //main API Display::display_normal_message($msgErr); //main API
} }
$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId.'&'.api_get_cidreq(); $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId . '&' . api_get_cidreq();
?> ?>
<form method="post" action="<?php echo $hotspot_admin_url; ?>" id="frm_exercise" name="frm_exercise"> <form method="post" action="<?php echo $hotspot_admin_url; ?>" id="frm_exercise" name="frm_exercise">
<table border="0" cellpadding="0" cellspacing="2" width="100%"> <table border="0" cellpadding="0" cellspacing="2" width="100%">
@ -566,20 +584,27 @@ if ($modifyAnswers) {
<tr> <tr>
<th width="5">&nbsp;</th> <th width="5">&nbsp;</th>
<th> <?php echo get_lang('HotspotDescription'); ?> *</th> <th> <?php echo get_lang('HotspotDescription'); ?> *</th>
<?php if ($answerType == HOT_SPOT_DELINEATION) <?php
echo '<th >' . get_lang('Thresholds') . '</th>'; ?> if ($answerType == HOT_SPOT_DELINEATION) {
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> echo '<th >' . get_lang('Thresholds') . '</th>';
<th><?php echo get_lang('Comment'); ?></th> }
<?php if ($answerType == HOT_SPOT_DELINEATION) if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
echo '<th >' . get_lang('Scenario') . '</th>'; ?> ?>
<?php } else { ?> <th><?php echo get_lang('Comment'); ?></th>
<?php
if ($answerType == HOT_SPOT_DELINEATION) {
echo '<th >' . get_lang('Scenario') . '</th>';
}
?>
<?php
} else {
?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th> <th colspan="2"><?php echo get_lang('Comment'); ?></th>
<?php } ?> <?php } ?>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th> <th><?php echo get_lang('QuestionWeighting'); ?> *</th>
</tr> </tr>
<?php <?php
$list = new LearnpathList(api_get_user_id()); $list = new LearnpathList(api_get_user_id());
// Loading list of LPs // Loading list of LPs
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
@ -601,6 +626,7 @@ if ($modifyAnswers) {
} }
$option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>'; $option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>';
} }
if ($isSelected) { if ($isSelected) {
$option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp; $option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
} else { } else {
@ -617,11 +643,14 @@ if ($modifyAnswers) {
$question = Question::read($questionid); $question = Question::read($questionid);
$val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL);
$select_lp_id[$id] = $details['lp_name']; $select_lp_id[$id] = $details['lp_name'];
if ($questionid == $select_question[$i]) { if ($questionid == $select_question[$i]) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>'; $option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>';
} }
if ($select_question[$i] == -1) { if ($select_question[$i] == -1) {
$option_feed .= '<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>'; $option_feed .= '<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>';
} else { } else {
@ -676,7 +705,9 @@ if ($modifyAnswers) {
<?php echo Security::remove_XSS($comment[$i]); ?> <?php echo Security::remove_XSS($comment[$i]); ?>
</textarea> </textarea>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="delineation" /> <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="delineation" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" /> <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]);
?>" />
<br/> <br/>
<?php echo get_lang('LearnerIsInformed'); ?> <?php echo get_lang('LearnerIsInformed'); ?>
</td> </td>
@ -686,9 +717,8 @@ if ($modifyAnswers) {
<tr> <tr>
<td> <td>
<input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> /> <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?><br /><br />
<br /><br /> <?php echo get_lang('SeeTheory'); ?><br />
<?php echo get_lang('SeeTheory'); ?> <br />
<select name="lp[<?php echo $i; ?>]" > <select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?> <?php echo $option_lp; ?>
</select> </select>
@ -784,7 +814,9 @@ if ($modifyAnswers) {
<td colspan="2" align="left"> <td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea> <textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea>
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="oar" /> <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="oar" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" /> <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php
echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]);
?>" />
</td> </td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<td> <td>
@ -812,7 +844,8 @@ if ($modifyAnswers) {
</td> </td>
<?php } else { ?> <?php } else { ?>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } <?php
}
} }
//end if is delineation //end if is delineation
} else { } else {
@ -827,21 +860,20 @@ if ($modifyAnswers) {
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($responseValue); ?>" size="45" /> <input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($responseValue); ?>" size="45" />
</td> </td>
<?php <?php
$form = new FormValidator('form_'.$i); $form = new FormValidator('form_' . $i);
$config = array( $config = array(
'ToolbarSet' => 'TestProposedAnswer' 'ToolbarSet' => 'TestProposedAnswer'
); );
$form->addHtmlEditor('comment['.$i.']', null, false, false, $config); $form->addHtmlEditor('comment[' . $i . ']', null, false, false, $config);
$renderer = $form->defaultRenderer(); $renderer = $form->defaultRenderer();
$form_template = '{content}'; $form_template = '{content}';
$renderer->setFormTemplate($form_template); $renderer->setFormTemplate($form_template);
$element_template = ' $element_template = '
{label} {label}
{element} {element}';
';
$renderer->setElementTemplate($element_template); $renderer->setElementTemplate($element_template);
$form->setDefaults(array('comment['.$i.']' => $commentValue)); $form->setDefaults(array('comment[' . $i . ']' => $commentValue));
$return = $form->return_form(); $return = $form->return_form();
?> ?>
<td>&nbsp;</td> <td>&nbsp;</td>
@ -850,14 +882,16 @@ if ($modifyAnswers) {
<td> <td>
<?php <?php
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') { ?> if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
?>
<input type="hidden" name="weighting[<?php echo $i; ?>]" class="span3" value="0" /> <input type="hidden" name="weighting[<?php echo $i; ?>]" class="span3" value="0" />
<?php } else { ?> <?php } else { ?>
<input type="text" name="weighting[<?php echo $i; ?>]" class="span3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" /> <input type="text" name="weighting[<?php echo $i; ?>]" class="span3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
<?php <?php
} }
} }
if ($answerType == HOT_SPOT) { ?> if ($answerType == HOT_SPOT) {
?>
<input type="text" name="weighting[<?php echo $i; ?>]" class="span3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" /> <input type="text" name="weighting[<?php echo $i; ?>]" class="span3" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" /> <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /> <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" />
@ -905,12 +939,14 @@ if ($modifyAnswers) {
} }
$option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>'; $option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>';
} }
if ($selectQuestionNoError == -1) if ($selectQuestionNoError == -1) {
$option_feed.='<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>'; $option_feed.='<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>';
else } else {
$option_feed.='<option value="-1">' . get_lang('ExitTest') . '</option>'; $option_feed.='<option value="-1">' . get_lang('ExitTest') . '</option>';
}
if ($answerType == HOT_SPOT_DELINEATION) { ?> if ($answerType == HOT_SPOT_DELINEATION) {
?>
<tr> <tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th> <th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>

Loading…
Cancel
Save