Fixing exercise layout, fixing links, fixing query

skala
Julio Montoya 15 years ago
parent 2821daf47e
commit 007d9dcbe9
  1. 18
      main/exercice/exercice.php
  2. 36
      main/exercice/exercise.lib.php
  3. 7
      main/exercice/exercise_show.php
  4. 12
      main/inc/lib/events.lib.inc.php

@ -615,7 +615,7 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
echo '<a href="hotpotatoes.php?' . api_get_cidreq() . '">' . Display :: return_icon('hotpotatoes_s.png', get_lang('ImportHotPotatoesQuiz')) . get_lang('ImportHotPotatoesQuiz') . '</a>';
// link to import qti2 ...
echo '<a href="qti2.php?' . api_get_cidreq() . '">' . Display :: return_icon('import_db.png', get_lang('ImportQtiQuiz')) . get_lang('ImportQtiQuiz') . '</a>';
echo '<a href="exercice.php?' . api_get_cidreq() . '&show=result&exercise_id='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
//echo '<a href="exercice.php?' . api_get_cidreq() . '&show=result&exercise_id='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
}
// the actions for the statistics
@ -684,9 +684,9 @@ if ($show == 'result') {
null;
}
if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
$view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&gradebook='.$gradebook.'" >'.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').'</a>';
$view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&exercise_id='.intval($_GET['exercise_id']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').'</a>';
} else {
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&gradebook='.$gradebook.'" >'.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').'</a>';
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&exercise_id='.intval($_GET['exercise_id']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').'</a>';
}
echo $view_result;
}
@ -816,6 +816,8 @@ if ($show == 'test') {
$actions = Display::url(Display::return_icon('wizard_small.gif',get_lang('Edit'), array('width'=>'22px')), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);
$actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exercise_id='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
//Export
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
//Clean exercise
@ -865,6 +867,7 @@ if ($show == 'test') {
echo '</div>';*/
echo Display::tag('tr',$item);
} else {
// Student only
$row['title']=text_filter($row['title']);
@ -878,8 +881,7 @@ if ($show == 'test') {
}
} else {
$url = '<a href="exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$myllpitemid.'&exerciseId='.$row['id'].'">'.$row['title'].'</a>';
}
}
$item = Display::tag('td',$url.' '.$session_img);
@ -931,7 +933,7 @@ if ($show == 'test') {
$percentage = ($row['exe_result'] / $row['exe_weighting']) * 100;
}
$attempt_text = get_lang('Attempted') . ' (' . get_lang('Score') . ': ';
$attempt_text .= printf("%1.2f\n", $percentage);
$attempt_text .= sprintf("%1.2f\n", $percentage);
$attempt_text .= " %)";
} else {
//echo get_lang('WillBeActivated' .' '. $row['start_time']);
@ -964,7 +966,7 @@ if ($show == 'test') {
/* Exercise Results (uses tracking tool) */
// if tracking is enabled
if ($_configuration['tracking_enabled'] && ($show == 'result')) {
if ($show == 'result') {
$parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook']));
$exercise_id = intval($_GET['exercise_id']);
if (!empty($exercise_id))
@ -988,7 +990,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
$table->set_header(-$secuence + 3, get_lang('Duration'),false);
$table->set_header(-$secuence + 4, get_lang('Date'));
$table->set_header(-$secuence + 5, get_lang('Result'),false);
$table->set_header(-$secuence + 6, (($is_allowedToEdit||$is_tutor) ? get_lang('CorrectTest') : get_lang('ViewTest')), false);
$table->set_header(-$secuence + 6, (($is_allowedToEdit||$is_tutor) ? get_lang('CorrectTest') : get_lang('ViewTest')), false);
$table->display();
}

@ -1075,25 +1075,25 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
*/
function show_score($score, $weight, $show_porcentage = true) {
$html = '';
$score_rounded = $score;
if ($score != '' && $weight != '') {
$max_note = api_get_setting('exercise_max_score');
$min_note = api_get_setting('exercise_min_score');
if ($max_note != '' && $min_note != '') {
if (!empty($weight) && intval($weight) != 0) {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
} else {
$score = $min_note;
}
$score_rounded = round($score, 2);
$weight = $max_note;
$score_rounded = $score;
$max_note = api_get_setting('exercise_max_score');
$min_note = api_get_setting('exercise_min_score');
if ($max_note != '' && $min_note != '') {
if (!empty($weight) && intval($weight) != 0) {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
} else {
$score = $min_note;
}
if ($show_porcentage) {
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')';
} else {
$html = $score_rounded . ' / ' . $weight;
}
}
$score_rounded = round($score, 2);
$weight = $max_note;
}
if ($show_porcentage) {
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')';
} else {
$html = $score_rounded . ' / ' . $weight;
}
return $html;
}

@ -248,7 +248,7 @@ if ($show_results) {
</td>
</tr>
<tr>
<td style="font-weight:bold" width="80px"><?php echo '&nbsp;'.get_lang('User')?> : </td>
<td style="font-weight:bold" width="90px"><?php echo '&nbsp;'.get_lang('User')?> : </td>
<td>
<?php
$user_info = api_get_user_info($student_id);
@ -257,7 +257,7 @@ if ($show_results) {
</td>
</tr>
<tr>
<td style="font-weight:bold" width="80px"><?php echo '&nbsp;'.get_lang('Date')?> : </td>
<td style="font-weight:bold" width="90px"><?php echo '&nbsp;'.get_lang('Date')?> : </td>
<td>
<?php
echo api_convert_and_format_date($exercise_date);
@ -597,11 +597,12 @@ if ($show_results) {
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results) {
echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
//@todo $dsp_percent who do that and why?
if ($dsp_percent) {
$my_result = number_format(($totalScore/$totalWeighting)*100,1,'.','');
$my_result = float_format($my_result,1);
echo $my_result."%";
} else {
} else {
echo show_score($totalScore,$totalWeighting,false);
}
echo '</div>';

@ -602,17 +602,20 @@ function get_last_attempt_date_of_exercise($exe_id) {
return $last_attempt_date;
}
function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id) {
/**
* Gets how many attempts exists
*/
function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id,$lp_item_view_id) {
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$user_id = intval($user_id);
$exerciseId = intval($exerciseId);
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
$lp_item_view_id = intval($lp_item_view_id);
$sql = "SELECT count(*) as count FROM $stat_table WHERE exe_exo_id = '$exerciseId'
AND exe_user_id = '$user_id' AND status != 'incomplete'
AND orig_lp_id = $lp_id AND orig_lp_item_id = $lp_item_id AND exe_cours_id = '".api_get_course_id()."' AND session_id = '" . api_get_session_id() . "'";
AND orig_lp_id = $lp_id AND orig_lp_item_id = $lp_item_id AND orig_lp_item_view_id = $lp_item_view_id AND exe_cours_id = '".api_get_course_id()."' AND session_id = '" . api_get_session_id() . "'";
$query = Database::query($sql);
if (Database::num_rows($query) > 0 ) {
@ -801,8 +804,7 @@ function get_all_exercises_from_lp($lp_id, $course_db) {
* @param int $question_id
* @return str the comment
*/
function get_comments($id,$question_id)
{
function get_comments($id,$question_id) {
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql = "SELECT teacher_comment FROM ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id";
$sqlres = Database::query($sql);

Loading…
Cancel
Save