| … | |
… | |
| 65 | ## Flags for operations on files |
65 | ## Flags for operations on files |
| 66 | |
66 | |
| 67 | use constant ADDED => 1; |
67 | use constant ADDED => 1; |
| 68 | use constant HIDDEN => (1 << 1); |
68 | use constant HIDDEN => (1 << 1); |
| 69 | use constant SUCCESS => (1 << 2); |
69 | use constant SUCCESS => (1 << 2); |
|
|
70 | use constant DELETED => (1 << 3); |
| 70 | |
71 | |
| 71 | ## for additional problib buttons |
72 | ## for additional problib buttons |
| 72 | my %problib; ## filled in in global.conf |
73 | my %problib; ## filled in in global.conf |
| 73 | my %ignoredir = ( |
74 | my %ignoredir = ( |
| 74 | '.' => 1, '..' => 1, 'Library' => 1, 'CVS' => 1, 'tmpEdit' => 1, |
75 | '.' => 1, '..' => 1, 'Library' => 1, 'CVS' => 1, 'tmpEdit' => 1, |
| … | |
… | |
| 237 | my @found=(); |
238 | my @found=(); |
| 238 | my $count =1; |
239 | my $count =1; |
| 239 | while (defined($r->param("filetrial$count"))) { |
240 | while (defined($r->param("filetrial$count"))) { |
| 240 | my $val = 0; |
241 | my $val = 0; |
| 241 | $val |= ADDED if($r->param("trial$count")); |
242 | $val |= ADDED if($r->param("trial$count")); |
|
|
243 | $val |= DELETED if($r->param("deleted$count")); |
| 242 | $val |= HIDDEN if($r->param("hideme$count")); |
244 | $val |= HIDDEN if($r->param("hideme$count")); |
| 243 | push @found, [$r->param("filetrial$count"), $val]; |
245 | push @found, [$r->param("filetrial$count"), $val]; |
| 244 | $count++; |
246 | $count++; |
| 245 | } |
247 | } |
| 246 | return(\@found); |
248 | return(\@found); |
| … | |
… | |
| 264 | $file = $selected->[0]; |
266 | $file = $selected->[0]; |
| 265 | my $problemRecord = $self->addProblemToSet(setName => $setName, |
267 | my $problemRecord = $self->addProblemToSet(setName => $setName, |
| 266 | sourceFile => $file, problemID => $freeProblemID); |
268 | sourceFile => $file, problemID => $freeProblemID); |
| 267 | $freeProblemID++; |
269 | $freeProblemID++; |
| 268 | $self->assignProblemToAllSetUsers($problemRecord); |
270 | $self->assignProblemToAllSetUsers($problemRecord); |
|
|
271 | $selected->[1] |= SUCCESS; |
|
|
272 | $addedcount++; |
|
|
273 | } |
|
|
274 | if($selected->[1] & DELETED) { |
|
|
275 | foreach my $problem ($db->listGlobalProblems($setName)) { |
|
|
276 | my $problemRecord = $db->getGlobalProblem($setName, $problem); |
|
|
277 | if($problemRecord->source_file eq $selected->[0]){ |
|
|
278 | $db->deleteGlobalProblem($setName, $problemRecord->problem_id); |
|
|
279 | } |
|
|
280 | } |
|
|
281 | print "it worked!"; |
| 269 | $selected->[1] |= SUCCESS; |
282 | $selected->[1] |= SUCCESS; |
| 270 | $addedcount++; |
283 | $addedcount++; |
| 271 | } |
284 | } |
| 272 | } |
285 | } |
| 273 | return($addedcount); |
286 | return($addedcount); |
| … | |
… | |
| 355 | # make labels without the $lib prefix -- reduces the width of the popup menu |
368 | # make labels without the $lib prefix -- reduces the width of the popup menu |
| 356 | if (length($lib)) { |
369 | if (length($lib)) { |
| 357 | my %labels = map { my($l)=$_=~/^$lib\/(.*)$/;$_=>$l } @$list_of_prob_dirs; |
370 | my %labels = map { my($l)=$_=~/^$lib\/(.*)$/;$_=>$l } @$list_of_prob_dirs; |
| 358 | push @popup_menu_args, -labels => \%labels; |
371 | push @popup_menu_args, -labels => \%labels; |
| 359 | } |
372 | } |
| 360 | print CGI::Tr({}, CGI::td({-class=>"InfoPanel", -align=>"left"}, "$name Problems: ", |
373 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "$name Problems: ", |
| 361 | CGI::popup_menu(@popup_menu_args), |
374 | CGI::popup_menu(@popup_menu_args), |
| 362 | CGI::br(), |
375 | CGI::br(), |
| 363 | $view_problem_line, |
376 | $view_problem_line, |
| 364 | )); |
377 | ); |
| 365 | } |
378 | } |
| 366 | |
379 | |
| 367 | ##### Version 2 is local homework sets |
380 | ##### Version 2 is local homework sets |
| 368 | sub browse_mysets_panel { |
381 | sub browse_mysets_panel { |
| 369 | my $self = shift; |
382 | my $self = shift; |
| … | |
… | |
| 378 | unshift @{$list_of_local_sets}, $default_value; |
391 | unshift @{$list_of_local_sets}, $default_value; |
| 379 | $library_selected = $default_value; |
392 | $library_selected = $default_value; |
| 380 | } |
393 | } |
| 381 | |
394 | |
| 382 | #my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r); |
395 | #my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r); |
| 383 | print CGI::Tr({}, |
|
|
| 384 | CGI::td({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", |
396 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 385 | CGI::popup_menu(-name=> 'myset_sets', |
397 | CGI::popup_menu(-name=> 'myset_sets', |
| 386 | -values=>$list_of_local_sets, |
398 | -values=>$list_of_local_sets, |
| 387 | -default=> $library_selected), |
399 | -default=> $library_selected), |
| 388 | CGI::hidden(-name=> 'local_sets', -value=>$remember_local_set), |
400 | CGI::hidden(-name=> 'local_sets', -value=>$remember_local_set), |
| 389 | CGI::br(), |
401 | CGI::br(), |
| 390 | CGI::submit(-name=>"view_mysets_set", -value=>"View Problems") |
402 | CGI::submit(-name=>"view_mysets_set", -value=>"View Set") |
| 391 | )); |
403 | ); |
| 392 | } |
404 | } |
| 393 | |
405 | |
| 394 | ##### Version 3 is the problem library |
406 | ##### Version 3 is the problem library |
| 395 | # |
407 | # |
| 396 | # This comes in 3 forms, problem library version 1, and for version 2 there |
408 | # This comes in 3 forms, problem library version 1, and for version 2 there |
| … | |
… | |
| 404 | |
416 | |
| 405 | # See if the problem library is installed |
417 | # See if the problem library is installed |
| 406 | my $libraryRoot = $r->{ce}->{problemLibrary}->{root}; |
418 | my $libraryRoot = $r->{ce}->{problemLibrary}->{root}; |
| 407 | |
419 | |
| 408 | unless($libraryRoot) { |
420 | unless($libraryRoot) { |
| 409 | print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, |
421 | print CGI::div({class=>'ResultsWithError', align=>"center"}, |
| 410 | "The problem library has not been installed."))); |
422 | "The problem library has not been installed."); |
| 411 | return; |
423 | return; |
| 412 | } |
424 | } |
| 413 | # Test if the Library directory link exists. If not, try to make it |
425 | # Test if the Library directory link exists. If not, try to make it |
| 414 | unless(-d "$ce->{courseDirs}->{templates}/Library") { |
426 | unless(-d "$ce->{courseDirs}->{templates}/Library") { |
| 415 | unless(symlink($libraryRoot, "$ce->{courseDirs}->{templates}/Library")) { |
427 | unless(symlink($libraryRoot, "$ce->{courseDirs}->{templates}/Library")) { |
| … | |
… | |
| 430 | return $self->browse_library_panel1; |
442 | return $self->browse_library_panel1; |
| 431 | } elsif($libraryVersion == 2) { |
443 | } elsif($libraryVersion == 2) { |
| 432 | return $self->browse_library_panel2 if($self->{library_basic}==1); |
444 | return $self->browse_library_panel2 if($self->{library_basic}==1); |
| 433 | return $self->browse_library_panel2adv; |
445 | return $self->browse_library_panel2adv; |
| 434 | } else { |
446 | } else { |
| 435 | print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, |
447 | print CGI::div({class=>'ResultsWithError', align=>"center"}, |
| 436 | "The problem library version is set to an illegal value."))); |
448 | "The problem library version is set to an illegal value."); |
| 437 | return; |
449 | return; |
| 438 | } |
450 | } |
| 439 | } |
451 | } |
| 440 | |
452 | |
| 441 | sub browse_library_panel1 { |
453 | sub browse_library_panel1 { |
| … | |
… | |
| 455 | unshift @sects, ALL_SECTIONS; |
467 | unshift @sects, ALL_SECTIONS; |
| 456 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
468 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
| 457 | |
469 | |
| 458 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); |
470 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); |
| 459 | |
471 | |
| 460 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, |
472 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 461 | CGI::start_table(), |
|
|
| 462 | CGI::Tr({}, |
|
|
| 463 | CGI::td(["Chapter:", |
473 | CGI::div(["Chapter:", |
| 464 | CGI::popup_menu(-name=> 'library_chapters', |
474 | CGI::popup_menu(-name=> 'library_chapters', |
| 465 | -values=>\@chaps, |
475 | -values=>\@chaps, |
| 466 | -default=> $chapter_selected, |
476 | -default=> $chapter_selected, |
| 467 | -onchange=>"submit();return true" |
477 | -onchange=>"submit();return true" |
| 468 | ), |
478 | ), |
| 469 | CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")])), |
479 | CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")]), |
| 470 | CGI::Tr({}, |
|
|
| 471 | CGI::td("Section:"), |
480 | CGI::div("Section:", |
| 472 | CGI::td({-colspan=>2}, |
|
|
| 473 | CGI::popup_menu(-name=> 'library_sections', |
481 | CGI::popup_menu(-name=> 'library_sections', |
| 474 | -values=>\@sects, |
482 | -values=>\@sects, |
| 475 | -default=> $section_selected |
483 | -default=> $section_selected |
| 476 | ))), |
484 | )), |
| 477 | |
485 | CGI::div($view_problem_line) |
| 478 | CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), |
|
|
| 479 | CGI::end_table(), |
|
|
| 480 | )); |
486 | ); |
| 481 | } |
487 | } |
| 482 | |
488 | |
| 483 | sub browse_library_panel2 { |
489 | sub browse_library_panel2 { |
| 484 | my $self = shift; |
490 | my $self = shift; |
| 485 | my $r = $self->r; |
491 | my $r = $self->r; |
| … | |
… | |
| 506 | $count_line = "There are no matching pg files"; |
512 | $count_line = "There are no matching pg files"; |
| 507 | } else { |
513 | } else { |
| 508 | $count_line = "There are $count_line matching WeBWorK problem files"; |
514 | $count_line = "There are $count_line matching WeBWorK problem files"; |
| 509 | } |
515 | } |
| 510 | |
516 | |
| 511 | print CGI::Tr({}, |
|
|
| 512 | CGI::td({-class=>"InfoPanel", -align=>"left"}, |
517 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 513 | CGI::hidden(-name=>"library_is_basic", -default=>1,-override=>1), |
518 | CGI::hidden(-name=>"library_is_basic", -default=>1,-override=>1), |
| 514 | CGI::start_table({-width=>"100%"}), |
|
|
| 515 | CGI::Tr({}, |
|
|
| 516 | CGI::td(["Subject:", |
519 | CGI::div(["Subject:", |
| 517 | CGI::popup_menu(-name=> 'library_subjects', |
520 | CGI::popup_menu(-name=> 'library_subjects', |
| 518 | -values=>\@subjs, |
521 | -values=>\@subjs, |
| 519 | -default=> $subject_selected, |
522 | -default=> $subject_selected, |
| 520 | -onchange=>"submit();return true" |
523 | -onchange=>"submit();return true" |
| 521 | )]), |
524 | )]), |
| 522 | CGI::td({-colspan=>2, -align=>"right"}, |
525 | CGI::div({-colspan=>2, -align=>"right"}, |
| 523 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")) |
526 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")), |
| 524 | ), |
|
|
| 525 | CGI::Tr({}, |
|
|
| 526 | CGI::td(["Chapter:", |
527 | CGI::div(["Chapter:", |
| 527 | CGI::popup_menu(-name=> 'library_chapters', |
528 | CGI::popup_menu(-name=> 'library_chapters', |
| 528 | -values=>\@chaps, |
529 | -values=>\@chaps, |
| 529 | -default=> $chapter_selected, |
530 | -default=> $chapter_selected, |
| 530 | -onchange=>"submit();return true" |
531 | -onchange=>"submit();return true" |
| 531 | )]), |
532 | )]), |
| 532 | CGI::td({-colspan=>2, -align=>"right"}, |
533 | CGI::div({-colspan=>2, -align=>"right"}, |
| 533 | CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")) |
534 | CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")), |
| 534 | ), |
|
|
| 535 | CGI::Tr({}, |
|
|
| 536 | CGI::td(["Section:", |
535 | CGI::div(["Section:", |
| 537 | CGI::popup_menu(-name=> 'library_sections', |
536 | CGI::popup_menu(-name=> 'library_sections', |
| 538 | -values=>\@sects, |
537 | -values=>\@sects, |
| 539 | -default=> $section_selected, |
538 | -default=> $section_selected, |
| 540 | -onchange=>"submit();return true" |
539 | -onchange=>"submit();return true" |
| 541 | )]), |
540 | )]), |
| 542 | ), |
|
|
| 543 | CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), |
541 | CGI::div({-colspan=>3}, $view_problem_line), |
| 544 | CGI::Tr(CGI::td({-colspan=>3, -align=>"center"}, $count_line)), |
542 | CGI::div({-colspan=>3, -align=>"center"}, $count_line) |
| 545 | CGI::end_table(), |
|
|
| 546 | )); |
543 | ); |
| 547 | |
544 | |
| 548 | } |
545 | } |
| 549 | |
546 | |
| 550 | sub browse_library_panel2adv { |
547 | sub browse_library_panel2adv { |
| 551 | my $self = shift; |
548 | my $self = shift; |
| … | |
… | |
| 618 | $count_line = "There are no matching pg files"; |
615 | $count_line = "There are no matching pg files"; |
| 619 | } else { |
616 | } else { |
| 620 | $count_line = "There are $count_line matching WeBWorK problem files"; |
617 | $count_line = "There are $count_line matching WeBWorK problem files"; |
| 621 | } |
618 | } |
| 622 | |
619 | |
| 623 | print CGI::Tr({}, |
|
|
| 624 | CGI::td({-class=>"InfoPanel", -align=>"left"}, |
620 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 625 | CGI::hidden(-name=>"library_is_basic", -default=>2,-override=>1), |
621 | CGI::hidden(-name=>"library_is_basic", -default=>2,-override=>1), |
| 626 | CGI::start_table({-width=>"100%"}), |
|
|
| 627 | # Html done by hand since it is temporary |
622 | # Html done by hand since it is temporary |
| 628 | CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')), |
623 | CGI::div({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"'), |
| 629 | CGI::Tr({}, |
|
|
| 630 | CGI::td(["Subject:", |
624 | CGI::div(["Subject:", |
| 631 | CGI::popup_menu(-name=> 'library_subjects', |
625 | CGI::popup_menu(-name=> 'library_subjects', |
| 632 | -values=>\@subjs, |
626 | -values=>\@subjs, |
| 633 | -default=> $selected{dbsubject}, |
627 | -default=> $selected{dbsubject}, |
| 634 | -onchange=>"submit();return true" |
628 | -onchange=>"submit();return true" |
| 635 | )]), |
629 | )]), |
| 636 | CGI::td({-colspan=>2, -align=>"right"}, |
630 | CGI::div({-colspan=>2, -align=>"right"}, |
| 637 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", |
631 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", |
| 638 | -style=> $right_button_style))), |
632 | -style=> $right_button_style)), |
| 639 | CGI::Tr({}, |
|
|
| 640 | CGI::td(["Chapter:", |
633 | CGI::div(["Chapter:", |
| 641 | CGI::popup_menu(-name=> 'library_chapters', |
634 | CGI::popup_menu(-name=> 'library_chapters', |
| 642 | -values=>\@chaps, |
635 | -values=>\@chaps, |
| 643 | -default=> $selected{dbchapter}, |
636 | -default=> $selected{dbchapter}, |
| 644 | -onchange=>"submit();return true" |
637 | -onchange=>"submit();return true" |
| 645 | )]), |
638 | )]), |
| 646 | CGI::td({-colspan=>2, -align=>"right"}, |
639 | CGI::div({-colspan=>2, -align=>"right"}, |
| 647 | CGI::submit(-name=>"library_reset", -value=>"Reset", |
640 | CGI::submit(-name=>"library_reset", -value=>"Reset", |
| 648 | -style=>$right_button_style)) |
641 | -style=>$right_button_style)), |
| 649 | ), |
|
|
| 650 | CGI::Tr({}, |
|
|
| 651 | CGI::td(["Section:", |
642 | CGI::div(["Section:", |
| 652 | CGI::popup_menu(-name=> 'library_sections', |
643 | CGI::popup_menu(-name=> 'library_sections', |
| 653 | -values=>\@sects, |
644 | -values=>\@sects, |
| 654 | -default=> $selected{dbsection}, |
645 | -default=> $selected{dbsection}, |
| 655 | -onchange=>"submit();return true" |
646 | -onchange=>"submit();return true" |
| 656 | )]), |
647 | )]), |
| 657 | CGI::td({-colspan=>2, -align=>"right"}, |
648 | CGI::div({-colspan=>2, -align=>"right"}, |
| 658 | CGI::submit(-name=>"library_basic", -value=>"Basic Search", |
649 | CGI::submit(-name=>"library_basic", -value=>"Basic Search", |
| 659 | -style=>$right_button_style)) |
650 | -style=>$right_button_style)), |
| 660 | ), |
|
|
| 661 | CGI::Tr({}, |
|
|
| 662 | CGI::td(["Textbook:", $text_popup]), |
651 | CGI::div(["Textbook:", $text_popup]), |
| 663 | ), |
|
|
| 664 | CGI::Tr({}, |
|
|
| 665 | CGI::td(["Text chapter:", |
652 | CGI::div(["Text chapter:", |
| 666 | CGI::popup_menu(-name=> 'library_textchapter', |
653 | CGI::popup_menu(-name=> 'library_textchapter', |
| 667 | -values=>\@textchaps, |
654 | -values=>\@textchaps, |
| 668 | -default=> $selected{textchapter}, |
655 | -default=> $selected{textchapter}, |
| 669 | -onchange=>"submit();return true" |
656 | -onchange=>"submit();return true" |
| 670 | )]), |
657 | )]), |
| 671 | ), |
|
|
| 672 | CGI::Tr({}, |
|
|
| 673 | CGI::td(["Text section:", |
658 | CGI::div(["Text section:", |
| 674 | CGI::popup_menu(-name=> 'library_textsection', |
659 | CGI::popup_menu(-name=> 'library_textsection', |
| 675 | -values=>\@textsecs, |
660 | -values=>\@textsecs, |
| 676 | -default=> $selected{textsection}, |
661 | -default=> $selected{textsection}, |
| 677 | -onchange=>"submit();return true" |
662 | -onchange=>"submit();return true" |
| 678 | )]), |
663 | )]), |
| 679 | ), |
|
|
| 680 | CGI::Tr({}, |
|
|
| 681 | CGI::td("Keywords:"),CGI::td({-colspan=>2}, |
664 | CGI::div("Keywords:"),CGI::div({-colspan=>2}, |
| 682 | CGI::textfield(-name=>"library_keywords", |
665 | CGI::textfield(-name=>"library_keywords", |
| 683 | -default=>$library_keywords, |
666 | -default=>$library_keywords, |
| 684 | -override=>1, |
667 | -override=>1, |
| 685 | -size=>40))), |
668 | -size=>40)), |
| 686 | CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), |
669 | CGI::div({-colspan=>3}, $view_problem_line), |
| 687 | CGI::Tr(CGI::td({-colspan=>3, -align=>"center"}, $count_line)), |
670 | CGI::div({-colspan=>3, -align=>"center"}, $count_line) |
| 688 | CGI::end_table(), |
|
|
| 689 | )); |
671 | ); |
| 690 | |
672 | |
| 691 | } |
673 | } |
| 692 | |
674 | |
| 693 | |
675 | |
| 694 | ##### Version 4 is the set definition file panel |
676 | ##### Version 4 is the set definition file panel |
| … | |
… | |
| 716 | -default=> $library_selected). |
698 | -default=> $library_selected). |
| 717 | CGI::br(). $view_problem_line; |
699 | CGI::br(). $view_problem_line; |
| 718 | if($list_of_set_defs[0] eq NO_LOCAL_SET_STRING) { |
700 | if($list_of_set_defs[0] eq NO_LOCAL_SET_STRING) { |
| 719 | $popupetc = "there are no set definition files in this course to look at." |
701 | $popupetc = "there are no set definition files in this course to look at." |
| 720 | } |
702 | } |
| 721 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", |
703 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", |
| 722 | $popupetc |
704 | $popupetc |
| 723 | )); |
705 | ); |
| 724 | } |
706 | } |
| 725 | |
707 | |
| 726 | sub make_mysets_row { |
708 | sub make_mysets_row { |
| 727 | my $self = shift; |
709 | my $self = shift; |
| 728 | my $r = $self->r; |
710 | my $r = $self->r; |
| … | |
… | |
| 759 | # Tidy this list up since it is used in two different places |
741 | # Tidy this list up since it is used in two different places |
| 760 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
742 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
| 761 | shift @{$list_of_local_sets}; |
743 | shift @{$list_of_local_sets}; |
| 762 | } |
744 | } |
| 763 | |
745 | |
| 764 | #print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
746 | #print CGI::div(CGI::div({-bgcolor=>"black"})); |
| 765 | #print CGI::hr(); |
747 | #print CGI::hr(); |
| 766 | |
748 | |
| 767 | $self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); |
749 | $self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); |
| 768 | } |
750 | } |
| 769 | |
751 | |
| … | |
… | |
| 802 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
784 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
| 803 | $set_selected = SELECT_SET_STRING; |
785 | $set_selected = SELECT_SET_STRING; |
| 804 | } |
786 | } |
| 805 | my $myjs = 'document.mainform.selfassign.value=confirm("Should I assign the new set to you now?\nUse OK for yes and Cancel for no.");true;'; |
787 | my $myjs = 'document.mainform.selfassign.value=confirm("Should I assign the new set to you now?\nUse OK for yes and Cancel for no.");true;'; |
| 806 | ## edited this, as a demo for the current set problem list |
788 | ## edited this, as a demo for the current set problem list |
| 807 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, |
789 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 808 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
790 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
| 809 | -onclick=>$myjs |
791 | -onclick=>$myjs |
| 810 | ), |
792 | ), |
| 811 | " ", |
793 | " ", |
| 812 | CGI::textfield(-name=>"new_set_name", |
794 | CGI::textfield(-name=>"new_set_name", |
| 813 | -default=>"Name for new set here", |
795 | -default=>"Name for new set here", |
| 814 | -override=>1, -size=>30), |
796 | -override=>1, -size=>30), |
| 815 | )); |
797 | ); |
| 816 | |
|
|
| 817 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
| 818 | |
798 | |
| 819 | # Tidy this list up since it is used in two different places |
799 | # Tidy this list up since it is used in two different places |
| 820 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
800 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
| 821 | shift @{$list_of_local_sets}; |
801 | shift @{$list_of_local_sets}; |
| 822 | } |
802 | } |
| 823 | |
803 | |
| 824 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, |
804 | print CGI::div({-class=>"InfoPanel", -align=>"center"}, |
| 825 | "Browse ", |
805 | "Browse ", |
| 826 | CGI::submit(-name=>"browse_npl_library", -value=>"National Problem Library", -style=>$these_widths, @dis1), |
806 | CGI::submit(-name=>"browse_npl_library", -value=>"National Problem Library", -style=>$these_widths, @dis1), |
| 827 | CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, @dis2), |
807 | CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, @dis2), |
| 828 | CGI::submit(-name=>"browse_setdefs", -value=>"Set Definition Files", -style=>$these_widths, @dis4), |
808 | CGI::submit(-name=>"browse_setdefs", -value=>"Set Definition Files", -style=>$these_widths, @dis4), |
| 829 | $libs, |
809 | $libs, |
| 830 | )); |
810 | ); |
| 831 | |
|
|
| 832 | #print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
| 833 | print CGI::hr(); |
|
|
| 834 | |
811 | |
| 835 | if ($browse_which eq 'browse_local') { |
812 | if ($browse_which eq 'browse_local') { |
| 836 | $self->browse_local_panel($library_selected); |
813 | $self->browse_local_panel($library_selected); |
| 837 | } elsif ($browse_which eq 'browse_mysets') { |
814 | } elsif ($browse_which eq 'browse_mysets') { |
| 838 | $self->browse_mysets_panel($library_selected, $list_of_local_sets); |
815 | $self->browse_mysets_panel($library_selected, $list_of_local_sets); |
| … | |
… | |
| 842 | $self->browse_setdef_panel($library_selected); |
819 | $self->browse_setdef_panel($library_selected); |
| 843 | } else { ## handle other problem libraries |
820 | } else { ## handle other problem libraries |
| 844 | $self->browse_local_panel($library_selected,$browse_which); |
821 | $self->browse_local_panel($library_selected,$browse_which); |
| 845 | } |
822 | } |
| 846 | |
823 | |
| 847 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
| 848 | |
|
|
| 849 | print CGI::Tr({}, |
|
|
| 850 | CGI::td({-class=>"InfoPanel", -align=>"center"}, |
824 | print CGI::div({-class=>"InfoPanel", -align=>"center"}, |
| 851 | CGI::start_table({-border=>"0"}), |
|
|
| 852 | CGI::Tr({}, CGI::td({ -align=>"center"}, |
|
|
| 853 | CGI::submit(-name=>"select_all", -style=>$these_widths, |
825 | CGI::submit(-name=>"select_all", -style=>$these_widths, |
| 854 | -value=>"Mark All For Adding"), |
826 | -value=>"Mark All For Adding"), |
| 855 | CGI::submit(-name=>"select_none", -style=>$these_widths, |
827 | CGI::submit(-name=>"select_none", -style=>$these_widths, |
| 856 | -value=>"Clear All Marks"), |
828 | -value=>"Clear All Marks"), |
| 857 | )), |
829 | ), |
| 858 | CGI::Tr({}, |
830 | CGI::div({}, |
| 859 | CGI::td({}, |
|
|
| 860 | CGI::submit(-name=>"update", -style=>$these_widths. "; font-weight:bold", |
831 | CGI::submit(-name=>"update", -style=>$these_widths. "; font-weight:bold", |
| 861 | -value=>"Update Set"), |
832 | -value=>"Update Set"), |
| 862 | CGI::submit(-name=>"rerandomize", |
833 | CGI::submit(-name=>"rerandomize", |
| 863 | -style=>$these_widths, |
834 | -style=>$these_widths, |
| 864 | -value=>"Rerandomize"), |
835 | -value=>"Rerandomize"), |
| 865 | CGI::submit(-name=>"cleardisplay", |
836 | CGI::submit(-name=>"cleardisplay", |
| 866 | -style=>$these_widths, |
837 | -style=>$these_widths, |
| 867 | -value=>"Clear Problem Display") |
838 | -value=>"Clear Problem Display") |
| 868 | )), |
839 | ); |
| 869 | CGI::end_table())); |
|
|
| 870 | } |
840 | } |
| 871 | |
841 | |
| 872 | sub make_data_row { |
842 | sub make_data_row { |
| 873 | my $self = shift; |
843 | my $self = shift; |
| 874 | my $sourceFileName = shift; |
844 | my $sourceFileName = shift; |
| … | |
… | |
| 935 | $add_box_data{ -checked } = 1; |
905 | $add_box_data{ -checked } = 1; |
| 936 | } |
906 | } |
| 937 | |
907 | |
| 938 | if(!($self->{isInSet}{$sourceFileName})){ |
908 | if(!($self->{isInSet}{$sourceFileName})){ |
| 939 | |
909 | |
| 940 | print CGI::Tr({-align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, CGI::td( |
910 | print CGI::div({-align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, |
| 941 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
911 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
| 942 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
912 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
| 943 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
913 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
| 944 | ), CGI::br(), |
914 | ), CGI::br(), |
| 945 | CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1), |
915 | CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1), |
| 946 | CGI::br(), |
916 | CGI::br(), |
| 947 | CGI::checkbox((%add_box_data),-override=>1), |
917 | CGI::checkbox((%add_box_data),-override=>1), |
| 948 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
918 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
| 949 | CGI::p($problem_output), |
919 | CGI::p($problem_output), |
| 950 | )); |
920 | ); |
| 951 | } |
921 | } |
| 952 | } |
922 | } |
| 953 | |
923 | |
| 954 | sub make_myset_data_row { |
924 | sub make_myset_data_row { |
| 955 | my $self = shift; |
925 | my $self = shift; |
| … | |
… | |
| 987 | courseID =>$urlpath->arg("courseID"), |
957 | courseID =>$urlpath->arg("courseID"), |
| 988 | setID=>"Undefined_Set", |
958 | setID=>"Undefined_Set", |
| 989 | problemID=>"1"), |
959 | problemID=>"1"), |
| 990 | params=>{sourceFilePath => "$sourceFileName", problemSeed=> $problem_seed} |
960 | params=>{sourceFilePath => "$sourceFileName", problemSeed=> $problem_seed} |
| 991 | ), target=>"WW_Editor"}, "Edit it" ); |
961 | ), target=>"WW_Editor"}, "Edit it" ); |
|
|
962 | |
|
|
963 | my %delete_box_data = ( -id=>"deleted$cnt".'myset' ,-name=>"deleted$cnt",-value=>1,-label=>"Delete this problem from the target set on the next update"); |
| 992 | |
964 | |
| 993 | my $displayMode = $self->r->param("mydisplayMode"); |
965 | my $displayMode = $self->r->param("mydisplayMode"); |
| 994 | $displayMode = $self->r->ce->{pg}->{options}->{displayMode} |
966 | $displayMode = $self->r->ce->{pg}->{options}->{displayMode} |
| 995 | if not defined $displayMode or $displayMode eq "None"; |
967 | if not defined $displayMode or $displayMode eq "None"; |
| 996 | my $module = ( $isGatewaySet ) ? "GatewayQuiz" : "Problem"; |
968 | my $module = ( $isGatewaySet ) ? "GatewayQuiz" : "Problem"; |
| … | |
… | |
| 1008 | sourceFilePath => "$sourceFileName", |
980 | sourceFilePath => "$sourceFileName", |
| 1009 | displayMode => $displayMode, |
981 | displayMode => $displayMode, |
| 1010 | } |
982 | } |
| 1011 | ), target=>"WW_View"}, "Try it"); |
983 | ), target=>"WW_View"}, "Try it"); |
| 1012 | |
984 | |
| 1013 | print CGI::Tr({-align=>"left"}, CGI::td({-draggable=>"true", -href=>"#", -id=>("$cnt".'myset')}, |
985 | print CGI::div({-class=>"problem myProblem", -draggable=>"true", -href=>"#", -id=>("$cnt".'myset')}, |
| 1014 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
986 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
| 1015 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
987 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
| 1016 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
988 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
| 1017 | ), CGI::br(), |
989 | ), CGI::br(), |
| 1018 | CGI::br(), |
990 | CGI::br(), |
|
|
991 | CGI::checkbox((%delete_box_data),-override=>1), |
| 1019 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
992 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
| 1020 | CGI::p($problem_output), |
993 | CGI::p($problem_output), |
| 1021 | )); |
994 | ); |
| 1022 | } |
995 | } |
| 1023 | |
996 | |
| 1024 | sub clear_default { |
997 | sub clear_default { |
| 1025 | my $r = shift; |
998 | my $r = shift; |
| 1026 | my $param = shift; |
999 | my $param = shift; |
| … | |
… | |
| 1264 | |
1237 | |
| 1265 | } elsif ($r->param('update')) { |
1238 | } elsif ($r->param('update')) { |
| 1266 | ## first handle problems to be added before we hide them |
1239 | ## first handle problems to be added before we hide them |
| 1267 | my($localSet, @selected); |
1240 | my($localSet, @selected); |
| 1268 | |
1241 | |
| 1269 | @pg_files = grep {($_->[1] & ADDED) != 0 } @{$self->{past_problems}}; |
1242 | @pg_files = grep {(($_->[1] & ADDED) || ($_->[1] & DELETED)) != 0 } @{$self->{past_problems}}; |
| 1270 | @selected = map {$_->[0]} @pg_files; |
1243 | @selected = map {$_->[0]} @pg_files; |
| 1271 | |
1244 | |
| 1272 | my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; |
1245 | my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; |
| 1273 | # There are now good reasons to do an update without selecting anything. |
1246 | # There are now good reasons to do an update without selecting anything. |
| 1274 | #if(scalar(@action_files) == 0) { |
1247 | #if(scalar(@action_files) == 0) { |
| … | |
… | |
| 1484 | my $problemRecord = $db->getGlobalProblem($setName, $problem); |
1457 | my $problemRecord = $db->getGlobalProblem($setName, $problem); |
| 1485 | $isInSet{$problemRecord->source_file} = 1; |
1458 | $isInSet{$problemRecord->source_file} = 1; |
| 1486 | } |
1459 | } |
| 1487 | } |
1460 | } |
| 1488 | $self->{isInSet} = \%isInSet; |
1461 | $self->{isInSet} = \%isInSet; |
| 1489 | |
1462 | my $jj; |
| 1490 | ########## Top part |
1463 | ########## Top part |
|
|
1464 | print '<div id="editor-form">'; |
|
|
1465 | |
| 1491 | print CGI::start_form({-method=>"POST", -action=>$r->uri, -name=>'mainform'}), |
1466 | print CGI::start_form({-method=>"POST", -action=>$r->uri, -name=>'mainform'}), |
| 1492 | $self->hidden_authen_fields, |
1467 | $self->hidden_authen_fields; |
|
|
1468 | print '<div id="mysets">'; |
|
|
1469 | ######### Table of mysets problems |
|
|
1470 | $self->make_mysets_row('all_db_sets'=>\@all_db_sets); |
|
|
1471 | for ($jj=0; $jj<scalar(@myset_html); $jj++) { |
|
|
1472 | $myset_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
|
|
1473 | $self->make_myset_data_row($myset_files[$jj+$first_shown], $myset_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
|
|
1474 | } |
|
|
1475 | #print CGI::end_table(); |
|
|
1476 | print '</div>'; |
|
|
1477 | |
| 1493 | '<div id="setmaker_library">', |
1478 | print '<div id="setmaker_library">'; |
| 1494 | CGI::start_table({-id=>'setmaker_table', -border=>2}); |
1479 | #CGI::start_table({-id=>'setmaker_table', -border=>2}); |
| 1495 | $self->make_top_row('all_db_sets'=>\@all_db_sets, |
1480 | $self->make_top_row('all_db_sets'=>\@all_db_sets, |
| 1496 | 'browse_which'=> $browse_which); |
1481 | 'browse_which'=> $browse_which); |
| 1497 | |
1482 | |
| 1498 | print CGI::hidden(-name=>'browse_which', -value=>$browse_which,-override=>1), |
1483 | print CGI::hidden(-name=>'browse_which', -value=>$browse_which,-override=>1), |
| 1499 | CGI::hidden(-name=>'problem_seed', -value=>$problem_seed, -override=>1); |
1484 | CGI::hidden(-name=>'problem_seed', -value=>$problem_seed, -override=>1); |
| … | |
… | |
| 1505 | |
1490 | |
| 1506 | print CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1); |
1491 | print CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1); |
| 1507 | |
1492 | |
| 1508 | |
1493 | |
| 1509 | ########## Now print problems |
1494 | ########## Now print problems |
| 1510 | my $jj; |
|
|
| 1511 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
1495 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
| 1512 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
1496 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
| 1513 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
1497 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
| 1514 | #$self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj+$first_shown]); #MEG |
1498 | #$self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj+$first_shown]); #MEG |
| 1515 | } |
1499 | } |
| 1516 | |
1500 | |
| 1517 | ########## Finish things off |
1501 | ########## Finish things off |
| 1518 | print CGI::end_table(); |
1502 | #print CGI::end_table(); |
| 1519 | my ($next_button, $prev_button) = ("", ""); |
1503 | my ($next_button, $prev_button) = ("", ""); |
| 1520 | if ($first_shown > 0) { |
1504 | if ($first_shown > 0) { |
| 1521 | $prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", |
1505 | $prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", |
| 1522 | -value=>"Previous page"); |
1506 | -value=>"Previous page"); |
| 1523 | } |
1507 | } |
| … | |
… | |
| 1529 | print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files). |
1513 | print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files). |
| 1530 | " shown.", $prev_button, " ", $next_button, |
1514 | " shown.", $prev_button, " ", $next_button, |
| 1531 | CGI::submit(-name=>"update", -style=>"width:15ex; font-weight:bold", |
1515 | CGI::submit(-name=>"update", -style=>"width:15ex; font-weight:bold", |
| 1532 | -value=>"Update Set")); |
1516 | -value=>"Update Set")); |
| 1533 | } |
1517 | } |
| 1534 | |
1518 | #close library_set |
| 1535 | print '</div>'; |
1519 | print '</div>'; |
| 1536 | |
1520 | #close form-editor |
| 1537 | print '<div id="mysets">'; |
|
|
| 1538 | ######### Table of mysets problems |
|
|
| 1539 | print CGI::start_table({-id=>'mysets_table' ,-border=>2}); |
|
|
| 1540 | print CGI::hr(); |
|
|
| 1541 | $self->make_mysets_row('all_db_sets'=>\@all_db_sets); |
|
|
| 1542 | for ($jj=0; $jj<scalar(@myset_html); $jj++) { |
|
|
| 1543 | $myset_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
|
|
| 1544 | $self->make_myset_data_row($myset_files[$jj+$first_shown], $myset_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
|
|
| 1545 | } |
|
|
| 1546 | print CGI::end_table(); |
|
|
| 1547 | print '</div>'; |
1521 | print '</div>'; |
| 1548 | |
1522 | |
|
|
1523 | print '<div style="clear:both;"></div>'; |
| 1549 | |
1524 | |
| 1550 | |
1525 | |
| 1551 | # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { |
1526 | # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { |
| 1552 | |
1527 | |
| 1553 | # } |
1528 | # } |