Merge from 1.9.x

skala
Julio Montoya 13 years ago
commit f0ff87a0b3
  1. 106
      main/admin/settings.lib.php
  2. 7
      main/admin/settings.php
  3. 8
      main/css/base.css
  4. 8
      main/exercice/exercise.class.php
  5. 4
      main/exercice/exercise.lib.php
  6. 78
      main/exercice/exercise_reminder.php
  7. 46
      main/exercice/exercise_report.php
  8. 12
      main/exercice/exercise_show.php
  9. 15
      main/exercice/exercise_submit.php
  10. 2
      main/exercice/question.class.php
  11. 13
      main/exercice/result.php
  12. 24
      main/inc/lib/display.lib.php
  13. 42
      main/inc/lib/events.lib.inc.php
  14. 4
      main/inc/lib/mail.lib.inc.php
  15. 3
      main/inc/lib/tracking.lib.php
  16. 85
      main/inc/lib/usermanager.lib.php
  17. 2
      main/lang/english/admin.inc.php
  18. 3
      main/lang/english/learnpath.inc.php
  19. 3
      main/lang/english/tracking.inc.php
  20. 2
      main/lang/english/trad4all.inc.php
  21. 77
      main/newscorm/learnpath.class.php
  22. 11
      main/newscorm/lp_add_item.php
  23. 17
      main/newscorm/lp_controller.php
  24. 55
      main/survey/survey.lib.php
  25. 16
      main/survey/survey_invite.php
  26. 276
      main/tracking/exams.php

