Should fix most of the problems due negative values (using propagate quiz setting), should fix also some bugs with feedback.

skala
Julio Montoya 14 years ago
parent 743cc53d15
commit f3d0712bff
  1. 30
      main/css/base.css
  2. 3897
      main/exercice/exercise.class.php
  3. 36
      main/exercice/exercise.lib.php
  4. 6
      main/exercice/exercise_result.php
  5. 28
      main/exercice/exercise_show.php
  6. 21
      main/exercice/exercise_submit.php
  7. 14
      main/inc/lib/events.lib.inc.php
  8. 2
      main/inc/lib/exercise_show_functions.lib.php
  9. 57
      main/newscorm/lp_view.php
  10. 6
      tests/main/inc/lib/events.lib.inc.test.php

@ -2277,4 +2277,34 @@ div.admin_section h4 {
.document_preview_container {
font-size: 12px !important;
color: #111 ! important;
}
/* Exercise comment*/
#comments {
position:absolute;
left:795px;
top:0px;
width:200px;
height:75px;
z-index:1;
}
#questions {
width:40%;
height:50px;
float:left;
padding:5px;
}
.question_item {
height:50px;
padding:5px;
margin:10px 0px 10px 0px;
}
.option_item {
width:150px;
padding:3px;
margin:10px;
}

File diff suppressed because it is too large Load Diff

