Quiz: Add page for recalculate all results - refs BT#16465

pull/3048/head
Angel Fernando Quiroz Campos 6 years ago
parent 9f24cfc767
commit 9ff32750ae
  1. 24
      main/exercise/exercise_report.php
  2. 61
      main/exercise/recalculate_all.php
  3. 9
      main/inc/lib/exercise.lib.php

@ -299,7 +299,7 @@ if (isset($_REQUEST['comments']) &&
Display::addFlash(Display::return_message(get_lang('LearnpathUpdated')));
}
$sql = "UPDATE $TBL_LP_ITEM_VIEW
$sql = "UPDATE $TBL_LP_ITEM_VIEW
SET score = '".floatval($tot)."'
$statusCondition
WHERE c_id = ".$course_id." AND id = ".$lp_item_view_id;
@ -339,6 +339,10 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
Display::return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&exerciseId='.$exercise_id.'" >'.
Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
$actions .= Display::url(
Display::return_icon('reload.png', get_lang('RecalculateResults'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'exercise/recalculate_all.php?'.api_get_cidreq()."&exercise=$exercise_id"
);
// clean result before a selected date icon
$actions .= Display::url(
Display::return_icon(
@ -434,7 +438,7 @@ if (($is_allowedToEdit || $is_tutor || api_is_coach()) &&
) {
// Close the user attempt otherwise left pending
$exe_id = (int) $_GET['id'];
$sql = "UPDATE $TBL_TRACK_EXERCISES SET status = ''
$sql = "UPDATE $TBL_TRACK_EXERCISES SET status = ''
WHERE exe_id = $exe_id AND status = 'incomplete'";
Database::query($sql);
}
@ -670,7 +674,7 @@ $extra_params['height'] = 'auto';
$extra_params['gridComplete'] = "
defaultGroupId = Cookies.get('default_group_".$exercise_id."');
if (typeof defaultGroupId !== 'undefined') {
$('#gs_group_name').val(defaultGroupId);
$('#gs_group_name').val(defaultGroupId);
}
";
@ -683,18 +687,18 @@ if (typeof defaultGroupId !== 'undefined') {
} else {
// get from cookies
defaultGroupId = Cookies.get('default_group_".$exercise_id."');
$('#gs_group_name').val(defaultGroupId);
$('#gs_group_name').val(defaultGroupId);
}
if (typeof defaultGroupId !== 'undefined') {
var posted_data = $(\"#results\").jqGrid('getGridParam', 'postData');
var extraFilter = ',{\"field\":\"group_id\",\"op\":\"eq\",\"data\":\"'+ defaultGroupId +'\"}]}';
var filters = posted_data.filters;
var stringObj = new String(filters);
stringObj.replace(']}', extraFilter);
var extraFilter = ',{\"field\":\"group_id\",\"op\":\"eq\",\"data\":\"'+ defaultGroupId +'\"}]}';
var filters = posted_data.filters;
var stringObj = new String(filters);
stringObj.replace(']}', extraFilter);
posted_data['group_id_in_toolbar'] = defaultGroupId;
$(this).jqGrid('setGridParam', 'postData', posted_data);
$(this).jqGrid('setGridParam', 'postData', posted_data);
}
";

@ -0,0 +1,61 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackEExercises;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
if (!isset($_REQUEST['exercise'])) {
api_not_allowed(true);
}
$exerciseId = (int) $_REQUEST['exercise'];
$is_allowedToEdit = api_is_allowed_to_edit(null, true) ||
api_is_drh() ||
api_is_student_boss() ||
api_is_session_admin();
if (!$is_allowedToEdit) {
api_not_allowed(true);
}
$result = ExerciseLib::get_exam_results_data(
0,
0,
1,
'asc',
$exerciseId,
'',
false,
null,
false,
false,
[],
false,
false,
true
);
foreach ($result as $track) {
/** @var TrackEExercises $trackedExercise */
$trackedExercise = ExerciseLib::recalculateResult(
$track['id'],
$track['user_id'],
$exerciseId
);
if (!$trackedExercise) {
Display::addFlash(
Display::return_message(get_lang('BadFormData').'<br>ID: '.$track['id'], 'warning', false)
);
}
}
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'
.api_get_cidreq()
."&exerciseId=$exerciseId";
header("Location: $url");

@ -1954,6 +1954,7 @@ HOTSPOT;
* @param array $userExtraFieldsToAdd
* @param bool $useCommaAsDecimalPoint
* @param bool $roundValues
* @param bool $getOnyIds
*
* @return array
*/
@ -1970,7 +1971,8 @@ HOTSPOT;
$showExerciseCategories = false,
$userExtraFieldsToAdd = [],
$useCommaAsDecimalPoint = false,
$roundValues = false
$roundValues = false,
$getOnyIds = false
) {
//@todo replace all this globals
global $filter;
@ -2244,7 +2246,10 @@ HOTSPOT;
if (!empty($column)) {
$sql .= " ORDER BY $column $direction ";
}
$sql .= " LIMIT $from, $number_of_items";
if (!$getOnyIds) {
$sql .= " LIMIT $from, $number_of_items";
}
$results = [];
$resx = Database::query($sql);

Loading…
Cancel
Save