Minor - Format code

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

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

Loading…
Cancel
Save