--- loncom/interface/statistics/lonstathelpers.pm 2020/08/26 21:50:16 1.76.2.1 +++ loncom/interface/statistics/lonstathelpers.pm 2023/07/12 15:09:41 1.81 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.76.2.1 2020/08/26 21:50:16 raeburn Exp $ +# $Id: lonstathelpers.pm,v 1.81 2023/07/12 15:09:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -73,7 +73,7 @@ use LONCAPA; Input: a navmaps resource -Retunrs: a scalar containing html for a rendering of the problem +Returns: a scalar containing html for a rendering of the problem within a table. =cut @@ -85,7 +85,7 @@ sub render_resource { ## ## Render the problem my ($base) = ($resource->src =~ m|^(.*/)[^/]*$|); - $base="http://".$ENV{'SERVER_NAME'}.$base; + $base=&Apache::lonnet::absolute_url().$base; my ($src,$symb)=($resource->link,&escape($resource->shown_symb)); my $rendered_problem = &Apache::lonnet::ssi_body($src.'?symb='.$symb); $rendered_problem =~ s/<\s*form\s*/retrieveResources($sequence, - sub { shift->is_problem(); }, - 0,0,0); + my ($navmap,$sequence,$include_tools) = @_; + my @resources; + if ($include_tools) { + @resources = $navmap->retrieveResources($sequence, + sub { shift->is_gradable(); }, + 0,0,0); + } else { + @resources = $navmap->retrieveResources($sequence, + sub { shift->is_problem(); }, + 0,0,0); + } return @resources; } @@ -158,7 +165,10 @@ sub problem_selector { return $navmap if (! ref($navmap)); # error foreach my $seq (@sequences) { my $seq_str = ''; - foreach my $res (&get_resources($navmap,$seq)) { + foreach my $res (&get_resources($navmap,$seq,$include_tools)) { + if ($res->src() eq '/res/lib/templates/simpleproblem.problem') { + next if (grep(/^placeholder$/,@{$res->parts})); + } my $title = $res->compTitle; if (! defined($title) || $title eq '') { ($title) = ($res->src =~ m:/([^/]*)$:); @@ -173,8 +183,12 @@ sub problem_selector { if ($env{'form.problemchoice'} eq $res->symb()) { $checked = ' checked="checked"'; } + my $rowspan; + if ($totalresps > 1) { + $rowspan = ' rowspan="'.$totalresps.'"'; + } $seq_str .= &Apache::loncommon::start_data_table_row(). - ''. + ''. ''; my $link = $res->link.'?symb='.&escape($res->shown_symb); @@ -183,14 +197,22 @@ sub problem_selector { } my %partsseen; foreach my $part (@{$res->parts}) { - my @response_ids = $res->responseIds($part); - my @response_types = $res->responseType($part); + my (@response_ids,@response_types); + if (($include_tools) && ($res->is_tool)) { + @response_ids = (); + @response_types = ('tool'); + } else { + @response_ids = $res->responseIds($part); + @response_types = $res->responseType($part); + } for (my $i=0;$i'. + my $resprowspan; + if (scalar(@response_ids) > 1) { + $resprowspan = ' rowspan="'.scalar(@response_ids).'"'; + } + $seq_str .= ''. $parttitle.''; $partsseen{$part} = scalar(@response_ids); } @@ -236,8 +262,8 @@ sub problem_selector { $seq_str .= (' 'x2). ''.&mt('view').''; $seq_str .= "". &Apache::loncommon::end_data_table_row()."\n"; - $rb_count++; } + $rb_count++; } } } @@ -264,6 +290,15 @@ sub problem_selector { } } $Str .= &Apache::loncommon::end_data_table().&Apache::loncommon::end_scrollbox()."\n"; + if (!$rb_count) { + if ($byres) { + $Str = '

'.&mt('No gradable problems found').'

'; + } elsif ($AcceptedResponseTypes eq '.') { + $Str = '

'.&mt('No problems found').'

'; + } else { + $Str = '

'.&mt('No analyzable problems found').'

'; + } + } return $Str; }