version 1.2, 2004/07/06 15:56:42
|
version 1.3, 2005/03/01 22:04:55
|
Line 96 sub BuildSurveyReportsPage {
|
Line 96 sub BuildSurveyReportsPage {
|
my $current_problem = &Apache::lonstathelpers::get_target_from_id |
my $current_problem = &Apache::lonstathelpers::get_target_from_id |
($ENV{'form.problemchoice'}); |
($ENV{'form.problemchoice'}); |
# |
# |
my ($prev,$curr,$next) = |
my ($navmap,$prev,$curr,$next) = |
&Apache::lonstathelpers::get_prev_curr_next($current_problem, |
&Apache::lonstathelpers::get_prev_curr_next($current_problem, |
'.', |
'.', |
'part_survey', |
'part_survey', |
Line 119 sub BuildSurveyReportsPage {
|
Line 119 sub BuildSurveyReportsPage {
|
$r->print('resource is undefined'); |
$r->print('resource is undefined'); |
} else { |
} else { |
my $resource = $current_problem->{'resource'}; |
my $resource = $current_problem->{'resource'}; |
$r->print('<h1>'.$resource->{'title'}.'</h1>'); |
$r->print('<h1>'.$resource->compTitle.'</h1>'); |
$r->print('<h3>'.$resource->{'src'}.'</h3>'); |
$r->print('<h3>'.$resource->src.'</h3>'); |
$r->print(&Apache::lonstathelpers::render_resource($resource)); |
$r->print(&Apache::lonstathelpers::render_resource($resource)); |
$r->rflush(); |
$r->rflush(); |
my %Data = &Apache::lonstathelpers::get_problem_data |
my %Data = &Apache::lonstathelpers::get_problem_data |
($resource->{'src'}); |
($resource->src); |
&make_HTML_report($r,$current_problem,\%Data,\@Students); |
&make_HTML_report($r,$current_problem,\%Data,\@Students); |
} |
} |
$r->print('<hr />'); |
$r->print('<hr />'); |
Line 147 sub BuildSurveyReportsPage {
|
Line 147 sub BuildSurveyReportsPage {
|
sub SurveyProblemSelector { |
sub SurveyProblemSelector { |
my $Str = ''; |
my $Str = ''; |
my @SurveyProblems; |
my @SurveyProblems; |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess('all')) { |
my ($navmap,@sequences) = |
next if ($seq->{'num_assess'}<1); |
&Apache::lonstatistics::selected_sequences_with_assessments('all'); |
foreach my $res (@{$seq->{'contents'}}) { |
foreach my $seq (@sequences) { |
next if ($res->{'type'} ne 'assessment'); |
my @resources = &Apache::lonstathelpers::get_resources($navmap,$seq); |
foreach my $part (@{$res->{'parts'}}) { |
foreach my $res (@resources) { |
if ($res->{'partdata'}->{$part}->{'Survey'}) { |
foreach my $part (@{$res->parts}) { |
|
if ($res->is_survey($part)) { |
push(@SurveyProblems,{res=>$res,seq=>$seq,part=>$part}); |
push(@SurveyProblems,{res=>$res,seq=>$seq,part=>$part}); |
last; |
last; |
} |
} |
Line 167 sub SurveyProblemSelector {
|
Line 168 sub SurveyProblemSelector {
|
} |
} |
$Str .= '<table>'.$/; |
$Str .= '<table>'.$/; |
$Str .= '<tr>'.'<td></td>'. |
$Str .= '<tr>'.'<td></td>'. |
'<th>'.&mt('Sequence').'</th>'. |
'<th>'.&mt('Survey').'</th>'. |
'<th>'.&mt('Problem').'</th>'. |
|
'</tr>'.$/; |
'</tr>'.$/; |
|
my $id; |
foreach my $problem (@SurveyProblems) { |
foreach my $problem (@SurveyProblems) { |
|
$id++; |
my $value = &Apache::lonstathelpers::make_target_id |
my $value = &Apache::lonstathelpers::make_target_id |
({symb=>$problem->{'res'}->{'symb'}, |
({symb=>$problem->{'res'}->symb, |
part=>$problem->{'part'}, |
part=>$problem->{'part'}, |
respid=>undef, |
respid=>undef, |
resptype=>undef}); |
resptype=>undef}); |
Line 180 sub SurveyProblemSelector {
|
Line 182 sub SurveyProblemSelector {
|
if ($ENV{'form.problemchoice'} eq $value) { |
if ($ENV{'form.problemchoice'} eq $value) { |
$checked = 'checked '; |
$checked = 'checked '; |
} |
} |
$Str .= '<tr>'.'<td>'. |
my $link = $problem->{'res'}->src. |
'<input type="radio" name="problemchoice" '. |
'?symb='.&Apache::lonnet::escape($problem->{'res'}->symb); |
|
$Str .= '<tr><td>'. |
|
'<input type="radio" name="problemchoice" id="'.$id.'" '. |
'value="'.$value.'" '.$checked.'/>'.'</td>'. |
'value="'.$value.'" '.$checked.'/>'.'</td>'. |
'<td>'.$problem->{'seq'}->{'title'}.'</td>'. |
'<td><nobr>'. |
'<td>'.$problem->{'res'}->{'title'}.'</td>'. |
'<label for="'.$id.'">'.$problem->{'res'}->compTitle.'('.$problem->{'seq'}->compTitle.')'.'</lablel>'. |
'</tr>'.$/; |
(' 'x2). |
|
qq{<a target="preview" href="$link">view</a>}.'</td></tr>'.$/; |
} |
} |
$Str .= '</table>'; |
$Str .= '</table>'; |
return $Str; |
return $Str; |
Line 202 sub Compile_Student_Answers {
|
Line 207 sub Compile_Student_Answers {
|
my ($problem,$ProblemData,$Students) = @_; |
my ($problem,$ProblemData,$Students) = @_; |
my $resource = $problem->{'resource'}; |
my $resource = $problem->{'resource'}; |
foreach my $student (@$Students) { |
foreach my $student (@$Students) { |
foreach my $partid (@{$resource->{'parts'}}) { |
foreach my $partid (@{$resource->parts}) { |
my $partdata = $resource->{'partdata'}->{$partid}; |
my @response_ids = $resource->responseIds($partid); |
for (my $i=0;$i<=@{$partdata->{'ResponseIds'}};$i++) { |
my @response_types = $resource->responseType($partid); |
my $respid = $partdata->{'ResponseIds'}->[$i]; |
for (my $i=0;$i<=$#response_ids;$i++) { |
my $resptype = $partdata->{'ResponseTypes'}->[$i]; |
my $respid = $response_ids[$i]; |
|
my $resptype = $response_types[$i]; |
my $results = |
my $results = |
&Apache::loncoursedata::get_response_data_by_student |
&Apache::loncoursedata::get_response_data_by_student |
($student,$resource->{'symb'},$respid); |
($student,$resource->symb,$respid); |
next if (! defined($results) || ref($results) ne 'ARRAY' || |
next if (! defined($results) || ref($results) ne 'ARRAY' || |
ref($results->[0]) ne 'ARRAY'); |
ref($results->[0]) ne 'ARRAY'); |
my $student_response = |
my $student_response = |
$results->[0]->[&Apache::loncoursedata::RDs_submission()]; |
$results->[0]->[&Apache::loncoursedata::RDs_submission()]; |
$problem->{'responsedata'}->{$partid}->{$respid}->{'_count'}++; |
$problem->{'responsedata'}->{$partid}->{$respid}->{'_count'}++; |
my $data = $problem->{'responsedata'}->{$partid}->{$respid}; |
my $data = $problem->{'responsedata'}->{$partid}->{$respid}; |
if ($resptype =~ /^(radiobutton|optionresponse)$/) { |
if ($resptype =~ /^(option|match)$/) { |
# Restricted response type can be categorized. |
my @responses = split('&',$student_response); |
# |
foreach my $response (@responses) { |
# Assume responses were not randomized and the order |
my ($foilid,$option) = |
# represents their value. This is probably a dumb thing |
map { |
# to do... |
&Apache::lonnet::unescape($_); |
# |
} split('=',$response); |
my ($foil,$value) = split('=',$student_response); |
$data->{'foil_count'}->{$foilid}++; |
|
$data->{'foil_responses'}->{$foilid}->{$option}++; |
|
} |
|
} elsif ($resptype =~ /^(radiobutton)$/) { |
|
my ($foil,$value) = map { &Apache::lonnet::unescape($_); } split('=',$student_response); |
$value += 1; # explicitly increment it... |
$value += 1; # explicitly increment it... |
$data->{'foil_responses'}->{$foil}++; |
$data->{'foil_responses'}->{$foil}++; |
$data->{'foil_values'}->{$value}++; |
$data->{'foil_values'}->{$value}++; |
Line 252 sub make_HTML_report {
|
Line 262 sub make_HTML_report {
|
&Compile_Student_Answers($problem,$ProblemData,$Students); |
&Compile_Student_Answers($problem,$ProblemData,$Students); |
# &output_hash('',$ProblemData); |
# &output_hash('',$ProblemData); |
my $resource = $problem->{'resource'}; |
my $resource = $problem->{'resource'}; |
foreach my $partid (@{$resource->{'parts'}}) { |
foreach my $partid (@{$resource->parts}) { |
my $partdata = $resource->{'partdata'}->{$partid}; |
my @response_ids = $resource->responseIds($partid); |
for (my $i=0;$i<=@{$partdata->{'ResponseIds'}};$i++) { |
my @response_types = $resource->responseType($partid); |
|
for (my $i=0;$i<=$#response_ids;$i++) { |
my $Str = '<table>'.$/; |
my $Str = '<table>'.$/; |
my $respid = $partdata->{'ResponseIds'}->[$i]; |
my $respid = $response_ids[$i]; |
my $resptype = $partdata->{'ResponseTypes'}->[$i]; |
my $resptype = $response_types[$i]; |
my $data = $problem->{'responsedata'}->{$partid}->{$respid}; |
my $data = $problem->{'responsedata'}->{$partid}->{$respid}; |
next if (! defined($data) || ref($data) ne 'HASH'); |
if (! defined($data) || ref($data) ne 'HASH') { |
|
next; |
|
} |
# Debugging code |
# Debugging code |
# $Str .= '<tr>'. |
# $Str .= '<tr>'. |
# '<td>'.$partid.'</td>'. |
# '<td>'.$partid.'</td>'. |
Line 270 sub make_HTML_report {
|
Line 283 sub make_HTML_report {
|
'<td><b>'.&mt('Total').'</b></td>'. |
'<td><b>'.&mt('Total').'</b></td>'. |
'<td>'.$data->{'_count'}.'</td>'. |
'<td>'.$data->{'_count'}.'</td>'. |
'<td>'.&mt('Part [_1], Response [_2]',$partid,$respid).'</td>'. |
'<td>'.&mt('Part [_1], Response [_2]',$partid,$respid).'</td>'. |
'</tr>'.$/; |
'</tr>'; |
if (exists($data->{'responses'}) && |
if (exists($data->{'responses'}) && |
ref($data->{'responses'}) eq 'ARRAY') { |
ref($data->{'responses'}) eq 'ARRAY') { |
&randomize_array($data->{'responses'}); |
&randomize_array($data->{'responses'}); |
Line 284 sub make_HTML_report {
|
Line 297 sub make_HTML_report {
|
'</pre><hr /></td>'. |
'</pre><hr /></td>'. |
'</tr>'.$/; |
'</tr>'.$/; |
} |
} |
|
} elsif (exists($data->{'foil_count'}) && |
|
exists($data->{'foil_responses'})) { |
|
$Str.='<tr><td colspan="3">'. |
|
'<table><tr>'; |
|
my $tmp = '<th>'.join('</th><th>', |
|
(&mt('Foil Name'), |
|
&mt('Foil Text'), |
|
&mt('Option'), |
|
&mt('Frequency'), |
|
&mt('Percent'))).'</th></tr>'; |
|
my @foils = sort(keys(%{$data->{'foil_responses'}})); |
|
foreach my $foilid (@foils) { |
|
my $prob_data = $ProblemData->{$partid.'.'.$respid}; |
|
my $foil_count = $data->{'foil_count'}->{$foilid}; |
|
my $foiltext = $prob_data->{'_Foils'}->{$foilid}->{'text'}; |
|
my $foilname = $prob_data->{'_Foils'}->{$foilid}->{'name'}; |
|
my $rowspan = scalar(@{$prob_data->{'_Options'}}); |
|
my $preamble = '<tr>'. |
|
'<td valign="top" rowspan="'.$rowspan.'">'. |
|
$foilname.'</td>'. |
|
'<td valign="top" rowspan="'.$rowspan.'">'. |
|
$foiltext.'</td>'; |
|
foreach my $option (sort(@{$prob_data->{'_Options'}})){ |
|
my $count = |
|
$data->{'foil_responses'}->{$foilid}->{$option}; |
|
$tmp .= $preamble. |
|
'<td>'.$option.'</td>'. |
|
'<td align="right">'.$count.'</td>'. |
|
'<td align="right">'. |
|
sprintf('%.2f',100*$count/$foil_count).'%'. |
|
'</td></tr>'.$/; |
|
$preamble = '<tr>'; |
|
} |
|
} |
|
$Str.=$tmp.'</table></td></tr>'; |
} elsif (exists($data->{'_count'}) && |
} elsif (exists($data->{'_count'}) && |
exists($data->{'foil_values'}) && |
exists($data->{'foil_values'}) && |
exists($data->{'map'})) { |
exists($data->{'map'})) { |
Line 370 sub CreateInterface {
|
Line 418 sub CreateInterface {
|
return $Str; |
return $Str; |
} |
} |
|
|
|
|
|
|
1; |
1; |
|
|
__END__ |
__END__ |