@ -146,31 +146,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
?>
<style>
#questions {
width:40%;
height:50px;
float:left;
padding:5px;
}
#options {
width:40%;
float:left;
padding:5px;
}
.question_item {
height:50px;
padding:5px;
margin:10px 0px 10px 0px;
}
.option_item {
width:150px;
padding:3px;
margin:10px;
}
</style>
<script>
$(function() {
@ -239,8 +215,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// splits text and weightings that are joined with the character '::'
list($answer) = explode('::',$answer);
// because [] is parsed here we follow this procedure:
$answer = text_filter($answer);
//getting the matches
$answer = api_ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10" />',($answer));
}
@ -300,6 +274,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$s .='<tr>';
$s .= Display::tag('td', $answer);
if (!empty($quiz_question_options)) {
@ -334,6 +309,8 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// multiple answers
// set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x'
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$help = $selected = '';
if ($debug_mark_answer) {
if ($answerCorrect) {
@ -960,9 +937,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id());
$teacher_id_list = array();
foreach ($teacher_list as $teacher) {
$teacher_id_list[] =$teacher['user_id'];
}
$teacher_id_list[] = $teacher['user_id'];
}
if (empty($hotpotatoe_where)) {
$column = intval($column);

@ -108,7 +108,7 @@ if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
}
$nameTools=get_lang('Exercice');
$nameTools = get_lang('Exercice');
$interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
//$htmlHeadXtra[] = $objExercise->show_lp_javascript();
@ -155,7 +155,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '</div>';
}
$exerciseTitle=text_filter($objExercise->selectTitle());
$exerciseTitle = $objExercise->selectTitle();
$feedback_type = $objExercise->feedbacktype;
//show exercise title
@ -275,7 +275,7 @@ if ($show_results || $show_only_score) {
$quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
if (api_is_allowed_to_session_edit() ) {
update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting, api_get_session_id(), $safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration);
update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting, api_get_session_id(), $safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration, $questionList);
}
if ($origin != 'learnpath') {

@ -74,6 +74,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
//Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = get_exercise_track_exercise_info($id);
//No track info
if (empty($track_exercise_info)) {
api_not_allowed();
@ -125,8 +126,6 @@ if($origin=='user_course') {
$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".$student_id."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
} else if($origin=='tracking_course') {
//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($student_id).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$student_id.'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
@ -153,20 +152,7 @@ if ($origin != 'learnpath') {
} else {
Display::display_reduced_header();
}
?>
<style type="text/css">
<!--
#comments {
position:absolute;
left:795px;
top:0px;
width:200px;
height:75px;
z-index:1;
}
-->
</style>
<script language="javascript">
function showfck(sid,marksid) {
document.getElementById(sid).style.display='block';
@ -270,7 +256,7 @@ $query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as at
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result =Database::query($query);
$result = Database::query($query);
$questionList = array();
$exerciseResult = array();
@ -282,7 +268,7 @@ while ($row = Database::fetch_array($result)) {
//Fixing #2073 Fixing order of questions
if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
$tempquestionList = explode(',',$track_exercise_info['data_tracking']);
if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
$questionList = $tempquestionList;
}
}
@ -314,12 +300,12 @@ foreach ($questionList as $questionId) {
echo $objQuestionTmp->return_header($feedback_type);
}
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice = array();
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
@ -609,7 +595,7 @@ foreach ($questionList as $questionId) {
unset($objAnswerTmp);
$i++;
$totalWeighting+=$questionWeighting;
$totalWeighting += $questionWeighting;
} // end of large foreach on questions

@ -91,11 +91,11 @@ if (empty ($exerciseType)) {
if (empty ($exerciseId)) {
$exerciseId = intval($_REQUEST['exerciseId']);
}
if (empty ($choice)) {
$choice = $_REQUEST['choice'];
if (empty($choice)) {
$choice = $_REQUEST['choice'];
}
if (empty ($_REQUEST['choice'])) {
$choice = $_REQUEST['choice2'];
if (empty($_REQUEST['choice'])) {
$choice = $_REQUEST['choice2'];
}
if (empty ($questionNum)) {
$questionNum = intval($_REQUEST['questionNum']);
@ -119,7 +119,6 @@ $safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
/*
* Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes
in the exercise
@ -302,8 +301,9 @@ if ($formSent && isset($_POST)) {
$hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
$choice = array($hotspot_id => '');
}
// if the user has answered at least one question
// if the user has answered at least one question
if (is_array($choice)) {
if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); }
// Also store hotspot spots in the session ($exerciseResultCoordinates
// will be stored in the session at the end of this script)
@ -333,8 +333,8 @@ if ($formSent && isset($_POST)) {
$choice = $exerciseResult[$questionId];
if (isset($exe_id)) {
//Manage the question and answer attempts
if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false);
if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false, $objExercise->propagate_neg);
}
//END of saving and qualifying
}
@ -475,14 +475,13 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '<a href="exercice.php?show=test&id_session='.api_get_session_id().'">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'','32').'</a>';
if ($show_quiz_edition) {
echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'','32').'</a>';
//echo Display :: return_icon('wizard.gif', get_lang('QuestionList')) . '<a href="exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '">' . get_lang('QuestionList') . '</a>';
} else {
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>';
}
echo '</div>';
}
$exerciseTitle = text_filter($objExercise->selectTitle());
$exerciseTitle = $objExercise->selectTitle();
echo Display::tag('h2', $exerciseTitle);
$show_clock = true;
$user_id = api_get_user_id();
@ -518,8 +517,6 @@ if ($objExercise->selectAttempts() > 0) {
$score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
} else {
Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
}

@ -305,7 +305,7 @@ function event_link($link_id) {
* @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @desc Record result of user when an exercice was done
*/
function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration) {
function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration , $question_list) {
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
if ($exeid!='') {
// Validation in case of fraud with actived control time
@ -323,6 +323,7 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
}
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
array_map('intval', $question_list);
$sql = "UPDATE $TABLETRACK_EXERCICES SET
exe_exo_id = '".Database::escape_string($exo_id)."',
@ -335,18 +336,17 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
exe_duration = '".Database::escape_string($duration)."',
exe_date = '".api_get_utc_datetime()."',
status = '',
start_date = '".api_get_utc_datetime($start_date)."'
start_date = '".api_get_utc_datetime($start_date)."',
data_tracking = '".implode(',', $question_list)."'
WHERE exe_id = '".Database::escape_string($exeid)."'";
$res = @Database::query($sql);
//Deleting control time session track
exercise_time_control_delete($exo_id);
//error_log('update_event_exercice');
//error_log($sql);
return $res;
} else
return $res;
} else {
return false;
}
}
/**

@ -228,7 +228,7 @@ class ExerciseShowFunctions {
<td width="5%" align="center">
<?php
$question = new MultipleAnswerTrueFalse();
$question = new MultipleAnswerTrueFalse();
$new_options = Question::readQuestionOption($questionId);
//Your choice
if (isset($new_options[$studentChoice])) {

@ -171,11 +171,15 @@ foreach($list as $toc) {
}
}
$debug = 0;
$autostart = 'true';
// Update status, total_time from lp_item_view table when you finish the exercises in learning path.
if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) {
global $src;
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
@ -185,19 +189,29 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$safe_exe_id = intval($_REQUEST['exeId']);
if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) {
$sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
$sql = 'SELECT start_date, exe_date, exe_result, exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = api_strtotime($row_dates['start_date'],'UTC');
$time_exe_date = api_strtotime($row_dates['exe_date'],'UTC');
$mytime = ((int)$time_exe_date-(int)$time_start_date);
$score = (float)$row_dates['exe_result'];
$max_score = (float)$row_dates['exe_weighting'];
$mytime = ((int)$time_exe_date-(int)$time_start_date);
$score = (float)$row_dates['exe_result'];
$max_score = (float)$row_dates['exe_weighting'];
/*require_once '../exercice/exercise.class.php';
require_once '../exercice/question.class.php';
require_once '../exercice/answer.class.php';
require_once '../exercice/exercise.lib.php';
$exercise_obj = new Exercise();
$score_result = $exercise_obj->get_exercise_result($safe_exe_id);
$score = (float)$score_result['score'];*/
$sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE id = '".(int)$safe_item_id."'";
if ($debug) error_log($sql_upd_max_score);
Database::query($sql_upd_max_score);
$sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1";
@ -206,10 +220,11 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$lp_item_view_id = $row_last_attempt[0];
if (Database::num_rows($res_last_attempt) > 0) {
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score,total_time = $mytime WHERE id='".$lp_item_view_id."'";
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime WHERE id='".$lp_item_view_id."'";
if ($debug) error_log($sql_upd_score);
Database::query($sql_upd_score);
$update_query = "UPDATE $TBL_TRACK_EXERCICES SET orig_lp_item_view_id = $lp_item_view_id WHERE exe_id = ".$safe_exe_id;
$update_query = "UPDATE $TBL_TRACK_EXERCICES SET orig_lp_item_view_id = $lp_item_view_id WHERE exe_id = ".$safe_exe_id;
Database::query($update_query);
}
}
@ -217,7 +232,8 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
if (intval($_GET['fb_type']) > 0) {
$src = 'blank.php?msg=exerciseFinished';
} else {
$src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.Security::remove_XSS($_REQUEST['exeId']).'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
$src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.$safe_exe_id.'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
if ($debug) error_log('Calling URL'.$src);
}
$autostart = 'false';
}
@ -235,18 +251,19 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
}
// Not in fullscreen mode.
require_once '../inc/reduced_header.inc.php';
//$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
// Check if audio recorder needs to be in studentview.
$course_id = $_SESSION['_course']['id'];
if ($_SESSION['status'][$course_id] == 5) {
$audio_recorder_studentview = true;
} else {
$audio_recorder_studentview = false;
}
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
$_SESSION['loaded_lp_view'] = true;
// Not in fullscreen mode.
require_once '../inc/reduced_header.inc.php';
//$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
// Check if audio recorder needs to be in studentview.
$course_id = $_SESSION['_course']['id'];
if ($_SESSION['status'][$course_id] == 5) {
$audio_recorder_studentview = true;
} else {
$audio_recorder_studentview = false;
}
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
$_SESSION['loaded_lp_view'] = true;
$display_none = '';
$margin_left = '290px';

@ -142,9 +142,9 @@ class TestEvents extends UnitTestCase {
$weighting='';
$session_id='';
$duration='';
$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration);
$question_list = array();
$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
$this->assertTrue(is_bool($res));
//var_dump($res);
}
}
?>
}
Loading…
Cancel
Save