[system] / trunk / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / SetMaker.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm

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

Revision 2229 Revision 2230
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.15 2004/05/22 16:46:03 jj Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.16 2004/05/28 23:15:44 jj Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
123 $problemRecord->source_file($file); 123 $problemRecord->source_file($file);
124 $problemRecord->value("1"); 124 $problemRecord->value("1");
125 $problemRecord->max_attempts("-1"); 125 $problemRecord->max_attempts("-1");
126 $db->addGlobalProblem($problemRecord); 126 $db->addGlobalProblem($problemRecord);
127 $self->assignProblemToAllSetUsers($problemRecord); 127 $self->assignProblemToAllSetUsers($problemRecord);
128 $selected->[1] &= SUCCESS; 128 $selected->[1] |= SUCCESS;
129 $addedcount++; 129 $addedcount++;
130 } 130 }
131 } 131 }
132 return($addedcount); 132 return($addedcount);
133} 133}
192 unshift @{$list_of_prob_dirs}, $default_value; 192 unshift @{$list_of_prob_dirs}, $default_value;
193 $library_selected = $default_value; 193 $library_selected = $default_value;
194 } 194 }
195 } 195 }
196 my $view_problem_line = view_problems_line('view_local_set', 'View Problems', $self->r); 196 my $view_problem_line = view_problems_line('view_local_set', 'View Problems', $self->r);
197 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Local Problems: ", 197 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Local Problems: ",
198 CGI::popup_menu(-name=> 'library_sets', 198 CGI::popup_menu(-name=> 'library_sets',
199 -values=>$list_of_prob_dirs, 199 -values=>$list_of_prob_dirs,
200 -default=> $library_selected), 200 -default=> $library_selected),
201 CGI::br(), 201 CGI::br(),
202 $view_problem_line, 202 $view_problem_line,
216 unshift @{$list_of_local_sets}, $default_value; 216 unshift @{$list_of_local_sets}, $default_value;
217 $library_selected = $default_value; 217 $library_selected = $default_value;
218 } 218 }
219 219
220 my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r); 220 my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r);
221 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Browse from: ", 221 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Browse from: ",
222 CGI::popup_menu(-name=> 'library_sets', 222 CGI::popup_menu(-name=> 'library_sets',
223 -values=>$list_of_local_sets, 223 -values=>$list_of_local_sets,
224 -default=> $library_selected), 224 -default=> $library_selected),
225 CGI::br(), 225 CGI::br(),
226 $view_problem_line 226 $view_problem_line
276 276
277 unshift @sects, $default_sect; 277 unshift @sects, $default_sect;
278 my $section_selected = $r->param('library_sections') || $default_sect; 278 my $section_selected = $r->param('library_sections') || $default_sect;
279 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 279 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r);
280 280
281 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, 281 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"},
282 CGI::start_table(), 282 CGI::start_table(),
283 CGI::Tr( 283 CGI::Tr(
284 CGI::td(["Chapter:", 284 CGI::td(["Chapter:",
285 CGI::popup_menu(-name=> 'library_chapters', 285 CGI::popup_menu(-name=> 'library_chapters',
286 -values=>\@chaps, 286 -values=>\@chaps,
358 } 358 }
359 unshift @{$list_of_local_sets}, SELECT_SET_STRING; 359 unshift @{$list_of_local_sets}, SELECT_SET_STRING;
360 $set_selected = SELECT_SET_STRING; 360 $set_selected = SELECT_SET_STRING;
361 } 361 }
362 362
363 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Adding Problems to ", 363 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Adding Problems to ",
364 CGI::b("Current Set: "), 364 CGI::b("Current Set: "),
365 CGI::popup_menu(-name=> 'local_sets', 365 CGI::popup_menu(-name=> 'local_sets',
366 -values=>$list_of_local_sets, 366 -values=>$list_of_local_sets,
367 -default=> $set_selected), 367 -default=> $set_selected),
368 CGI::submit(-name=>"edit_local", -value=>"Edit Current Set"), 368 CGI::submit(-name=>"edit_local", -value=>"Edit Current Set"),
369 CGI::br(), 369 CGI::br(),
370 CGI::br(), 370 CGI::br(),
371 CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:"), 371 CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:",
372 #-onclick=>$myjs
373 ),
372 " ", 374 " ",
373 CGI::textfield(-name=>"new_set_name", 375 CGI::textfield(-name=>"new_set_name",
374 -default=>"Name for new set here", 376 -default=>"Name for new set here",
375 -override=>1, -size=>30), 377 -override=>1, -size=>30),
376 CGI::br(), 378 CGI::br(),
377 )); 379 ));
378 380
379 print CGI::Tr(CGI::td({-bgcolor=>"black"})); 381 print CGI::Tr(CGI::td({-bgcolor=>"black"}));
380 382
381 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, 383 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"},
384 CGI::start_table({-border=>"0"}),
385 CGI::Tr( CGI::td({ -align=>"center"},
386 CGI::submit(-name=>"select_all", -style=>$these_widths,
387 -value=>"Mark All For Adding"),
382 CGI::submit(-name=>"update", -style=>$these_widths, 388 CGI::submit(-name=>"select_none", -style=>$these_widths,
383 -value=>"Act on Marked Problems"), 389 -value=>"Clear All Marks"),
390 )),
391 CGI::Tr( CGI::td(
392 CGI::submit(-name=>"update", -style=>$these_widths. "; font-weight:bold",
393 -value=>"Update"),
384 CGI::submit(-name=>"rerandomize", 394 CGI::submit(-name=>"rerandomize",
385 -style=>$these_widths, 395 -style=>$these_widths,
386 -value=>"Rerandomize"), 396 -value=>"Rerandomize"),
387 CGI::submit(-name=>"cleardisplay", 397 CGI::submit(-name=>"cleardisplay",
388 -style=>$these_widths, 398 -style=>$these_widths,
389 -value=>"Clear Problem Display"))); 399 -value=>"Clear Problem Display")
400 )),
401 CGI::end_table()));
390 402
391} 403}
392 404
393sub make_data_row { 405sub make_data_row {
394 my $self = shift; 406 my $self = shift;
395 my $sourceFileName = shift; 407 my $sourceFileName = shift;
396 my $pg = shift; 408 my $pg = shift;
397 my $cnt = shift; 409 my $cnt = shift;
410 my $mark = shift || 0;
398 411
399 $sourceFileName =~ s|^./||; # clean up top ugliness 412 $sourceFileName =~ s|^./||; # clean up top ugliness
400 413
401 my $urlpath = $self->r->urlpath; 414 my $urlpath = $self->r->urlpath;
402 my $problem_output = $pg->{flags}->{error_flag} ? 415 my $problem_output = $pg->{flags}->{error_flag} ?
421 problemID=>"1"), 434 problemID=>"1"),
422 params =>{effectiveUser => $self->r->param('user'), 435 params =>{effectiveUser => $self->r->param('user'),
423 editMode => "SetMaker", 436 editMode => "SetMaker",
424 sourceFilePath => "$sourceFileName"} )}, "Try it"); 437 sourceFilePath => "$sourceFileName"} )}, "Try it");
425 438
426 439 my %add_box_data = ( -name=>"trial$cnt",-value=>1,-label=>"Add me to the current set on the next update");
440 if($mark & SUCCESS) {
441 $add_box_data{ -label } .= " (just added this problem)";
442 } elsif($mark & ADDED) {
443 $add_box_data{ -checked } = 1;
444 }
427 445
428 print CGI::Tr({-align=>"left"}, CGI::td( 446 print CGI::Tr({-align=>"left"}, CGI::td(
429 447
430 CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, 448 CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"},
431CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), 449CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "),
435 453
436 454
437 455
438 CGI::checkbox(-name=>"hideme$cnt",-value=>1,-label=>"Don't show me on the next update"), 456 CGI::checkbox(-name=>"hideme$cnt",-value=>1,-label=>"Don't show me on the next update"),
439 CGI::br(), 457 CGI::br(),
440 CGI::checkbox(-name=>"trial$cnt",-value=>1,-label=>"Add me to the current set on the next update"), 458 CGI::checkbox((%add_box_data)),
441 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]). 459 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]).
442 CGI::p($problem_output), 460 CGI::p($problem_output),
443 )); 461 ));
444} 462}
445 463
482 ## Next, lots of set up so that errors can be reported with message() 500 ## Next, lots of set up so that errors can be reported with message()
483 501
484 ############# List of problems we have already printed 502 ############# List of problems we have already printed
485 503
486 $self->{past_problems} = get_past_problem_files($r); 504 $self->{past_problems} = get_past_problem_files($r);
505 # if we don't end up reusing problems, this will be wiped out
506 # if we do redisplay the same problems, we must adjust this accordingly
507 my @past_marks = map {$_->[1]} @{$self->{past_problems}};
487 my $none_shown = scalar(@{$self->{past_problems}})==0; 508 my $none_shown = scalar(@{$self->{past_problems}})==0;
488 my @pg_files=(); 509 my @pg_files=();
489 my $use_previous_problems = 1; 510 my $use_previous_problems = 1;
490 my $first_shown = $r->param('first_shown') || 0; 511 my $first_shown = $r->param('first_shown') || 0;
491 my $last_shown = $r->param('last_shown'); 512 my $last_shown = $r->param('last_shown');
571 } 592 }
572 593
573 ##### View whole chapter from the library 594 ##### View whole chapter from the library
574 ## This will change somewhat later 595 ## This will change somewhat later
575 596
576 } elsif ($r->param('lib_view')) { 597 } elsif ($r->param('lib_view')) {
577 598
578 @pg_files=(); 599 @pg_files=();
579 my $chap = $r->param('library_chapters') || ""; 600 my $chap = $r->param('library_chapters') || "";
580 $chap = "" if($chap eq "All Chapters"); 601 $chap = "" if($chap eq "All Chapters");
581 my $sect = $r->param('library_sections') || ""; 602 my $sect = $r->param('library_sections') || "";
630 651
631 @pg_files = grep {($_->[1] & ADDED) != 0 } @{$self->{past_problems}}; 652 @pg_files = grep {($_->[1] & ADDED) != 0 } @{$self->{past_problems}};
632 @selected = map {$_->[0]} @pg_files; 653 @selected = map {$_->[0]} @pg_files;
633 654
634 my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; 655 my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}};
656 # There are now good reasons to do an update without selecting anything.
635 if(scalar(@action_files) == 0) { 657 #if(scalar(@action_files) == 0) {
636 $self->addbadmessage('Act on marked problems requested, but no problems were marked.'); 658 # $self->addbadmessage('Update requested, but no problems were marked.');
637 } 659 #}
638 660
639 if (scalar(@selected)>0) { # if some are to be added, they need a place to go 661 if (scalar(@selected)>0) { # if some are to be added, they need a place to go
640 $localSet = $r->param('local_sets'); 662 $localSet = $r->param('local_sets');
641 if (not defined($localSet) or 663 if (not defined($localSet) or
642 $localSet eq SELECT_SET_STRING or 664 $localSet eq SELECT_SET_STRING or
657 } 679 }
658 ## now handle problems to be hidden 680 ## now handle problems to be hidden
659 681
660 ## only keep the ones which are not hidden 682 ## only keep the ones which are not hidden
661 @pg_files = grep {($_->[1] & HIDDEN) ==0 } @{$self->{past_problems}}; 683 @pg_files = grep {($_->[1] & HIDDEN) ==0 } @{$self->{past_problems}};
684 @past_marks = map {$_->[1]} @pg_files;
662 @pg_files = map {$_->[0]} @pg_files; 685 @pg_files = map {$_->[0]} @pg_files;
663 @all_past_list = (@all_past_list[0..($first_shown-1)], 686 @all_past_list = (@all_past_list[0..($first_shown-1)],
664 @pg_files, 687 @pg_files,
665 @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]); 688 @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]);
666 $last_shown = $first_shown+$maxShown -1; 689 $last_shown = $first_shown+$maxShown -1;
667 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); 690 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list));
668 691
669 ## FIXME: you should say something if no problems are selected
670 ## maybe the add button should be disabled if there are no problems
671 ## showing
672
673
674 } elsif ($r->param('next_page')) { 692 } elsif ($r->param('next_page')) {
675 $first_shown = $last_shown+1; 693 $first_shown = $last_shown+1;
676 $last_shown = $first_shown+$maxShown-1; 694 $last_shown = $first_shown+$maxShown-1;
677 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); 695 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list));
696 @past_marks = ();
678 } elsif ($r->param('prev_page')) { 697 } elsif ($r->param('prev_page')) {
679 $last_shown = $first_shown-1; 698 $last_shown = $first_shown-1;
680 $first_shown = $last_shown - $maxShown+1; 699 $first_shown = $last_shown - $maxShown+1;
681 700
682 $first_shown = 0 if($first_shown<0); 701 $first_shown = 0 if($first_shown<0);
702 @past_marks = ();
703
704 } elsif ($r->param('select_all')) {
705 @past_marks = map {1} @past_marks;
706 } elsif ($r->param('select_none')) {
707 @past_marks = ();
683 708
684 ##### No action requested, probably our first time here 709 ##### No action requested, probably our first time here
685 710
686 } else { 711 } else {
687 #my $c = $r->connection; 712 #my $c = $r->connection;
702 @pg_files = @all_past_list; 727 @pg_files = @all_past_list;
703 } else { 728 } else {
704 $first_shown = 0; 729 $first_shown = 0;
705 $last_shown = scalar(@pg_files)<$maxShown ? scalar(@pg_files) : $maxShown; 730 $last_shown = scalar(@pg_files)<$maxShown ? scalar(@pg_files) : $maxShown;
706 $last_shown--; # to make it an array index 731 $last_shown--; # to make it an array index
732 @past_marks = ();
707 } 733 }
708 ############# Now store data in self for retreival by body 734 ############# Now store data in self for retreival by body
709 $self->{first_shown} = $first_shown; 735 $self->{first_shown} = $first_shown;
710 $self->{last_shown} = $last_shown; 736 $self->{last_shown} = $last_shown;
711 $self->{browse_which} = $browse_which; 737 $self->{browse_which} = $browse_which;
712 $self->{problem_seed} = $problem_seed; 738 $self->{problem_seed} = $problem_seed;
713 $self->{pg_files} = \@pg_files; 739 $self->{pg_files} = \@pg_files;
740 $self->{past_marks} = \@past_marks;
714 $self->{all_set_defs} = \@all_set_defs; 741 $self->{all_set_defs} = \@all_set_defs;
715 742
716} 743}
717 744
718 745
778 805
779 ########## Now print problems 806 ########## Now print problems
780 my $jj; 807 my $jj;
781 for ($jj=0; $jj<scalar(@pg_html); $jj++) { 808 for ($jj=0; $jj<scalar(@pg_html); $jj++) {
782 $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; 809 $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||;
783 $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1); 810 $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]);
784 } 811 }
785 812
786 ########## Finish things off 813 ########## Finish things off
787 print CGI::end_table(); 814 print CGI::end_table();
788 print '</div>'; 815 print '</div>';

Legend:
Removed from v.2229  
changed lines
  Added in v.2230

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9