[system] / branches / gage_dev / webwork2 / lib / WeBWorK / ContentGenerator / Instructor / ProblemSetDetail.pm Repository:
ViewVC logotype

Diff of /branches/gage_dev/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5703 Revision 5704
43use constant USER_PROBLEM_FIELDS => [qw(problem_seed status num_correct num_incorrect)]; 43use constant USER_PROBLEM_FIELDS => [qw(problem_seed status num_correct num_incorrect)];
44 44
45# these constants determine what order those fields should be displayed in 45# these constants determine what order those fields should be displayed in
46use constant HEADER_ORDER => [qw(set_header hardcopy_header)]; 46use constant HEADER_ORDER => [qw(set_header hardcopy_header)];
47use constant PROBLEM_FIELD_ORDER => [qw(problem_seed status value max_attempts attempted last_answer num_correct num_incorrect)]; 47use constant PROBLEM_FIELD_ORDER => [qw(problem_seed status value max_attempts attempted last_answer num_correct num_incorrect)];
48# for gateway sets, we don't want to allow users to change max_attempts on a per
49# problem basis, as that's nothing but confusing.
50use constant GATEWAY_PROBLEM_FIELD_ORDER => [qw(problem_seed status value attempted last_answer num_correct num_incorrect)];
48 51
49# we exclude the gateway set fields from the set field order, because they 52# we exclude the gateway set fields from the set field order, because they
50# are only displayed for sets that are gateways. this results in a bit of 53# are only displayed for sets that are gateways. this results in a bit of
51# convoluted logic below, but it saves burdening people who are only using 54# convoluted logic below, but it saves burdening people who are only using
52# homework assignments with all of the gateway parameters 55# homework assignments with all of the gateway parameters
53# FIXME: in the long run, we may want to let hide_score and hide_work be 56# FIXME: in the long run, we may want to let hide_score and hide_work be
54# FIXME: set for non-gateway assignments. right now (11/30/06) they are 57# FIXME: set for non-gateway assignments. right now (11/30/06) they are
55# FIXME: only used for gateways 58# FIXME: only used for gateways
56use constant SET_FIELD_ORDER => [qw(open_date due_date answer_date published restrict_ip relax_restrict_ip assignment_type)]; 59use constant SET_FIELD_ORDER => [qw(open_date due_date answer_date published restrict_ip relax_restrict_ip assignment_type)];
57# use constant GATEWAY_SET_FIELD_ORDER => [qw(attempts_per_version version_time_limit time_interval versions_per_interval problem_randorder problems_per_page hide_score hide_work)]; 60# use constant GATEWAY_SET_FIELD_ORDER => [qw(attempts_per_version version_time_limit time_interval versions_per_interval problem_randorder problems_per_page hide_score hide_work)];
58use constant GATEWAY_SET_FIELD_ORDER => [qw(version_time_limit time_limit_cap attempts_per_version time_interval versions_per_interval problem_randorder problems_per_page hide_score:hide_score_by_problem hide_work)]; 61use constant GATEWAY_SET_FIELD_ORDER => [qw(version_time_limit time_limit_cap attempts_per_version time_interval versions_per_interval problem_randorder problems_per_page hide_score:hide_score_by_problem hide_work)];
59 62
313 316
314# Create a table of fields for the given parameters, one row for each db field 317# Create a table of fields for the given parameters, one row for each db field
315# if only the setID is included, it creates a table of set information 318# if only the setID is included, it creates a table of set information
316# if the problemID is included, it creates a table of problem information 319# if the problemID is included, it creates a table of problem information
317sub FieldTable { 320sub FieldTable {
318 my ($self, $userID, $setID, $problemID, $globalRecord, $userRecord) = @_; 321 my ($self, $userID, $setID, $problemID, $globalRecord, $userRecord, $isGWset) = @_;
319 322
320 my $r = $self->r; 323 my $r = $self->r;
321 my @editForUser = $r->param('editForUser'); 324 my @editForUser = $r->param('editForUser');
322 my $forUsers = scalar(@editForUser); 325 my $forUsers = scalar(@editForUser);
323 my $forOneUser = $forUsers == 1; 326 my $forOneUser = $forUsers == 1;
324 327
325 my @fieldOrder; 328 my @fieldOrder;
326 329
327 # needed for gateway output 330 # needed for gateway output
328 my $gwFields = ''; 331 my $gwFields = '';
332 # $isGWset will come in undef if we don't need to worry about it
333 $isGWset = 0 if ( ! defined( $isGWset ) );
329 334
330 # needed for ip restrictions 335 # needed for ip restrictions
331 my $ipFields = ''; 336 my $ipFields = '';
332 my $ipDefaults; 337 my $ipDefaults;
333 my $numLocations = 0; 338 my $numLocations = 0;
335 340
336 # needed for set-level proctor 341 # needed for set-level proctor
337 my $procFields = ''; 342 my $procFields = '';
338 343
339 if (defined $problemID) { 344 if (defined $problemID) {
345 @fieldOrder = ($isGWset) ? @{ GATEWAY_PROBLEM_FIELD_ORDER() } :
340 @fieldOrder = @{ PROBLEM_FIELD_ORDER() }; 346 @{ PROBLEM_FIELD_ORDER() };
341 } else { 347 } else {
342 @fieldOrder = @{ SET_FIELD_ORDER() }; 348 @fieldOrder = @{ SET_FIELD_ORDER() };
343 349
344 ($gwFields, $ipFields, $numLocations, $procFields) = $self->extraSetFields($userID, $setID, $globalRecord, $userRecord, $forUsers); 350 ($gwFields, $ipFields, $numLocations, $procFields) = $self->extraSetFields($userID, $setID, $globalRecord, $userRecord, $forUsers);
345 } 351 }
1316 1322
1317 # Mark the specified problems as correct for all users 1323 # Mark the specified problems as correct for all users
1318 foreach my $problemID ($r->param('markCorrect')) { 1324 foreach my $problemID ($r->param('markCorrect')) {
1319 # DBFIXME where clause, iterator 1325 # DBFIXME where clause, iterator
1320 my @userProblemIDs = map { [$_, $setID, $problemID] } ($forUsers ? @editForUser : $db->listProblemUsers($setID, $problemID)); 1326 my @userProblemIDs = map { [$_, $setID, $problemID] } ($forUsers ? @editForUser : $db->listProblemUsers($setID, $problemID));
1327 # if the set is not a gateway set, this requires going through the
1328 # user_problems and resetting their status; if it's a gateway set,
1329 # then we have to go through every *version* of every user_problem.
1330 # it may be that there is an argument for being able to get() all
1331 # problem versions for all users in one database call. The current
1332 # code may be slow for large classes.
1333 if ( $setRecord->assignment_type !~ /gateway/ ) {
1321 my @userProblemRecords = $db->getUserProblems(@userProblemIDs); 1334 my @userProblemRecords = $db->getUserProblems(@userProblemIDs);
1322 foreach my $record (@userProblemRecords) { 1335 foreach my $record (@userProblemRecords) {
1323 if (defined $record && ($record->status eq "" || $record->status < 1)) { 1336 if (defined $record && ($record->status eq "" || $record->status < 1)) {
1324 $record->status(1); 1337 $record->status(1);
1325 $record->attempted(1); 1338 $record->attempted(1);
1326 $db->putUserProblem($record); 1339 $db->putUserProblem($record);
1340 }
1341 }
1342 } else {
1343 my @userIDs = ( $forUsers ) ? @editForUser : $db->listProblemUsers($setID, $problemID);
1344 foreach my $uid ( @userIDs ) {
1345 my @versions = $db->listSetVersions( $uid, $setID );
1346 my @userProblemVersionIDs =
1347 map{ [ $uid, $setID, $_, $problemID ]} @versions;
1348 my @userProblemVersionRecords = $db->getProblemVersions(@userProblemVersionIDs);
1349 foreach my $record (@userProblemVersionRecords) {
1350 if (defined $record && ($record->status eq "" || $record->status < 1)) {
1351 $record->status(1);
1352 $record->attempted(1);
1353 $db->putProblemVersion($record);
1354 }
1355 }
1327 } 1356 }
1328 } 1357 }
1329 } 1358 }
1330 1359
1331 # Delete all problems marked for deletion 1360 # Delete all problems marked for deletion
1535 1564
1536 # If you're editing for users, initially their records will be different but 1565 # If you're editing for users, initially their records will be different but
1537 # if you make any changes to them they will be the same. 1566 # if you make any changes to them they will be the same.
1538 # if you're editing for one user, the problems shown should be his/hers 1567 # if you're editing for one user, the problems shown should be his/hers
1539 my $userToShow = $forUsers ? $editForUser[0] : $userID; 1568 my $userToShow = $forUsers ? $editForUser[0] : $userID;
1569
1570 # a useful gateway variable
1571 my $isGatewaySet = ( $setRecord->assignment_type =~ /gateway/ ) ? 1 : 0;
1540 1572
1541 # DBFIXME no need to get ID lists -- counts would be fine 1573 # DBFIXME no need to get ID lists -- counts would be fine
1542 my $userCount = $db->listUsers(); 1574 my $userCount = $db->listUsers();
1543 my $setCount = $db->listGlobalSets(); # if $forOneUser; 1575 my $setCount = $db->listGlobalSets(); # if $forOneUser;
1544 my $setUserCount = $db->countSetUsers($setID); 1576 my $setUserCount = $db->countSetUsers($setID);
1717 if ( ! $guaranteed_set ) { 1749 if ( ! $guaranteed_set ) {
1718 # in the header loop we need to have a set that 1750 # in the header loop we need to have a set that
1719 # we know exists, so if the getMergedSet failed 1751 # we know exists, so if the getMergedSet failed
1720 # (that is, the set isn't assigned to the 1752 # (that is, the set isn't assigned to the
1721 # the current user), we get the global set instead 1753 # the current user), we get the global set instead
1722 $guaranteed_set = $db->getGlobalSet( $setID ); 1754 # $guaranteed_set = $db->getGlobalSet( $setID );
1755 $guaranteed_set = $setRecord;
1723 } 1756 }
1724 1757
1725 foreach my $header (@headers) { 1758 foreach my $header (@headers) {
1726 1759
1727 my $headerFile = $r->param("set.$setID.$header") || $setRecord->{$header} || $headerDefaults{$header}; 1760 my $headerFile = $r->param("set.$setID.$header") || $setRecord->{$header} || $headerDefaults{$header};
1833 CGI::input({type => "submit", name => "refresh", value => "Refresh Display"}), 1866 CGI::input({type => "submit", name => "refresh", value => "Refresh Display"}),
1834 ])); 1867 ]));
1835 1868
1836 my %shownYet; 1869 my %shownYet;
1837 my $repeatFile; 1870 my $repeatFile;
1871
1838 foreach my $problemID (@problemIDList) { 1872 foreach my $problemID (@problemIDList) {
1839 1873
1840 my $problemRecord; 1874 my $problemRecord;
1841 if ($forOneUser) { 1875 if ($forOneUser) {
1842 #$problemRecord = $db->getMergedProblem($editForUser[0], $setID, $problemID); 1876 #$problemRecord = $db->getMergedProblem($editForUser[0], $setID, $problemID);
1856 1890
1857 # FIXME: should we have an "act as" type link here when editing for multiple users? 1891 # FIXME: should we have an "act as" type link here when editing for multiple users?
1858 my $viewProblemPage = $urlpath->new(type => 'problem_detail', args => { courseID => $courseID, setID => $setID, problemID => $problemID }); 1892 my $viewProblemPage = $urlpath->new(type => 'problem_detail', args => { courseID => $courseID, setID => $setID, problemID => $problemID });
1859 my $viewProblemLink = $self->systemLink($viewProblemPage, params => { effectiveUser => ($forOneUser ? $editForUser[0] : $userID)}); 1893 my $viewProblemLink = $self->systemLink($viewProblemPage, params => { effectiveUser => ($forOneUser ? $editForUser[0] : $userID)});
1860 1894
1895 ###-----
1896 ### The array @fields never gets used in the following, so
1897 ### I'm commenting it out. If there's a reason it should
1898 ### be here, someone else can add it back in and maybe
1899 ### comment why. Thanks, Gavin. -glarose 6/19/08
1861 my @fields = @{ PROBLEM_FIELDS() }; 1900 ### my @fields = @{ PROBLEM_FIELDS() };
1862 push @fields, @{ USER_PROBLEM_FIELDS() } if $forOneUser; 1901 ### push @fields, @{ USER_PROBLEM_FIELDS() } if $forOneUser;
1902 ###-----
1863 1903
1864 my $problemFile = $r->param("problem.$problemID.source_file") || $problemRecord->source_file; 1904 my $problemFile = $r->param("problem.$problemID.source_file") || $problemRecord->source_file;
1865 1905
1866 # warn of repeat problems 1906 # warn of repeat problems
1867 if (defined $shownYet{$problemFile}) { 1907 if (defined $shownYet{$problemFile}) {
1893 CGI::Tr({}, CGI::td({}, CGI::a({href => $viewProblemLink, target=>"WW_View"}, "Try it" . ($forOneUser ? " (as $editForUser[0])" : "")))) . 1933 CGI::Tr({}, CGI::td({}, CGI::a({href => $viewProblemLink, target=>"WW_View"}, "Try it" . ($forOneUser ? " (as $editForUser[0])" : "")))) .
1894 ($forUsers ? "" : CGI::Tr({}, CGI::td({}, CGI::checkbox({name => "deleteProblem", value => $problemID, label => "Delete it?"})))) . 1934 ($forUsers ? "" : CGI::Tr({}, CGI::td({}, CGI::checkbox({name => "deleteProblem", value => $problemID, label => "Delete it?"})))) .
1895# CGI::Tr({}, CGI::td({}, "Delete&nbsp;it?" . CGI::input({type => "checkbox", name => "deleteProblem", value => $problemID}))) . 1935# CGI::Tr({}, CGI::td({}, "Delete&nbsp;it?" . CGI::input({type => "checkbox", name => "deleteProblem", value => $problemID}))) .
1896 ($forOneUser ? "" : CGI::Tr({}, CGI::td({}, CGI::checkbox({name => "markCorrect", value => $problemID, label => "Mark Correct?"})))) . 1936 ($forOneUser ? "" : CGI::Tr({}, CGI::td({}, CGI::checkbox({name => "markCorrect", value => $problemID, label => "Mark Correct?"})))) .
1897 CGI::end_table(), 1937 CGI::end_table(),
1898 $self->FieldTable($userToShow, $setID, $problemID, $GlobalProblems{$problemID}, $UserProblems{$problemID}), 1938 $self->FieldTable($userToShow, $setID, $problemID, $GlobalProblems{$problemID}, $UserProblems{$problemID}, $isGatewaySet),
1899# A comprehensive list of problems is just TOO big to be handled well 1939# A comprehensive list of problems is just TOO big to be handled well
1900# comboBox({ 1940# comboBox({
1901# name => "set.$setID.$problemID", 1941# name => "set.$setID.$problemID",
1902# request => $r, 1942# request => $r,
1903# default => $problemRecord->{problem_id}, 1943# default => $problemRecord->{problem_id},

Legend:
Removed from v.5703  
changed lines
  Added in v.5704

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9