--- loncom/interface/statistics/lonstathelpers.pm 2014/02/28 19:20:17 1.73 +++ loncom/interface/statistics/lonstathelpers.pm 2020/09/12 20:21:30 1.79 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.73 2014/02/28 19:20:17 bisitz Exp $ +# $Id: lonstathelpers.pm,v 1.79 2020/09/12 20:21:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -108,10 +108,17 @@ sub render_resource { #################################################### #################################################### sub get_resources { - my ($navmap,$sequence) = @_; - my @resources = $navmap->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; } @@ -135,9 +142,12 @@ Skips 'survey' problems. #################################################### #################################################### sub problem_selector { - my ($AcceptedResponseTypes,$sequence_addendum,$symbmode,$all,$prefix,$smallbox,$onclick) = @_; + my ($AcceptedResponseTypes,$sequence_addendum,$symbmode,$all,$prefix, + $byres,$include_tools,$smallbox,$onclick) = @_; # all: also make sequences selectable # prefix: prefix for all form names +# byres: radiobutton shown per resource +# include_tools: external tools included # smallbox: use smaller box # onclick: javascript to execute when clicked my $Str; @@ -155,62 +165,140 @@ 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:/([^/]*)$:); + } + my $totalresps = 0; + if ($byres) { + foreach my $part (@{$res->parts}) { + $totalresps += scalar($res->responseIds($part)); + } + my $value = &HTML::Entities::encode($res->symb(),'<>&"'); + my $checked; + 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(). + '
'.&mt('No gradable problems found').'
'; + } elsif ($AcceptedResponseTypes eq '.') { + $Str = ''.&mt('No problems found').'
'; + } else { + $Str = ''.&mt('No analyzable problems found').'
'; + } + } return $Str; } @@ -286,7 +374,8 @@ END END if (ref($anoncounter) eq 'HASH') { if (keys(%{$anoncounter}) > 0) { - my $anonwarning = &mt('Your selection includes both problems with and without anonymous submissions.').'\n'.&mt('You must select either only anonymous or only named problems.').'\n\n'.&mt('If a selection contains both anonymous and named parts,[_1]use the Anonymous/Named buttons to ensure selections will be either all anonymous[_1]or all named.','\n'); + my $anonwarning = &mt('Your selection includes both problems with and without anonymous submissions.')."\n".&mt('You must select either only anonymous or only named problems.')."\n\n".&mt('If a selection contains both anonymous and named parts,[_1]use the Anonymous/Named buttons to ensure selections will be either all anonymous[_1]or all named.',"\n"); + &js_escape(\$anonwarning); $checkanonjs = <<"END";