Source for file mark_free_answer.php
Documentation is available at mark_free_answer.php
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See "documentation/licence.html" more details.
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
* Free answer marking script
* This script allows a course tutor to mark a student's free answer.
* @package dokeos.exercise
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
* @todo respect coding guidelines
==============================================================================
==============================================================================
// name of the language file that needs to be included
$language_file= 'exercice';
// name of the language file that needs to be included
include('../inc/global.inc.php');
// including additional libraries
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include_once(api_get_library_path(). '/text.lib.php');
/** @todo use the Database:: functions */
//debug param. 0: no display - 1: debug display
if($debug> 0){echo str_repeat(' ',0). 'Entered exercise_result.php'. "<br />\n";var_dump($_POST);}
// general parameters passed via POST/GET
if(!empty($_REQUEST['exe'])){
$my_exe = $_REQUEST['exe'];
if(!empty($_REQUEST['qst'])){
$my_qst = $_REQUEST['qst'];
if(!empty($_REQUEST['usr'])){
$my_usr = $_REQUEST['usr'];
if(!empty($_REQUEST['cidReq'])){
$my_cid = $_REQUEST['cidReq'];
if(!empty($_POST['action'])){
$action = $_POST['action'];
if (empty($my_qst) or empty($my_usr) or empty($my_cid) or empty($my_exe)){
header('Location: exercice.php');
$interbreadcrumb[]= array("url" => "exercice.php","name" => get_lang('Exercices'));
if (!empty($_POST['score']) AND $_POST['score'] < $obj_question->selectWeighting() AND $_POST['score'] >= 0){
//mark the user mark into the database using something similar to the following function:
if($_configuration['tracking_enabled'])
#$tbl_learnpath_user = Database::get_course_table('learnpath_user');
#global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id;
$sql = "SELECT * FROM $exercise_table
WHERE exe_user_id = '$my_usr' AND exe_cours_id = '$my_cid' AND exe_exo_id = '$my_exe'
//@todo Check that just summing past score and the new free answer mark doesn't come up
// with a score higher than the possible score for that exercise
$my_score = $row['exe_result'] + $_POST['score'];
$sql = "UPDATE $exercise_table SET exe_result = '$my_score'
WHERE exe_id = '". $row['exe_id']. "'";
$my_score = $_POST['score'];
$sql = "INSERT INTO $exercise_table
'". $obj_question->selectWeighting(). "',
FROM_UNIXTIME(". $reallyNow. ")
#if ($origin == 'learnpath')
# if ($user_id == "NULL")
# $sql2 = "update `$tbl_learnpath_user` set score='$score' where (user_id=$user_id and learnpath_id='$learnpath_id' and learnpath_item_id='$learnpath_item_id')";
# $res2 = api_sql_query($sql2,__FILE__,__LINE__);
$my_msg .= " There might have been a problem with the total score being too big...<br />\n";
// Display simple marking interface
// 1a - result of previous marking then exit suggestion
// 1b - user answer and marking box + submit button
$objAnswerTmp->selectAnswer($answerId);
<a href="exercice.php?cidReq='. $cidReq. '">'. get_lang('Back'). '</a>';
echo '<h2>'. $obj_question->question . ':</h2>
'. $obj_question->selectTitle(). '<br /><br />
"<form action='' method='POST'>\n"
. "<input type='hidden' name='exe' value='$my_exe'>\n"
. "<input type='hidden' name='usr' value='$my_usr'>\n"
. "<input type='hidden' name='cidReq' value='$my_cid'>\n"
. "<input type='hidden' name='action' value='mark'>\n"
. "<select name='score'>\n";
for($i= 0 ; $i< $obj_question->selectWeighting() ; $i++ ){
echo '<option>'. $i. '</option>';
"<input type='submit' name='submit' value='". get_lang('Ok'). "'>\n"
|