version 1.19, 2005/12/01 22:34:10
|
version 1.25, 2024/04/29 03:06:39
|
Line 27
|
Line 27
|
|
|
#include <capaCommon.h> |
#include <capaCommon.h> |
#include <ranlib.h> |
#include <ranlib.h> |
|
#include <ctype.h> /* isdigit() */ |
|
|
PointsList_t * parse_pts_list (char *pts_list) { |
PointsList_t * parse_pts_list (char *pts_list) { |
PointsList_t *new=NULL, *end=NULL, *beforeend=NULL, *rlist=NULL; |
PointsList_t *new=NULL, *end=NULL, *beforeend=NULL, *rlist=NULL; |
Line 134 int caparesponse_capa_check_answer(char
|
Line 135 int caparesponse_capa_check_answer(char
|
int caparesponse_get_real_response (char* unit_str, char* answer, |
int caparesponse_get_real_response (char* unit_str, char* answer, |
double* scaled) { |
double* scaled) { |
//double caparesponse_get_real_response (char* unit_str, char* answer) { |
//double caparesponse_get_real_response (char* unit_str, char* answer) { |
int input_len,all_alphabet,idx,outcome,result; |
int input_len,all_alphabet,idx,outcome=-1; |
double n_part,scale=1.0,given,target; |
#pragma GCC diagnostic push |
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
|
int result; |
|
#pragma GCC diagnostic pop |
|
double n_part,scale=1.0,given; |
char input[ANSWER_STRING_LENG],filename[FILE_NAME_LENGTH], |
char input[ANSWER_STRING_LENG],filename[FILE_NAME_LENGTH], |
tmp_unit_str[ANSWER_STRING_LENG]; |
tmp_unit_str[ANSWER_STRING_LENG]; |
Unit_t *ans_unit; |
Unit_t *ans_unit; |
long seed1,seed2; |
|
FILE *fp; |
FILE *fp; |
sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units"); |
sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units"); |
if ((fp=fopen(filename,"r"))==NULL) { |
if ((fp=fopen(filename,"r"))==NULL) { |
Line 165 int caparesponse_get_real_response (char
|
Line 169 int caparesponse_get_real_response (char
|
if( !all_alphabet ) { |
if( !all_alphabet ) { |
tmp_unit_str[0] = 0; |
tmp_unit_str[0] = 0; |
outcome = split_num_unit(answer,&n_part,input,tmp_unit_str); |
outcome = split_num_unit(answer,&n_part,input,tmp_unit_str); |
|
} |
|
if( outcome > 0 ) { |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( ans_unit != NULL ) { |
if( ans_unit != NULL ) { |
result = check_correct_unit(tmp_unit_str,ans_unit,&scale); |
result = check_correct_unit(tmp_unit_str,ans_unit,&scale); |
Line 177 int caparesponse_get_real_response (char
|
Line 183 int caparesponse_get_real_response (char
|
result = NO_UNIT; |
result = NO_UNIT; |
} |
} |
} |
} |
|
#pragma GCC diagnostic push |
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" |
if( (result != NO_UNIT) && (!check_for_unit_fail(result)) && ( result != UNIT_NOTNEEDED) ) { |
if( (result != NO_UNIT) && (!check_for_unit_fail(result)) && ( result != UNIT_NOTNEEDED) ) { |
given = n_part * scale; |
given = n_part * scale; |
*scaled=given; |
*scaled=given; |
/* convert the given answer into proper scale for units */ |
/* convert the given answer into proper scale for units */ |
} /* end if unit check */ |
} /* end if unit check */ |
} else { /* user entered a |
} else { /* user entered alphabet, but no number */ |
lphabet, but no number */ |
|
result = WANTED_NUMERIC; |
result = WANTED_NUMERIC; |
} |
} |
|
#pragma GCC diagnostic pop |
return result; |
return result; |
} |
} |
|
|
/* Testing harnass |
/* Testing harness |
int main(void) { |
int main(void) { |
int result=0; |
int result=0; |
char *reterror=NULL; |
char *reterror=NULL; |