[LON-CAPA-dev] extracting answer for a problem

Guy Albertelli II lon-capa-dev@mail.lon-capa.org
Tue, 18 Feb 2003 11:15:55 -0500 (EST)


Hi Hon-Kie,

> Is there a function that allows me to extract just the answer plus tol etc 
> for a problem? If so how is it called?

If you want a funtion that gets the answers in a web displayable format:
&Apache::loncommon::get_student_answers($symb,$username,$domain,$courseid);
will do that (and it supports all currently used types).

If you want a datastructure version that you can use to do something
with, you can use the analyze target to get it:

my $subresult=&Apache::lonnet::ssi($request->uri,
				   ('grade_target' => 'analyze'),
				   ('grade_domain' => $domain),
				   ('grade_user' => $user),
				   ('grade_symb' => $symb),
				   ('grade_courseid' => $courseid));
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
my %analyze=&Apache::lonnet::str2hash($subresult);


And %analyze is a hash containg the structure of the problem.

This currently only works for some problem types
option/numericalresponse are known to work
string/formularesponse might work
rank/match/radio/essay/externalresponse won't work

If you need the second version to work more let me know and I can get
it working for a greater variety.

-- 
guy@albertelli.com  LON-CAPA Developer  0-7-7-4-