@ -143,7 +143,6 @@ function handle_plugins() {
} else {
echo '<tr>';
}
//echo '<tr>';
echo '<td>';
//Checkbox
if (in_array($plugin, $installed_plugins)) {
@ -197,20 +196,21 @@ function handle_stylesheets() {
$url_info = api_get_access_url($_configuration['access_url']);
if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) {
$is_style_changeable = true;
echo '<div class="actions" id="stylesheetuploadlink">';
/*echo '<div class="actions" id="stylesheetuploadlink">';
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM);
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>';
echo '</div>';
echo '</div>';*/
}
} else {
$is_style_changeable = true;
echo '<div class="actions" id="stylesheetuploadlink">';
/*echo '<div class="actions" id="stylesheetuploadlink">';
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM);
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>';
echo '</div>';
echo '</div>';*/
}
$form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets&showuploadform=true');
$form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets#tabs-2');
//$form->addElement('header', get_lang('UploadNewStylesheet'));
$form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40'));
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
@ -218,8 +218,27 @@ function handle_stylesheets() {
$form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save'));
if ($form->validate() && is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Upload'), array('class'=>'save'));
$show_upload_form = false;
if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
} else {
// Uploading a new stylesheet.
if ($_configuration['access_url'] == 1) {
//$form->display();
$show_upload_form = true;
} else {
if ($is_style_changeable) {
//$form->display();
$show_upload_form = true;
}
}
}
if (isset($_POST['stylesheet_upload'])) {
if ($form->validate()) {
$values = $form->exportValues();
$picture_element = $form->getElement('new_stylesheet');
$picture = $picture_element->getValue();
@ -233,39 +252,15 @@ function handle_stylesheets() {
if ($result) {
Display::display_confirmation_message(get_lang('StylesheetAdded'));
}
} else {
if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
} else {
if (!empty($_GET['showuploadform']) && $_GET['showuploadform'] == 'true') {
echo '<div id="newstylesheetform">';
} else {
echo '<div id="newstylesheetform" style="display: none;">';
}
// Uploading a new stylesheet.
if ($_configuration['access_url'] == 1) {
$form->display();
} else {
if ($is_style_changeable) {
$form->display();
}
}
echo '</div>';
}
}
?>
<script type="text/javascript">
function load_preview(){
$('#stylesheets_id').submit();
}
</script>
<?php
echo '<form id="stylesheets_id" name="stylesheets" class="form-search" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
echo '<br /><select name="style" onchange="load_preview(this)" >';
$form_change = new FormValidator('stylesheet_upload', 'post', api_get_self().'?category=Stylesheets', null, array('id' => 'stylesheets_id'));
//$form_change->addElement('header', get_lang('ChangeStylesheet'));
$list_of_styles = array();
$list_of_names = array();
$selected = null;
if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/')) {
$counter = 1;
@ -277,11 +272,11 @@ function handle_stylesheets() {
if (is_dir($dirpath)) {
if ($style_dir != '.' && $style_dir != '..') {
if (isset($_POST['style']) && $_POST['style'] == $style_dir) {
$selected = 'selected="true"';
if (isset($_POST['style']) && 'preview' && isset($_POST['style']) && $_POST['style'] == $style_dir) {
$selected = $style_dir;
} else {
if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) {
$selected = 'selected="true"';
$selected = $style_dir;
} else {
$selected = '';
}
@ -294,9 +289,8 @@ function handle_stylesheets() {
//echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>";
//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
} else {
echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
}
echo '<br />';
$counter++;
}
}
@ -306,14 +300,38 @@ function handle_stylesheets() {
//Sort styles in alphabetical order
asort($list_of_names);
$select_list = array();
foreach($list_of_names as $style_dir=>$item) {
echo $list_of_styles[$style_dir];
$select_list[$style_dir] = strip_tags($list_of_styles[$style_dir]);
}
//echo '</select><br />';
echo '</select>&nbsp;&nbsp;';
$form_change->addElement('select', 'style', get_lang('NameStylesheet'), $select_list);
$form_change->setDefaults('style', $selected);
if ($form_change->validate()) {
// Submit stylesheets.
if (isset($_POST['save'])) {
store_stylesheets();
echo Display::display_normal_message(get_lang('Saved'));
}
}
if ($is_style_changeable){
echo '<button class="btn save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>';
$group[] = $form_change->createElement('button', 'save', get_lang('SaveSettings'), array('class' => 'btn btn-primary'));
$group[] = $form_change->createElement('button', 'preview', get_lang('Preview'), array('class' => 'btn'));
$form_change->addGroup($group);
if ($show_upload_form) {
echo '<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>';
echo Display::tabs(array(get_lang('Update'), get_lang('UploadNewStylesheet')), array($form_change->return_form(), $form->return_form()));
} else {
$form_change->display();
}
} else {
$form_change->freeze();
}
}

@ -46,13 +46,6 @@ $settings_to_avoid = array(
$convert_byte_to_mega_list = array('dropbox_max_filesize', 'message_max_upload_filesize', 'default_document_quotum', 'default_group_quotum');
// Submit stylesheets.
if (isset($_POST['submit_stylesheets'])) {
$message = store_stylesheets();
header("Location: ".api_get_self()."?category=Stylesheets");
exit;
}
if (isset($_POST['style'])) {
Display::$preview_style = $_POST['style'];
}

@ -415,10 +415,16 @@ footer .container .row {
vertical-align:middle;
}
.actions a {
display:inline-block;
display: block;
float: left;
margin-right: 10px;
vertical-align:middle;
}
.actions .btn-toolbar {
margin : 0px;
}
.actions span {
margin-right: 10px;
vertical-align:middle;

@ -2270,7 +2270,7 @@ class Exercise {
$str = str_replace('\r\n', '', $str);
$choice = $arr[1];
$tmp = api_strrpos($choice[$j],' / ');
$tmp = api_strrpos($choice[$j],' / ');
$choice[$j] = api_substr($choice[$j],0,$tmp);
$choice[$j] = trim($choice[$j]);
@ -2359,6 +2359,9 @@ class Exercise {
} else {
$totalScore+= $questionScore;
}
if ($questionScore == '') {
$questionScore = 0;
}
$arrques = $questionName;
$arrans = $choice;
} else {
@ -2735,7 +2738,7 @@ class Exercise {
} else {
if ($debug) error_log('Showing questions $from '.$from);
switch($answerType) {
switch ($answerType) {
case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION:
case MULTIPLE_ANSWER :
@ -3433,6 +3436,7 @@ class Exercise {
public function is_visible($lp_id = 0, $lp_item_id = 0 , $lp_item_view_id = 0, $filter_by_admin = true) {
//1. By default the exercise is visible
$is_visible = true;
$message = null;
//1.1 Admins and teachers can access to the exercise
if ($filter_by_admin) {

@ -203,6 +203,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
$comment = $objAnswerTmp->selectComment($answerId);
$attributes = array();
// Unique answer
if ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$input_id = 'choice-'.$questionId.'-'.$answerId;
@ -2073,6 +2074,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
//Getting attempt info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
//Getting question list
$question_list = array();
if (!empty($exercise_stat_info['data_tracking'])) {
$question_list = explode(',', $exercise_stat_info['data_tracking']);
@ -2135,7 +2137,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
ob_start();
// We're inside *one* question. Go through each possible answer for this question
$result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null ,'exercise_result', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
$result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null , 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
$total_score += $result['score'];
$total_weight += $result['weight'];

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Exercise reminder overview
/**
* Exercise reminder overview
* Then it shows the results on the screen.
* @package chamilo.exercise
@ -46,11 +46,11 @@ if ( empty ($exerciseId)) { $exerciseId = intval($_REQUEST['exerciseId']);}
if ( empty ($objExercise)) { $objExercise = $_SESSION['objExercise'];}
if (!$objExercise) {
if (!$objExercise) {
//Redirect to the exercise overview
//Check if the exe_id exists
header("Location: overview.php?exerciseId=".$exerciseId);
exit;
exit;
}
$time_control = false;
@ -68,7 +68,7 @@ if ($time_control) {
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
}
@ -106,48 +106,48 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo Display::page_header(get_lang('QuestionsToReview'));
if ($time_control) {
echo $objExercise->return_time_left_div();
echo $objExercise->return_time_left_div();
}
echo Display::div('', array('id'=>'message'));
echo '<script>
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
echo '<script>
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
function final_submit() {
//Normal inputs
//Normal inputs
window.location = "exercise_result.php?origin='.$origin.'&exe_id='.$exe_id.'&" + lp_data;
}
function review_questions() {
var is_checked = 1;
$("input[type=checkbox]").each(function () {
if ($(this).attr("checked") == "checked") {
is_checked = 2;
is_checked = 2;
return false;
}
});
});
if (is_checked == 1) {
$("#message").addClass("warning-message");
$("#message").html("'.addslashes(get_lang('SelectAQuestionToReview')).'");
}
window.location = "exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&reminder=2&origin='.$origin.'&" + lp_data;
}
function save_remind_item(obj, question_id) {
var action = "";
var action = "";
if ($(obj).is(\':checked\')) {
action = "add";
} else {
action = "delete";
}
$.ajax({
}
$.ajax({
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=add_question_to_reminder",
data: "question_id="+question_id+"&exe_id='.$exe_id.'&action="+action,
success: function(return_value) {
},
});
data: "question_id="+question_id+"&exe_id='.$exe_id.'&action="+action,
success: function(return_value) {
},
});
}
</script>';
@ -161,10 +161,10 @@ $exercise_result = array();
foreach ($attempt_list as $question_id => $options) {
//echo $question_id.'<br />';
foreach($options as $item) {
$question_obj = Question::read($item['question_id']);
switch($question_obj->type) {
switch($question_obj->type) {
case FILL_IN_BLANKS:
$item['answer'] = $objExercise->fill_in_blank_answer_to_string($item['answer']);
break;
@ -172,12 +172,12 @@ foreach ($attempt_list as $question_id => $options) {
//var_dump($item['answer']);
break;
}
if ($item['answer'] != '0' && !empty($item['answer'])) {
if ($item['answer'] != '0' && !empty($item['answer'])) {
$exercise_result[] = $question_id;
break;
}
}
}
}
echo Display::label(get_lang('QuestionWithNoAnswer'), 'warning');
echo '<div class="clear"></div><br />';
@ -189,26 +189,26 @@ $counter = 0;
foreach ($question_list as $questionId) {
// destruction of the Question object
unset($objQuestionTmp);
// creates a temporary Question object
$objQuestionTmp = Question :: read($questionId);
// initialize question information
$quesId = $objQuestionTmp->selectId();
$check_id = 'remind_list['.$questionId.']';
$attributes = array('id'=>$check_id, 'onclick'=>"save_remind_item(this, '$questionId');");
$attributes = array('id'=>$check_id, 'onclick'=>"save_remind_item(this, '$questionId');");
if (in_array($questionId, $remind_list)) {
$attributes['checked'] = 1;
}
$label_attributes = array();
$label_attributes['class'] = 'checkbox';
$label_attributes['for'] = $check_id;
$label_attributes['for'] = $check_id;
$label_attributes['class'] = "checkbox";
$checkbox = Display::input('checkbox', 'remind_list['.$questionId.']', '', $attributes);
$url = 'exercise_submit.php?exerciseId='.$objExercise->id.'&num='.$counter.'&reminder=1';
$counter++;
if ($objExercise->type == ONE_PER_PAGE) {
$question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
@ -220,14 +220,14 @@ foreach ($question_list as $questionId) {
if (!in_array($questionId, $exercise_result)) {
$question_title = Display::label($question_title, 'warning');
}
$question_title = Display::tag('label', $checkbox.$question_title, $label_attributes);
$table .= Display::div($question_title, array('class'=>'exercise_reminder_item'));
$question_title = Display::tag('label', $checkbox.$question_title, $label_attributes);
$table .= Display::div($question_title, array('class'=>'exercise_reminder_item'));
} // end foreach() block that loops over all questions
echo Display::div($table, array('class'=>'span10'));
$exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('onclick'=>'final_submit();', 'class'=>'btn btn-success'));
$exercise_actions .= '&nbsp;'.Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick'=>'review_questions();','class'=>'btn'));
$exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('onclick'=>'final_submit();', 'class'=>'btn btn-warning'));
$exercise_actions .= '&nbsp;'.Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick'=>'review_questions();','class'=>'btn btn-success'));
echo Display::div('', array('class'=>'clear'));
echo Display::div($exercise_actions, array('class'=>'form-actions'));

@ -78,7 +78,7 @@ if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
if (isset($_REQUEST['extra_data']) && $_REQUEST['extra_data'] == 1) {
$load_extra_data = true;
}
require_once 'exercise_result.class.php';
switch ($_GET['export_format']) {
case 'xls' :
@ -99,8 +99,8 @@ if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
}
//Send student email @todo move this code in a class, library
if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
$id = intval($_GET['exeid']); //filtered by post-condition
if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid'] == strval(intval($_GET['exeid']))) {
$id = intval($_GET['exeid']); //filtered by post-condition
$track_exercise_info = get_exercise_track_exercise_info($id);
if (empty($track_exercise_info)) {
api_not_allowed();
@ -111,14 +111,13 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
$lp_id = $track_exercise_info['orig_lp_id'];
//$lp_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$course_info = api_get_course_info();
// Teacher data
$teacher_info = api_get_user_info(api_get_user_id());
$teacher_info = api_get_user_info(api_get_user_id());
$from_name = api_get_person_name($teacher_info['firstname'], $teacher_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
$url = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&id_session='.$session_id.'&exerciseId='.$exercise_id;
$url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id;
$my_post_info = array();
$post_content_id = array();
@ -132,16 +131,17 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
}
}
$loop_in_track=($comments_exist===true) ? (count($_POST)/2) : count($_POST);
$loop_in_track = ($comments_exist===true) ? (count($_POST)/2) : count($_POST);
$array_content_id_exe=array();
if ($comments_exist===true) {
$array_content_id_exe = array_slice($post_content_id,$loop_in_track);
$array_content_id_exe = array();
if ($comments_exist === true) {
$array_content_id_exe = array_slice($post_content_id, $loop_in_track);
} else {
$array_content_id_exe = $post_content_id;
}
for ($i=0;$i<$loop_in_track;$i++) {
for ($i=0; $i < $loop_in_track; $i++) {
$my_marks = Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]);
$contain_comments = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
if (isset($contain_comments)) {
@ -151,6 +151,7 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
}
$my_questionid = intval($array_content_id_exe[$i]);
$sql = "SELECT question from $TBL_QUESTIONS WHERE c_id = $course_id AND id = '$my_questionid'";
$result =Database::query($sql);
Database::result($result,0,"question");
@ -172,7 +173,7 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".floatval($tot)."' WHERE exe_id = ".$id;
Database::query($totquery);
if (isset($_POST['send_notification'])) {
//@todo move this somewhere else
$subject = get_lang('ExamSheetVCC');
@ -192,7 +193,6 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G
$message = str_replace("#url#", $url, $message);
MessageManager::send_message_simple($student_id, $subject, $message, api_get_user_id());
}
//Updating LP score here
if (in_array($origin, array ('tracking_course','user_course','correct_exercise_in_lp'))) {
@ -322,16 +322,16 @@ if (!empty($group_parameters)) {
if ($is_allowedToEdit || $is_tutor) {
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'),
get_lang('LastName'),
$columns = array(get_lang('FirstName'),
get_lang('LastName'),
get_lang('LoginName'),
get_lang('Group'),
get_lang('Duration').' ('.get_lang('MinMinute').')',
get_lang('StartDate'),
get_lang('EndDate'),
get_lang('Score'),
get_lang('Status'),
get_lang('ToolLearnpath'),
get_lang('Group'),
get_lang('Duration').' ('.get_lang('MinMinute').')',
get_lang('StartDate'),
get_lang('EndDate'),
get_lang('Score'),
get_lang('Status'),
get_lang('ToolLearnpath'),
get_lang('Actions')
);

@ -95,12 +95,6 @@ if (empty($objExercise)) {
}
$feedback_type = $objExercise->feedback_type;
//If is not valid
$session_control_key = get_session_time_control_key($exercise_id, $learnpath_id, $learnpath_item_id);
if (isset($session_control_key) && !exercise_time_control_is_valid($exercise_id, $learnpath_id, $learnpath_item_id) && !in_array($action, array('qualify','edit'))) {
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position = 0 WHERE exe_id = $id ";
Database::query($sql_fraud);
}
//Only users can see their own results
if (!$is_allowedToEdit) {
@ -109,8 +103,6 @@ if (!$is_allowedToEdit) {
}
}
//Unset session for clock time
exercise_time_control_delete($exercise_id, $learnpath_id, $learnpath_item_id);
if (isset($_SESSION['gradebook'])) {
$gradebook= Security::remove_XSS($_SESSION['gradebook']);
@ -237,7 +229,6 @@ $query = "SELECT attempts.question_id, answer FROM ".$TBL_TRACK_ATTEMPT." as att
AND questions.c_id = ".api_get_course_int_id()."
WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result = Database::query($query);
$question_list_from_database = array();
@ -260,9 +251,6 @@ if (!empty($track_exercise_info['data_tracking'])) {
if (empty($questionList)) {
$questionList = $question_list_from_database;
}
/*if (is_array($temp_question_list) && count($temp_question_list) == count($question_list_from_database)) {
$questionList = $tempquestionList;
}*/
} else {
$questionList = $question_list_from_database;
}

@ -347,7 +347,6 @@ if ($time_control) { //Sends the exercice form when the expired time is finished
// if the user has submitted the form
$exercise_title = $objExercise->selectTitle();
$exercise_description = $objExercise->selectDescription();
$exercise_sound = $objExercise->selectSound();
//Media questions
@ -665,8 +664,20 @@ if ($time_control) {
echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciceExpiredTimeMessage').'</div>';
}
if (!empty($objExercise->description)) {
echo Display::generate_accordion(array( array('title' => get_lang('ExerciseDescriptionLabel'), 'content' => $objExercise->description)));
echo "<script>
$(function() {
$('#description_content').accordion({
changestart: function(event, ui) {
//var clicked = $(this).find('.ui-state-active').attr('id');
//$('#'+clicked).load('/widgets/'+clicked);
$('#collapse1').html('".addslashes($objExercise->description)."');
}
});
});
</script>";
echo Display::generate_accordion(array(array('title' => get_lang('ExerciseDescriptionLabel'), 'content' => null)), 'jquery', 'description_content');
}
if ($origin != 'learnpath') {

@ -1458,7 +1458,7 @@ abstract class Question
// display question category, if any
$header = Testcategory::returnCategoryAndTitle($this->id);
$show_media = null;
if ($show_media) {
$header .= $this->show_media_content();
}

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Shows the exercise results
* Shows the exercise results
*
* @author Julio Montoya Armas - Simple exercise result page
*
*
*/
/**
@ -31,7 +31,7 @@ else
api_protect_course_script(true);
$id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
$show_headers = isset($_GET['show_headers']) ? intval($_GET['show_headers']) : null; //exe id
$show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
if ($origin == 'learnpath') {
$show_headers = false;
@ -60,7 +60,7 @@ if (!empty($exercise_id)) {
$objExercise->read($exercise_id);
}
//Only users can see their own results
//Only users can see their own results
if (!$is_allowedToEdit) {
if ($student_id != $current_user_id) {
api_not_allowed();
@ -70,12 +70,11 @@ if (!$is_allowedToEdit) {
if ($show_headers) {
$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
$interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
$this_section = SECTION_COURSES;
$this_section = SECTION_COURSES;
Display::display_header();
} else {
Display::display_reduced_header();
}
}
display_question_list_by_attempt($objExercise, $id, false);
if ($show_headers) {

@ -1453,12 +1453,17 @@ class Display {
return self::span($text, array('class' => 'boot-tooltip', 'title' => strip_tags($tip)));
}
public static function generate_accordion($items) {
public static function generate_accordion($items, $type = 'jquery', $id = null) {
$html = null;
if (!empty($items)) {
if (empty($id)) {
$id = api_get_unique_id();
//$html = '<div class="accordion" id="'.$id.'">'; //using bootstrap
}
if ($type == 'jquery') {
$html = '<div class="accordion_jquery" id="'.$id.'">'; //using jquery
} else {
$html = '<div class="accordion" id="'.$id.'">'; //using bootstrap
}
$count = 1;
foreach ($items as $item) {
@ -1482,4 +1487,19 @@ class Display {
}
return $html;
}
/**
* @todo use twig
*/
static function group_button($title, $elements) {
$html = '<div class="btn-toolbar">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">'.$title.' <span class="caret"></span></button>
<ul class="dropdown-menu">';
foreach ($elements as $item) {
$html .= Display::tag('li', Display::url($item['title'], $item['href']));
}
$html .= '</ul>
</div> </div>';
return $html;
}
} //end class Display

@ -484,24 +484,34 @@ function exercise_attempt($score, $answer, $question_id, $exe_id, $position, $ex
$file = Database::escape_string(basename($nano->load_filename_if_exists(false)));
}
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (exe_id, user_id, question_id, answer, marks, course_code, session_id, position, tms, filename)
VALUES (
".$exe_id.",
".$user_id.",
'".$question_id."',
'".$answer."',
'".$score."',
'".api_get_course_id()."',
'".api_get_session_id()."',
'".$position."',
'".$now."',
'".$file."'
)";
if ($debug) error_log("Saving question attempt: ");
if ($debug) error_log($sql);
if (!empty($question_id) && !empty($exe_id) && !empty($user_id)) {
//Check if attempt exists
$sql = "SELECT exe_id FROM $TBL_TRACK_ATTEMPT WHERE exe_id = $exe_id AND user_id = $user_id AND question_id = $question_id";
$result = Database::query($sql);
if (Database::num_rows($result)) {
if ($debug) error_log("Attempt already exist: exe_id: $exe_id - user_id:$user_id - question_id:$question_id");
//The attempt already exist do not update use update_event_exercice() instead
return false;
}
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (exe_id, user_id, question_id, answer, marks, course_code, session_id, position, tms, filename)
VALUES (
".$exe_id.",
".$user_id.",
'".$question_id."',
'".$answer."',
'".$score."',
'".api_get_course_id()."',
'".api_get_session_id()."',
'".$position."',
'".$now."',
'".$file."'
)";
if ($debug) error_log("Saving question attempt: ");
if ($debug) error_log($sql);
$res = Database::query($sql);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){
$recording_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);

@ -80,6 +80,10 @@ function api_mail_html($recipient_name, $recipient_email, $subject, $message, $s
$mail->AddReplyTo($sender_email, $sender_name);
}
if (isset($extra_headers['reply_to'])) {
$mail->AddReplyTo($extra_headers['reply_to']['mail'], $extra_headers['reply_to']['name']);
}
// Attachments
// $mail->AddAttachment($path);
// $mail->AddAttachment($path, $filename);

@ -2657,8 +2657,7 @@ class Tracking {
$weighting = $exercise_stat['exe_weighting'];
$exe_id = $exercise_stat['exe_id'];
//$latest_attempt_url .= '<a href="../exercice/exercise_show.php?origin=myprogress&id='.$exe_id.'&cidReq='.$course_info['code'].'&id_session='.$session_id.'"> '.Display::return_icon('quiz.gif', get_lang('Quiz')).' </a>';
$latest_attempt_url .= '../exercice/exercise_show.php?origin=myprogress&id='.$exe_id.'&cidReq='.$course_info['code'].'&id_session='.$session_id;
$latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercice/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
$percentage_score_result = Display::url(show_score($score, $weighting), $latest_attempt_url);
$my_score = 0;
if (!empty($weighting) && intval($weighting) != 0) {

@ -366,12 +366,15 @@ class UserManager {
}
/**
* Can user be deleted?
* This functions checks if there's a course in which the given user is the
* Can user be deleted? This function checks whether there's a course
* in which the given user is the
* only course administrator. If that is the case, the user can't be
* deleted because the course would remain without a course admin.
* @param int $user_id The user id
* @return boolean true if user can be deleted
* @assert (null) === false
* @assert (-1) === false
* @assert ('abc') === false
*/
public static function can_delete_user($user_id) {
global $_configuration;
@ -394,9 +397,14 @@ class UserManager {
}
/**
* Delete a user from the platform
* @param int $user_id The user id
* Delete a user from the platform, and all its belongings. This is a
* very dangerous function that should only be accessible by
* super-admins. Other roles should only be able to disable a user,
* which removes access to the platform but doesn't delete anything.
* @param int The ID of th user to be deleted
* @return boolean true if user is succesfully deleted, false otherwise
* @assert (null) === false
* @assert ('abc') === false
*/
public static function delete_user($user_id) {
@ -513,14 +521,16 @@ class UserManager {
}
/**
* Deactivate users. Can be called either as:
*
* - UserManager :: delete_users(1, 2, 3);
* Deletes users completely. Can be called either as:
* - UserManager :: delete_users(1, 2, 3); or
* - UserManager :: delete_users(array(1, 2, 3));
*
* @param array|int $ids
* @return boolean True if at least one user was successfuly deleted. False otherwise.
* @author Laurent Opprecht
* @uses UserManager::delete_user() to actually delete each user
* @assert (null) === false
* @assert (-1) === false
* @assert (array(-1)) === false
*/
static function delete_users($ids = array()) {
$result = false;
@ -534,14 +544,14 @@ class UserManager {
}
/**
* Deactivate users. Can be called either as:
*
* Disable users. Can be called either as:
* - UserManager :: deactivate_users(1, 2, 3);
* - UserManager :: deactivate_users(array(1, 2, 3));
*
* @param array|int $ids
* @return boolean
* @author Laurent Opprecht
* @assert (null) === false
* @assert (array(-1)) === false
*/
static function deactivate_users($ids = array()) {
if (empty($ids)) {
@ -557,14 +567,14 @@ class UserManager {
}
/**
* Activate users. Can be called either as:
*
* Enable users. Can be called either as:
* - UserManager :: activate_users(1, 2, 3);
* - UserManager :: activate_users(array(1, 2, 3));
*
* @param array|int $ids
* @param array|int IDs of the users to enable
* @return boolean
* @author Laurent Opprecht
* @assert (null) === false
* @assert (array(-1)) === false
*/
static function activate_users($ids = array()) {
if (empty($ids)) {
@ -583,6 +593,8 @@ class UserManager {
* @param int $user_id
* @param string $openid
* @return boolean true if the user information was updated
* @assert (false,'') === false
* @assert (-1,'') === false
*/
public static function update_openid($user_id, $openid) {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -594,22 +606,23 @@ class UserManager {
}
/**
* Update user information
* @param int $user_id
* @param string $firstname
* @param string $lastname
* @param string $username
* @param string $password
* @param string $auth_source
* @param string $email
* @param int $status
* @param string $official_code
* @param string $phone
* @param string $picture_uri
* Update user information with all the parameters passed to this function
* @param int The ID of the user to be updated
* @param string The user's firstname
* @param string The user's lastname
* @param string The user's username (login)
* @param string The user's password
* @param string The authentication source (default: "platform")
* @param string The user's e-mail address
* @param int The user's status
* @param string The user's official code (usually just an internal institutional code)
* @param string The user's phone number
* @param string The user's picture URL (internal to the Chamilo directory)
* @param int The user ID of the person who registered this user (optional, defaults to null)
* @param int The department of HR in which the user is registered (optional, defaults to 0)
* @param array A series of additional fields to add to this user as extra fields (optional, defaults to null)
* @return boolean true if the user information was updated
* @assert (false) === false
*/
public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0) {
global $_configuration;
@ -721,6 +734,9 @@ class UserManager {
*
* @param int user_id
* @param int Enable or disable
* @return void
* @assert (-1,0) === false
* @assert (1,1) === true
*/
public static function change_active_state($user_id, $active, $send_email_if_activated = false) {
$user_id = intval($user_id);
@ -760,6 +776,8 @@ class UserManager {
* Disables a user
*
* @param int User id
* @uses UserManager::change_active_state() to actually disable the user
* @assert (0) === false
*/
public static function disable($user_id) {
self::change_active_state($user_id, 0);
@ -769,17 +787,21 @@ class UserManager {
* Enable a user
*
* @param int User id
* @uses UserManager::change_active_state() to actually disable the user
* @assert (0) === false
*/
public static function enable($user_id) {
self::change_active_state($user_id, 1);
}
/**
* Returns the user's id based on the original id and field name in the extra fields. Returns 0 if no user was found
*
* Returns the user's id based on the original id and field name in
* the extra fields. Returns 0 if no user was found. This function is
* mostly useful in the context of a web services-based sinchronization
* @param string Original user id
* @param string Original field name
* @return int User id
* @assert ('0','---') === 0
*/
public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name) {
$t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD);
@ -798,8 +820,11 @@ class UserManager {
* Check if a username is available
* @param string the wanted username
* @return boolean true if the wanted username is available
* @assert ('') === false
* @assert ('xyzxyzxyz') === true
*/
public static function is_username_available($username) {
if (empty($username)) { return false; }
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT username FROM $table_user WHERE username = '".Database::escape_string($username)."'";
$res = Database::query($sql);
@ -815,6 +840,8 @@ class UserManager {
* @return string Suggests a username that contains only ASCII-letters and digits, without check for uniqueness within the system.
* @author Julio Montoya Armas
* @author Ivan Tcholakov, 2009 - rework about internationalization.
* @assert ('','') === false
* @assert ('a','b') === 'ab'
*/
public static function create_username($firstname, $lastname, $language = null, $encoding = null) {
if (is_null($encoding)) {

@ -1257,6 +1257,8 @@ $SessionStartDate = "Access start date";
$SessionDisplayEndDate = "End date to display";
$SessionDisplayStartDate = "Start date to display";
$UserHasNoCourse = "This user is not subscribed to any course";
$SessionPageEnabledComment = "When this option is enabled, the session title is a link to a special session page. When disabled, it is only a text title, without link. The session page linked to might be confusing for some users, which is why you might want to disable it.";
$SessionPageEnabledTitle = "Enable session link in courses list";
$ThisValueIsUsedInTheCourseURL = "This value is used in the course URL";
$ThereAreUsersUsingThisLanguageYouWantToDisableThisLanguageAndSetUsersWithTheDefaultPortalLanguage = "There are users using this language. Do you want to disable this language and set all this users with the default portal language?";
$SessionTutorsCanSeeExpiredSessionsResultsComment = "Can session tutors see the reports for their session after it has expired?";

@ -247,6 +247,9 @@ $ModifyHotPotatoes = "Modify hotpotatoes";
$SaveHotpotatoes = "Save hotpotatoes";
$ReturnToLPList = "Return to list";
$LpPrerequisiteDescription = "Selecting another learning path as a prerequisite will hide the current prerequisite until the one in prerequisite is fully completed (100%)";
$PrerequisitesOptions = "Prerequisites options";
$ClearAllPrerequisites = "Clear all prerequisites";
$SetPrerequisiteForEachItem = "Set previous step as prerequisite for each step";
$ClickOnTheLearnerViewToSeeYourLearningPath = "Click on the [Learner view] button to see your learning path";
$ExerciseCantBeEditedAfterAddingToTheLP = "Exercise can't be edited after being added to the Learning Path";
$EnableTimeLimits = "Enable availability limits";

@ -269,6 +269,9 @@ $LinkInvisible = "Link made invisible";
$LinkAdded = "Link added";
$Minutes = "Minutes";
$BackupCreated = "Backup created";
$TrainingHoursAccumulated = "Training hours accumulated";
$ManHours = "Man hours";
$NotesObtained = "Notes obtained";
$DisplayCourseOverview = "Courses overview";
$DisplaySessionOverview = "Sessions overview";
$TotalNumberOfMessages = "Total number of messages";

@ -950,6 +950,7 @@ $SkillXWithCourseX = "%s with %s";
$ToGetToLearnXYouWillNeedToTakeOneOfTheFollowingCourses = "To get to learn %s you will need to take one of the following courses:";
$YourSkillRankingX = "Your skill ranking: %s";
$ManageSkills = "Manage skills";
$StartDateMustBeBeforeTheEndDate = "Start date must be before the end date";
$SkillRoot = "Root";
$SkillInfo = "Skill info";
$GetNewSkills = "Get new skills";
@ -976,6 +977,7 @@ $NumberOfCoursesPrivate = "Number of private courses";
$NumberOfCoursesClosed = "Number of closed courses";
$NumberOfCoursesTotal = "Total number of courses";
$NumberOfUsersActive = "Number of active users";
$Approved = "Approved";
$EditSettings = "Edit settings";
$ThisValueCantBeChanged = "This value can't be changed.";
$TotalAvailableUsers = "Total available users";

@ -113,6 +113,8 @@ class learnpath {
}
}
$this->set_course_int_id($course_id);
// Check learnpath ID.
if (empty($lp_id)) {
$this->error = 'Learnpath ID is empty';
@ -3608,7 +3610,6 @@ class learnpath {
$prereq_string = $this->items[$item]->get_prereq_string();
}
if (empty($prereq_string)) {
return true;
}
@ -4043,7 +4044,6 @@ class learnpath {
} else {
return false;
}
}
/**
@ -4234,7 +4234,7 @@ class learnpath {
if ($this->debug > 2) {
error_log('New LP - lp updated with new preview requisite : ' . $this->requisite, 0);
}
$res = Database::query($sql);
Database::query($sql);
return true;
}
@ -4368,7 +4368,7 @@ class learnpath {
if ($this->debug > 2) {
error_log('New LP - lp updated with new expired_on : ' . $this->modified_on, 0);
}
$res = Database::query($sql);
Database::query($sql);
return true;
}
@ -5308,6 +5308,18 @@ class learnpath {
$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '&amp;updateaudio=true">' . Display :: return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=edit&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM).'</a>';
$buttons = array(
array(
'title' => get_lang('SetPrerequisiteForEachItem'),
'href' => 'lp_controller.php?'.api_get_cidreq().'&amp;action=set_previous_step_as_prerequisite&amp;lp_id=' . $_SESSION['oLP']->lp_id,
),
array(
'title' => get_lang('ClearAllPrerequisites'),
'href' => 'lp_controller.php?'.api_get_cidreq().'&amp;action=clear_prerequisites&amp;lp_id=' . $_SESSION['oLP']->lp_id,
),
);
$return .= Display::group_button(get_lang('PrerequisitesOptions'), $buttons);
$return .= '</div>';
echo $return;
}
@ -7786,10 +7798,9 @@ class learnpath {
$return .= get_lang('AddEditPrerequisites');
$return .= '</legend>';
$return .= '<div class="sectioncomment">';
$return .= '<form method="POST">';
$return .= '<table class="data_table" style="width:650px">';
$return .= '<table class="data_table">';
$return .= '<tr>';
$return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Minimum') . '</th>';
@ -7837,6 +7848,9 @@ class learnpath {
break;
$return .= '<tr>';
$return .= '<td class="radio"' . (($arrLP[$i]['item_type'] != TOOL_QUIZ && $arrLP[$i]['item_type'] != TOOL_HOTPOTATOES) ? ' colspan="3"' : '') . '>';
$return .= '<label for="id' . $arrLP[$i]['id'] . '">';
$return .= '<input' . (($arrLP[$i]['id'] == $preq_id) ? ' checked="checked" ' : '') . (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter') ? ' disabled="disabled" ' : ' ') . 'id="id' . $arrLP[$i]['id'] . '" name="prerequisites" style="margin-left:' . $arrLP[$i]['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $arrLP[$i]['id'] . '" />';
$icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
if (file_exists('../img/lp_' . $icon_name . '.png')) {
@ -7847,8 +7861,9 @@ class learnpath {
} else {
$return .= Display::return_icon('folder_document.gif','',array('style'=>'margin-right:5px;'));
}
$return .= '<label for="id' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</label>';
$return .= $arrLP[$i]['title'] . '</label>';
$return .= '</td>';
//$return .= '<td class="radio"' . (($arrLP[$i]['item_type'] != TOOL_HOTPOTATOES) ? ' colspan="3"' : '') . ' />';
if ($arrLP[$i]['item_type'] == TOOL_QUIZ) {
@ -7874,10 +7889,8 @@ class learnpath {
$return .= '</table>';
$return .= '<div style="padding-top:3px;">';
$return .= '<button class="save" name="submit_button" type="submit">' . get_lang('ModifyPrerequisites') . '</button>';
$return .= '</div>';
$return .= '</form>';
// $return .= '</div>';
$return .= '</form>';
return $return;
}
@ -9220,6 +9233,50 @@ EOD;
return false;
}
}
function clear_prerequisites() {
$course_id = $this->get_course_int_id();
if ($this->debug > 0) {
error_log('New LP - In learnpath::clear_prerequisites()', 0);
}
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$lp_id = $this->get_id();
//Cleaning prerequisites
$sql = "UPDATE $tbl_lp_item SET prerequisite = ''
WHERE c_id = ".$course_id." AND lp_id = '$lp_id'";
Database::query($sql);
//Cleaning mastery score for exercises
$sql = "UPDATE $tbl_lp_item SET mastery_score = ''
WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND item_type = 'quiz'";
Database::query($sql);
}
function set_previous_step_as_prerequisite_for_all_items() {
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$course_id = $this->get_course_int_id();
$lp_id = $this->get_id();
if (!empty($this->items)) {
$old_id = null;
$old_max = 0;
$old_type = null;
foreach ($this->items as $item) {
if (!empty($old_id)) {
$current_item_id = $item->get_id();
if ($old_type == 'quiz') {
$sql = "UPDATE $tbl_lp_item SET mastery_score = '$old_max' WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$old_id'";
Database::query($sql);
}
$sql = "UPDATE $tbl_lp_item SET prerequisite = '$old_id' WHERE c_id = ".$course_id." AND lp_id = '$lp_id' AND id = '$current_item_id'";
Database::query($sql);
}
$old_id = $item->get_id();
$old_max = $item->get_max();
$old_type = $item->get_type();
}
}
}
}
if (!function_exists('trim_value')) {

@ -248,10 +248,14 @@ echo '<div id="lp_sidebar" class="span4">';
echo $_SESSION['oLP']->return_new_tree(null, true);
$message = isset($_REQUEST['message']) ? $_REQUEST['message'] : null;
// Show the template list.
if ($type == 'document' && !isset($_GET['file'])) {
// Show the template list.
echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';}
echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
}
echo '</div>';
//hide bar div
@ -261,6 +265,11 @@ if ($action == 'add_item' && $type == 'document' && !isset($_GET['file'])) {
echo '<div id="doc_form" class="span8">';
//@todo use session flash messages
if (in_array($message, array('ItemUpdated'))) {
echo Display::return_message(get_lang($message));
}
if (isset($new_item_id) && is_numeric($new_item_id)) {
switch ($type) {
case 'chapter':

@ -100,6 +100,7 @@ $lpfound = false;
$myrefresh = 0;
$myrefresh_id = 0;
if (!empty($_SESSION['refresh']) && $_SESSION['refresh'] == 1) {
// Check if we should do a refresh of the oLP object (for example after editing the LP).
// If refresh is set, we regenerate the oLP object from the database (kind of flush).
@ -135,7 +136,6 @@ if (isset($_SESSION['lpobject'])) {
}
}
$course_id = api_get_course_int_id();
if ($debug>0) error_log('New LP - Passed data remains check', 0);
@ -224,8 +224,6 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
}
}
$action = (!empty($_REQUEST['action']) ? $_REQUEST['action'] : '');
switch ($action) {
@ -966,15 +964,24 @@ switch ($action) {
require 'lp_list.php';
} else {
if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); }
if ( !empty($_REQUEST['item_id']) ) {
if (!empty($_REQUEST['item_id']) ) {
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
}
require 'lp_impress.php';
}
break;
case 'set_previous_step_as_prerequisite':
$_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
header('Location: '.$url);
break;
case 'clear_prerequisites':
$_SESSION['oLP']->clear_prerequisites();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated";
header('Location: '.$url);
break;
default:
if ($debug > 0) error_log('New LP - default action triggered', 0);
//$_SESSION['refresh'] = 1;
require 'lp_list.php';
break;
}

@ -3816,14 +3816,15 @@ class SurveyUtil {
}
$new_user = false; // User not already invited
// Store the invitation if user_id not in $already_invited['course_users'] OR email is not in $already_invited['additional_users']
$addit_users_array = explode(';', $already_invited['additional_users']);
$addit_users_array = isset($already_invited['additional_users']) && !empty($already_invited['additional_users']) ? explode(';', $already_invited['additional_users']) : array();
$my_alredy_invited = ($already_invited['course_users'] == null) ? array() : $already_invited['course_users'];
if ((is_numeric($value) && !in_array($value, $my_alredy_invited)) || (!is_numeric($value) && !in_array($value, $addit_users_array))) {
$new_user = true;
if (!array_key_exists($value, $survey_invitations)) {
$sql = "INSERT INTO $table_survey_invitation (c_id, user, survey_code, invitation_code, invitation_date) VALUES
($course_id, '".Database::escape_string($value)."','".Database::escape_string($survey_data['code'])."','".Database::escape_string($invitation_code)."','".Database::escape_string(date('Y-m-d H:i:s'))."')";
$result = Database::query($sql);
Database::query($sql);
}
}
// Send the email if checkboxed
@ -3927,7 +3928,7 @@ class SurveyUtil {
// Updating the field in the survey table
$sql = "UPDATE $table_survey SET invited = '".Database::escape_string($total_invited)."' WHERE c_id = $course_id AND code = '".Database::escape_string($survey_code)."'";
$result = Database::query($sql);
Database::query($sql);
}
/**
@ -3940,9 +3941,10 @@ class SurveyUtil {
* @todo consider making $defaults['additional_users'] also an array
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya, adding c_id fixes - Dec 2012
* @version January 2007
*/
static function get_invited_users($survey_code, $course_code = '') {
static function get_invited_users($survey_code, $course_code = '', $session_id = 0) {
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
@ -3950,32 +3952,53 @@ class SurveyUtil {
$course_id = api_get_course_int_id();
}
if (empty($session_id)) {
$session_id = api_get_session_id();
}
$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// Selecting all the invitations of this survey AND the additional emailaddresses (the left join)
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
$sql = "SELECT user
FROM $table_survey_invitation as table_invitation
LEFT JOIN $table_user as table_user
ON table_invitation.user = table_user.user_id AND table_invitation.c_id = $course_id
WHERE survey_code='".Database::escape_string($survey_code)."'".$order_clause;
WHERE table_invitation.c_id = $course_id AND
survey_code='".Database::escape_string($survey_code)."' AND
session_id = $session_id
";
$defaults = array();
$defaults['course_users'] = array();
$defaults['additional_users'] = '';
$defaults['additional_users'] = array();
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
if (is_numeric($row['user'])) {
$defaults['course_users'][] = $row['user'];
} else {
if (empty($defaults['additional_users'])) {
$defaults['additional_users'] = $row['user'];
} else {
$defaults['additional_users'] .= ';'.$row['user'];
}
if (!empty($row['user'])) {
$defaults['additional_users'][] = $row['user'];
}
}
}
if (!empty($defaults['course_users'])) {
$user_ids = implode("','", $defaults['course_users']);
$sql = "SELECT user_id FROM $table_user WHERE user_id IN ('$user_ids') $order_clause";
$result = Database::query($sql);
$fixed_users = array();
while ($row = Database::fetch_array($result)) {
$fixed_users[] = $row['user_id'];
}
$defaults['course_users'] = $fixed_users;
}
if (!empty($defaults['additional_users'])) {
$defaults['additional_users'] = implode(';', $defaults['additional_users']);
}
//error_log(print_r($defaults, 1));
return $defaults;
}
@ -4299,9 +4322,9 @@ class SurveyUtil {
survey.survey_id AS col9,
survey.session_id AS session_id
FROM $table_survey survey
LEFT JOIN $table_survey_question survey_question ON survey.survey_id = survey_question.survey_id
LEFT JOIN $table_survey_question survey_question ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = $course_id)
INNER JOIN $table_user user ON (survey.author = user.user_id)
WHERE survey.c_id = $course_id AND survey_question.c_id = $course_id
WHERE survey.c_id = $course_id
$search_restriction
$condition_session ";
$sql .= " GROUP BY survey.survey_id";

@ -94,14 +94,14 @@ if ($survey_data['invited'] > 0 && !isset($_POST['submit'])) {
}
// Building the form for publishing the survey
$form = new FormValidator('publish_form', 'post', api_get_self().'?survey_id='.$survey_id);
$form = new FormValidator('publish_form', 'post', api_get_self().'?survey_id='.$survey_id.'&'.api_get_cidReq());
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], $_SESSION['id_session'], '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$complete_user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$possible_users = array();
foreach ($complete_user_list as $index => & $user) {
foreach ($complete_user_list as & $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
@ -119,15 +119,16 @@ $users->setElementTemplate('
');
$users->setButtonAttributes('add', array('class' => 'btn arrowr'));
$users->setButtonAttributes('remove', array('class' => 'btn arrowl'));
// Additional users
$form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 2));
$form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 5));
//$form->addElement('html', '<div> <h3>'.Display::return_icon('course.png', Security::remove_XSS(get_lang('SendMail')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('SendMail')).'</h3><div>');
$form->addElement('html', '<div id="check_mail">');
$form->addElement('checkbox', 'send_mail','', get_lang('SendMail'));
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="mail_text">');
// The title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6'));
// The text of the mail
@ -169,6 +170,7 @@ if ($form->validate()) {
Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete'));
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
@ -211,11 +213,12 @@ if ($form->validate()) {
$message .= '<a href="survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.$total_invited.'</a> ';
$message .= get_lang('WereInvited');
Display::display_normal_message($message, false);
Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
Display::display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
}
} else {
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
@ -224,6 +227,7 @@ if ($form->validate()) {
}
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
$form->display();
}

@ -16,7 +16,7 @@ $this_section = SECTION_TRACKING;
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
if(!$is_allowedToTrack) {
if(!$is_allowedToTrack) {
api_not_allowed();
}
@ -27,25 +27,25 @@ if (isset($_GET['export'])) {
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (api_is_platform_admin() ) {
if (api_is_platform_admin() ) {
$global = true;
} else {
$global = false;
}
if ($global) {
$temp_course_list = CourseManager :: get_courses_list();
$temp_course_list = CourseManager :: get_courses_list();
foreach($temp_course_list as $temp_course_item) {
$course_item = CourseManager ::get_course_information($temp_course_item['code']);
$course_item = CourseManager ::get_course_information($temp_course_item['code']);
$course_list[]= array( 'db_name' => $course_item['db_name'],
'code' => $course_item['code'],
'real_id' => $course_item['real_id'],
'title' => $course_item['title']);
'title' => $course_item['title']);
}
} else {
} else {
$current_course['db_name'] = $_course['dbName'];
$current_course['real_id'] = $_course['real_id'];
$current_course['code'] = $_course['id'];
$current_course['code'] = $_course['id'];
$course_list = array($current_course);
}
@ -58,15 +58,15 @@ if ($global) {
$t_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$course_id = api_get_course_int_id();
$sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' ORDER BY quiz.title ASC";
$resultExercices = Database::query($sqlExercices);
$resultExercices = Database::query($sqlExercices);
$exercise_list[0] = get_lang('All');
while($a_exercices = Database::fetch_array($resultExercices)) {
$exercise_list[$a_exercices['id']] = $a_exercices['title'];
}
}
$form->addElement('select', 'exercise_id', get_lang('Exercise'), $exercise_list);
}
//$form->addElement('submit','submit',get_lang('Filter'));
$form->addElement('style_submit_button','submit', get_lang('Filter'),'class="search"' );
@ -80,16 +80,16 @@ if (!$export_to_xls) {
Display :: display_header(get_lang('Reporting'));
echo '<div class="actions">';
if ($global) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'auth/my_progress.php">'.
Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM);
echo '</a>';
echo '<span style="float:right">';
echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'">'.Display::return_icon('export_excel.png',get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</span>';
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
if (api_is_platform_admin()) {
$menu_items[] = Display::url(Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=admin');
@ -97,24 +97,24 @@ if (!$export_to_xls) {
$menu_items[] = Display::url(Display::return_icon('star.png', get_lang('CoachInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=coach');
}
$menu_items[] = Display::return_icon('quiz_na.png', get_lang('ExamTracking'), array(), 32);
$nb_menu_items = count($menu_items);
if($nb_menu_items>1) {
foreach($menu_items as $key=> $item) {
echo $item;
echo $item;
}
}
} else {
echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;|&nbsp';
echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=resources">'.get_lang('ResourcesTracking').'</a>';
echo ' | '.get_lang('ExamTracking').'';
echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a>';
}
echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a>';
}
echo '</div>';
$form->display();
$form->display();
echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
}
@ -128,10 +128,10 @@ if ($global) {
$html_result .= '<th>'.get_lang('ExamFail').'</th>';
$html_result .= '<th>'.get_lang('TotalStudents').'</th>';
$html_result .= '</tr>';
} else {
$html_result .= '<table class="data_table">';
} else {
$html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('Quiz').'</th>';
$html_result .= '<th>'.get_lang('User').'</th>';
$html_result .= '<th>'.get_lang('User').'</th>';
//$html_result .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'</th>';
$html_result .= '<th>'.get_lang('Percentage').' %</th>';
$html_result .= '<th>'.get_lang('Status').'</th>';
@ -146,14 +146,14 @@ if(!empty($course_list) && is_array($course_list))
foreach ($course_list as $current_course) {
$global_row = $row_not_global = array();
$course_id = $current_course['real_id'];
$a_students = CourseManager :: get_student_list_from_course_code($current_course['code'], false);
$a_students = CourseManager :: get_student_list_from_course_code($current_course['code'], false);
$total_students = count($a_students);
$sqlExercices = "SELECT count(id) as count FROM ".$t_quiz." AS quiz WHERE active='1' AND c_id = $course_id ";
$resultExercices = Database::query($sqlExercices);
$data_exercises = Database::store_result($resultExercices);
$exercise_count = $data_exercises[0]['count'];
$exercise_count = $data_exercises[0]['count'];
if ($global) {
if ($exercise_count == 0) {
$exercise_count = 2;
@ -161,25 +161,25 @@ foreach ($course_list as $current_course) {
$html_result .= "<tr class='$s_css_class'>
<td rowspan=$exercise_count>";
$html_result .= $current_course['title'];
$html_result .= "</td>";
$html_result .= "</td>";
}
$sql = "SELECT visibility FROM $table WHERE c_id = $course_id AND name='quiz'";
$resultVisibilityQuizz = Database::query($sql);
if (Database::result($resultVisibilityQuizz, 0 ,'visibility') == 1) {
$sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' ORDER BY quiz.title ASC";
if (Database::result($resultVisibilityQuizz, 0 ,'visibility') == 1) {
$sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' ORDER BY quiz.title ASC";
//Getting the exam list
if (!$global) {
if (!empty($exercise_id)) {
$sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' AND id = $exercise_id ORDER BY quiz.title ASC";
$sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' AND id = $exercise_id ORDER BY quiz.title ASC";
}
}
}
$resultExercices = Database::query($sqlExercices);
$i = 0;
if (Database::num_rows($resultExercices) > 0) {
if (Database::num_rows($resultExercices) > 0) {
while($a_exercices = Database::fetch_array($resultExercices)) {
$global_row[]= $current_course['title'];
$global_row[]= $current_course['title'];
if (!$global) {
$html_result .= "<tr class='$s_css_class'>";
}
@ -187,36 +187,36 @@ foreach ($course_list as $current_course) {
$html_result .= '<td ROWSPAN="'.$total_students.'">';
} else {
$html_result .= '<td>';
}
$html_result .= $a_exercices['title'];
$html_result .= '</td>';
}
$html_result .= $a_exercices['title'];
$html_result .= '</td>';
$global_row[]=$a_exercices['title'];
$row_not_global['exercise']= $a_exercices['title'];
$taken = 0;
$total_with_parameter = 0;
$fail = 0;
$not_taken = 0;
$total_with_parameter_score = 0;
$total_with_parameter_porcentage = 0;
$student_result = array();
foreach ($a_students as $student ) {
$student_result = array();
foreach ($a_students as $student ) {
$current_student_id = $student['user_id'];
$sqlEssais = " SELECT COUNT(ex.exe_id) as essais
FROM $tbl_stats_exercices AS ex
WHERE ex.exe_cours_id = '".$current_course['code']."'
AND ex.exe_exo_id = ".$a_exercices['id']."
AND exe_user_id='".$current_student_id."'";
$resultEssais = Database::query($sqlEssais);
$a_essais = Database::fetch_array($resultEssais);
$resultEssais = Database::query($sqlEssais);
$a_essais = Database::fetch_array($resultEssais);
$sqlScore = "SELECT exe_id, exe_result,exe_weighting
FROM $tbl_stats_exercices
WHERE exe_user_id = ".$current_student_id."
@ -224,42 +224,42 @@ foreach ($course_list as $current_course) {
AND exe_exo_id = ".$a_exercices['id']."
ORDER BY exe_result DESC LIMIT 1"; // we take the higher value
//ORDER BY exe_date DESC LIMIT 1";
$resultScore = Database::query($sqlScore);
$score = 0;
while($a_score = Database::fetch_array($resultScore)) {
$score = $score + $a_score['exe_result'];
$weighting = $weighting + $a_score['exe_weighting'];
$exe_id = $a_score['exe_id'];
}
$pourcentageScore = 0;
if ($weighting!=0) {
$pourcentageScore = round(($score*100)/$weighting);
}
$weighting = 0;
$weighting = 0;
if($i%2==0){
$s_css_class="row_odd";
} else {
$s_css_class="row_even";
}
}
$i++;
/*echo " <td align='right'>
";
echo $current_student_id.' ';
echo " </td>";
*/
//var_dump($pourcentageScore);
/* echo " <td align='right'>
";
echo $pourcentageScore.' %';
echo " </td>";
echo "<td align='right'>
";
/*
@ -267,47 +267,35 @@ foreach ($course_list as $current_course) {
echo " </td>
<td align='center'>
";*/
if ($a_essais['essais'] > 0 ) {
$taken++;
$taken++;
}
if ($pourcentageScore >= $parameter_porcentage) {
$total_with_parameter_porcentage++;
}
if ($pourcentageScore >= $filter_score) {
$total_with_parameter_score++;
}
/*
$sql_last_attempt='SELECT exe_id FROM '.$tbl_stats_exercices.' WHERE exe_exo_id="'.$a_exercices['id'].'" AND exe_user_id="'.$current_student_id.'" AND exe_cours_id="'.$current_course['code'].'" ORDER BY exe_date DESC LIMIT 1';
$resultLastAttempt = Database::query($sql_last_attempt);
if(Database::num_rows($resultLastAttempt)>0) {
$id_last_attempt=Database::result($resultLastAttempt,0,0);
if($a_essais['essais']>0) {
/// echo '<a href="../exercice/exercise_show.php?id='.$id_last_attempt.'&cidReq='.$current_course['code'].'&student='.$current_student_id.'&origin='.(empty($_GET['origin']) ? 'tracking' : $_GET['origin']).'"> <img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif" border="0"> </a>';
}
}
*/
$total_with_parameter_score++;
}
if (!$global) {
$user_info = api_get_user_info($current_student_id);
$user_info = api_get_user_info($current_student_id);
//User
$user_row = '<td >';
$user_row = '<td >';
$user_row .= $user_info['firstName'].' '.$user_info['lastName'];
$user_row .= '</td>';
$user_info = $user_info['firstName'].' '.$user_info['lastName'];
//Best result
$user_info = $user_info['firstName'].' '.$user_info['lastName'];
//Best result
if (!empty($a_essais['essais'])) {
$user_row .= '<td >';
$user_row .= $pourcentageScore;
$temp_array [] = $pourcentageScore;
$user_row .= $pourcentageScore;
$temp_array [] = $pourcentageScore;
$user_row .= '</td>';
if ($pourcentageScore >= $filter_score ) {
$user_row .= '<td style="background-color:#DFFFA8">';
$user_row .= get_lang('PassExam').'</td>';
@ -317,34 +305,34 @@ foreach ($course_list as $current_course) {
$user_row .= get_lang('ExamFail').'</td>';
$temp_array [] = get_lang('ExamFail');
}
$user_row .= '<td >';
$user_row .= '<td >';
$user_row .= $a_essais['essais'];
$temp_array [] = $a_essais['essais'];
$user_row .= '</td>';
$user_row .= '</td>';
} else {
$score = '-';
$user_row .= '<td >';
$user_row .= '-';
$temp_array [] = '-';
$user_row .= '</td>';
$user_row .= '<td style="background-color:#FCE89A">';
$user_row .= '<td style="background-color:#FCE89A">';
$user_row .= get_lang('NoAttempt');
$temp_array [] = get_lang('NoAttempt');
$user_row .= '</td>';
$user_row .= '<td >';
$user_row .= '<td >';
$user_row .= 0;
$temp_array [] = 0;
$user_row .= '</td>';
}
}
$user_row .= '</tr>';
$student_result[$current_student_id] = array('html'=>$user_row,'score'=>$score,'array'=>$temp_array,'user'=>$user_info);
$student_result[$current_student_id] = array('html'=>$user_row,'score'=>$score,'array'=>$temp_array,'user'=>$user_info);
$temp_array = array();
}
}
if (!$global) {
if (!$global) {
if (!empty($student_result)) {
$student_result_empty = $student_result_content = array();
foreach($student_result as $row) {
@ -357,11 +345,11 @@ foreach ($course_list as $current_course) {
//Sort only users with content
usort($student_result_content, 'sort_user');
$student_result = array_merge($student_result_content, $student_result_empty );
foreach($student_result as $row) {
$html_result .=$row['html'];
$row_not_global['results'][]= $row['array'];
$row_not_global['users'][] = $row['user'];
$row_not_global['users'][] = $row['user'];
}
$export_array[] = $row_not_global;
$row_not_global = array();
@ -369,69 +357,69 @@ foreach ($course_list as $current_course) {
}
if ($global) {
//Exam taken
$html_result .= '<td >';
$html_result .= '<td >';
$html_result .= $taken;
$global_row[]= $taken;
//echo $total.' / '.$total_students;
$html_result .= '</td>';
//Exam NOT taken
$html_result .= '<td >';
//Exam NOT taken
$html_result .= '<td >';
$html_result .= $not_taken = $total_students - $taken;
$global_row[]= $not_taken;
$html_result .= '</td>';
//Examn pass
if (!empty($total_with_parameter_score)) {
$html_result .= '<td style="background-color:#DFFFA8" >';
} else {
$html_result .= '<td style="background-color:#FCE89A" >';
}
$html_result .= $total_with_parameter_score;
$global_row[]= $total_with_parameter_score;
$html_result .= '</td>';
//Exam fail
//Exam fail
$html_result .= '<td >';
$html_result .= $fail = $taken - $total_with_parameter_score;
$global_row[]= $fail;
$html_result .= '</td>';
$html_result .= '<td >';
$html_result .= $total_students;
$global_row[]= $total_students;
$global_counter++;
$html_result .= '</td>';
$html_result .= '</tr>';
$html_result .= '</td>';
$html_result .= '</tr>';
$export_array_global[] = $global_row;
$global_row = array();
$global_row = array();
}
}
} else {
$html_result .= " <tr>
$html_result .= " <tr>
<td colspan='6'>
".get_lang('NoExercise')."
</td>
</tr>
";
}
}
} else {
$html_result .= " <tr>
$html_result .= " <tr>
<td colspan='6'>
".get_lang('NoExercise')."
</td>
</tr>
";
}
}
}
$html_result .= '</table>';
if (!$export_to_xls) {
echo $html_result;
echo $html_result;
}
$filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls';
if ($export_to_xls) {
@ -451,10 +439,10 @@ function sort_user($a, $b) {
}
return 0;
}
return 1;
return 1;
}
function export_complete_report_xls($filename, $array) {
function export_complete_report_xls($filename, $array) {
global $charset, $global, $filter_score;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
@ -462,18 +450,18 @@ function export_complete_report_xls($filename, $array) {
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
$worksheet->setInputEncoding($charset);
$line = 0;
$column = 0; //skip the first column (row titles)
if ($global) {
$worksheet->write($line,$column,get_lang('Courses'));
$column++;
$worksheet->write($line,$column,get_lang('Exercises'));
$column++;
$worksheet->write($line,$column,get_lang('ExamTaken'));
$column++;
$column++;
$worksheet->write($line,$column,get_lang('ExamNotTaken'));
$column++;
$worksheet->write($line,$column,sprintf(get_lang('ExamPassX'), $filter_score).'%');
@ -481,45 +469,45 @@ function export_complete_report_xls($filename, $array) {
$worksheet->write($line,$column,get_lang('ExamFail'));
$column++;
$worksheet->write($line,$column,get_lang('TotalStudents'));
$column++;
$line++;
$column++;
$line++;
foreach ($array as $row) {
$column = 0;
foreach ($row as $item) {
foreach ($row as $item) {
$worksheet->write($line,$column,html_entity_decode(strip_tags($item)));
$column++;
}
$line++;
}
$line++;
}
$line++;
} else {
$worksheet->write($line,$column,get_lang('Exercises'));
$column++;
$worksheet->write($line,$column,get_lang('User'));
$column++;
$worksheet->write($line,$column,get_lang('Percentage'));
$column++;
$column++;
$worksheet->write($line,$column,get_lang('Status'));
$column++;
$worksheet->write($line,$column,get_lang('Attempts'));
$column++;
$line++;
foreach ($array as $row) {
$column++;
$line++;
foreach ($array as $row) {
$column = 0;
$worksheet->write($line,$column,html_entity_decode(strip_tags($row['exercise'])));
$column++;
foreach ($row['users'] as $key=>$user) {
$column = 1;
$column = 1;
$worksheet->write($line,$column,html_entity_decode(strip_tags($user)));
$column++;
$column++;
foreach ($row['results'][$key] as $result_item) {
$worksheet->write($line,$column,html_entity_decode(strip_tags($result_item)));
$column++;
$column++;
}
$line++;
}
}
$line++;
$line++;
}
}
$line++;
}
$workbook->close();
exit;

Loading…
Cancel
Save