ERROR: subject id not valid');
end_session();
break;
}
$_SESSION['subject_id'] = $subject_id;
// check to see if the subject has completed the given experiment
// FIXME: does this account for when participants start additional sessions to complete a given experiment?
$sql_subject_complete_experiment = sprintf("SELECT end_datetime FROM session WHERE subject_id=%s AND experiment_id=%s",
GetSQLValueString($_SESSION['subject_id'],"text"),
GetSQLValueString($_SESSION['experiment_id'],"int"));
$result_subject_compexp = mysql_query($sql_subject_complete_experiment,$subject) or report_error_form(mysql_error());
$num_subject_compexp = mysql_num_rows($result_subject_compexp);
if($num_subject_compexp > 0) {
$good = true;
// subject has already started this experiment, BREAK
for ($iii = 1; $iii <= $num_subject_compexp; $iii++) {
$row_result_subject_compexp = mysql_fetch_assoc($result_subject_compexp);
if (strlen(chop($row_result_subject_compexp['end_datetime'])) > 0) {
$good = false;
break;
}
}
if ($good) {
printf('finding old session
');
find_old_session($_SESSION['subject_id']);
} else {
printf('You have already completed this experiment. Thank you for your participation.
');
break;
}
} else {
// update session record for this session
$sql_update_session = sprintf("update session set subject_id = %s, php_session_id=%s where session_id = %s ",
GetSQLValueString($_SESSION['subject_id'],"text"),
GetSQLValueString($_COOKIE[$QPI_SESSION_NAME],"text"),
GetSQLValueString($_SESSION['session_id'],"int"));
mysql_update($sql_update_session);
$sql_update_responses = sprintf("update %s set subject_id = %s where session_id = %s ",
$_SESSION['response_table'],
GetSQLValueString($_SESSION['subject_id'],"text"),
GetSQLValueString($_SESSION['session_id'],"int"));
mysql_update($sql_update_responses);
}
expire_user_ticket($_SESSION['ticket_id']);
include ($questionnaire_dir.'form_processing/update_session.php');
} //end if a valid sid has been submitted
?>
Ensemble Experiment System
print LANGUAGE_TEXT_ENTER_SUB_ID_NUM;
?>