exe_weighting is not dynamic see #1932 + some other minor fixes in exercises

skala
Julio Montoya 15 years ago
parent e2a6e3cb11
commit bfbffc99bc
  1. 18
      main/exercice/admin.php
  2. 2
      main/exercice/exercice.php
  3. 17
      main/exercice/exercice_submit.php
  4. 21
      main/exercice/exercise.class.php
  5. 39
      main/exercice/exercise_admin.php
  6. 8
      main/exercice/exercise_history.php
  7. 4
      main/exercice/exercise_show.php
  8. 57
      main/inc/lib/exercise_show_functions.lib.php

@ -459,28 +459,14 @@ if ($newQuestion || $editQuestion) {
$type = $_REQUEST['answerType'];
?><input type="hidden" name="Type" value="<?php echo $type; ?>" />
<?php
require 'question_admin.inc.php';
}
if(isset($_GET['hotspotadmin'])) {
if (isset($_GET['hotspotadmin'])) {
require 'hotspot_admin.inc.php';
}
if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) {
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
$form = new FormValidator('exercise_admin', 'post', api_get_self().'?exerciseId='.$_GET['exerciseId']);
$form -> addElement ('hidden','edit','true');
//$objExercise -> createForm ($form,'simple');
if($form -> validate()) {
$objExercise -> processCreation($form,'simple');
if($form -> getSubmitValue('edit') == 'true')
Display::display_confirmation_message(get_lang('ExerciseEdited'));
}
if(api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {
Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
}
$form -> display ();
echo '<br />';
// question list management
require 'question_list_admin.inc.php';
}

@ -155,7 +155,7 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
$from = $_SESSION['_user']['mail'];
$from_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
$url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&show=result';
$total_weighting = $_REQUEST['totalWeighting'];
//$total_weighting = $_REQUEST['totalWeighting'];
$my_post_info = array();
$post_content_id = array();

@ -64,9 +64,8 @@ $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
// General parameters passed via POST/GET
if (empty ($origin)) {
$origin = $_REQUEST['origin'];
$origin = Security::remove_XSS($_REQUEST['origin']);
}
if (empty ($learnpath_id)) {
$learnpath_id = intval($_REQUEST['learnpath_id']);
}
@ -156,6 +155,7 @@ $current_timestamp = time();
//Getting track exercise info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
if ($debug) {error_log('$objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
/*
@ -543,6 +543,7 @@ if ($time_control) {
if ($origin != 'learnpath') {
echo '<div id="highlight-plugin" class="glossary-content">';
}
if (!empty ($error)) {
Display :: display_error_message($error, false);
} else {
@ -558,7 +559,7 @@ if (!empty ($error)) {
if (!strcmp($questionList[0], '') === 0) {
foreach ($questionList as $questionId) {
$i++;
$objQuestionTmp = Question :: read($questionId);
$objQuestionTmp = Question::read($questionId);
// for sequential exercises
if ($exerciseType == ONE_PER_PAGE) {
// if it is not the right question, goes to the next loop iteration
@ -602,6 +603,7 @@ if (!empty ($error)) {
//Show list of questions
$i = 1;
foreach ($questionList as $questionId) {
// for sequential exercises
if ($exerciseType == ONE_PER_PAGE) {
// if it is not the right question, goes to the next loop iteration
@ -613,7 +615,7 @@ if (!empty ($error)) {
// if the user has already answered this question
if (isset ($exerciseResult[$questionId])) {
// construction of the Question object
$objQuestionTmp = Question :: read($questionId);
$objQuestionTmp = Question::read($questionId);
$questionName = $objQuestionTmp->selectTitle();
// destruction of the Question object
unset ($objQuestionTmp);
@ -642,7 +644,12 @@ if (!empty ($error)) {
}
if ($objExercise->type == ONE_PER_PAGE) {
if (empty($exercise_stat_info)) {
$objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList);
$total_weight = 0;
foreach($questionList as $question_id) {
$objQuestionTmp = Question::read($questionId);
$total_weight += floatval($objQuestionTmp->weighting);
}
$objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList, $total_weight);
}
}
if ($origin != 'learnpath') {

@ -1444,8 +1444,17 @@ class Exercise {
return $new_array;
}
public function save_stat_track_exercise_info($clock_expired_time = 0, $safe_lp_id = 0, $safe_lp_item_id = 0, $safe_lp_item_view_id = 0, $questionList = array()) {
/**
* Saves a test attempt
*
* @param int clock_expired_time
* @param int lp id
* @param int lp item id
* @param int lp item_view id
* @param array question list
*/
public function save_stat_track_exercise_info($clock_expired_time = 0, $safe_lp_id = 0, $safe_lp_item_id = 0, $safe_lp_item_view_id = 0, $questionList = array(), $weight) {
$track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
if (empty($safe_lp_id)) {
$safe_lp_id = 0;
@ -1464,11 +1473,11 @@ class Exercise {
$sql_fields_values = "";
}
if ($this->type == ONE_PER_PAGE) {
$sql = "INSERT INTO $track_exercises($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date,orig_lp_id,orig_lp_item_id)
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "','" . api_get_utc_datetime() . "',$safe_lp_id,$safe_lp_item_id)";
$sql = "INSERT INTO $track_exercises ($sql_fields exe_exo_id, exe_user_id, exe_cours_id, status,session_id, data_tracking, start_date, orig_lp_id, orig_lp_item_id, exe_weighting)
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "', '" . api_get_utc_datetime() . "', '$safe_lp_id', '$safe_lp_item_id', '$weight' )";
} else {
$sql = "INSERT INTO $track_exercises ($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date,orig_lp_id,orig_lp_item_id)
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . api_get_utc_datetime() . "',$safe_lp_id,$safe_lp_item_id)";
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . api_get_utc_datetime() . "', '$safe_lp_id', '$safe_lp_item_id' , '$weight' )";
}
Database::query($sql);
}
@ -2918,7 +2927,7 @@ class Exercise {
if ($saved_results) {
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . floatval($totalScore) . ',exe_weighting = exe_weighting + ' . floatval($totalWeighting) . ' WHERE exe_id = ' . $exeId;
$sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . floatval($totalScore) . ' WHERE exe_id = ' . $exeId;
Database::query($sql_update);
}

@ -23,40 +23,31 @@ if(!api_is_allowed_to_edit(null,true)) {
api_not_allowed(true);
}
$htmlHeadXtra[] = '<script>
function advanced_parameters()
{
if(document.getElementById(\'options\').style.display == \'none\')
{
$htmlHeadXtra[] = '<script type="text/javascript">
function advanced_parameters() {
if(document.getElementById(\'options\').style.display == \'none\') {
document.getElementById(\'options\').style.display = \'block\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
} else {
document.getElementById(\'options\').style.display = \'none\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
}
}
function FCKeditor_OnComplete( editorInstance )
{
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name ))
{
function FCKeditor_OnComplete( editorInstance ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name )) {
HideFCKEditorByInstanceName (editorInstance.Name);
}
}
function HideFCKEditorByInstanceName ( editorInstanceName )
{
function HideFCKEditorByInstanceName ( editorInstanceName ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" )
{
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
}
}
function show_media()
{
function show_media() {
var my_display = document.getElementById(\'HiddenFCKexerciseDescription\').style.display;
if(my_display== \'none\' || my_display == \'\')
{
@ -68,8 +59,7 @@ $htmlHeadXtra[] = '<script>
}
}
function timelimit()
{
function timelimit() {
if(document.getElementById(\'options2\').style.display == \'none\')
{
document.getElementById(\'options2\').style.display = \'block\';
@ -78,22 +68,18 @@ $htmlHeadXtra[] = '<script>
}
}
function feedbackselection()
{
function feedbackselection() {
var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
if (index == \'1\')
{
if (index == \'1\') {
document.exercise_admin.exerciseType[1].checked=true;
document.exercise_admin.exerciseType[0].disabled=true;
} else {
document.exercise_admin.exerciseType[0].disabled=false;
}
}
function option_time_expired()
{
function option_time_expired() {
if(document.getElementById(\'timercontrol\').style.display == \'none\')
{
document.getElementById(\'timercontrol\').style.display = \'block\';
@ -166,12 +152,13 @@ $objExercise->createForm($form);
// VALIDATE FORM
if ($form->validate()) {
$objExercise->processCreation($form);
$objExercise->processCreation($form);
if ($form->getSubmitValue('edit') == 'true') {
$message = 'ExerciseEdited';
} else {
$message = 'ExerciseAdded';
}
api_session_unregister('objExercise');
header('Location:admin.php?message='.$message.'&exerciseId='.$objExercise->id);
exit;
} else {

@ -51,12 +51,12 @@ Display::display_header($nameTools,get_lang('Exercise'));
}
}
//event_access_tool(TOOL_QUIZ);
echo '<div class="actions">';
echo '<a href="exercice.php?' . api_get_cidreq() . '&show=result&filter=2">' . Display :: return_icon('back.png', get_lang('BackToResultList'),'','32').'</a>';
echo '</div>';
?>
<div class="actions">
<a href="exercice.php?cidReq=<?php echo Security::remove_XSS($_GET['cidReq']) ?>&show=result&filter=2"><img src="../img/back.png"/><?php echo get_lang('BackToResultList') ?></a>
</div>
<table class="data_table">
<tr class="row_odd">
<th><?php echo get_lang('Question'); ?></th>

@ -653,14 +653,14 @@ if (is_array($arrid) && is_array($arrmarks)) {
if ($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
//echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">';
echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">';
echo '<input type = "hidden" name="student_id" value="'.$student_id.'">';
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
} else {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&action=qualify&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&totalWeighting='.$totalWeighting.'" method="post">';
echo ' <form name="myform" id="myform" action="exercice.php?show=result&action=qualify&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'" method="post">';
}
if ($origin!='learnpath' && $origin!='student_progress') {
?>

@ -55,39 +55,32 @@ class ExerciseShowFunctions {
* @return void
*/
function display_free_answer($answer,$id,$questionId) {
global $feedback_type;
global $feedback_type;
if (empty($id)) {
?>
<tr>
<td width="55%">
<?php echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)); ?>
</td>
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="45%">
<?php echo get_lang('notCorrectedYet');?>
</td>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
} else {
?>
<tr>
<td>
<?php if (!empty($answer)) {echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY));} ?>
</td>
<?php if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {?>
<td>
<?php
$comm = get_comments($id,$questionId);
?>
</td>
<?php }?>
</tr>
<?php
echo '<tr>';
echo Display::tag('td',nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY)), array('width'=>'55%'));
echo '</tr>';
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<tr>';
echo Display::tag('td',get_lang('notCorrectedYet'), array('width'=>'45%'));
echo '</tr>';
} else {
echo '<tr><td>&nbsp;</td></tr>';
}
} else {
echo '<tr>';
echo '<td>';
if (!empty($answer)) {
echo nl2br(Security::remove_XSS($answer,COURSEMANAGERLOWSECURITY));
}
echo '</td>';
if(!api_is_allowed_to_edit(null,true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = get_comments($id,$questionId);
echo '</td>';
}
echo '</tr>';
}
}

Loading…
Cancel
Save