| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright � 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.85 2008/07/01 13:18:52 glarose Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.85 2008/07/01 13:18:52 glarose 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 |
| … | |
… | |
| 79 | |
79 | |
| 80 | sub prepare_activity_entry { |
80 | sub prepare_activity_entry { |
| 81 | my $self=shift; |
81 | my $self=shift; |
| 82 | my $r = $self->r; |
82 | my $r = $self->r; |
| 83 | my $user = $self->r->param('user') || 'NO_USER'; |
83 | my $user = $self->r->param('user') || 'NO_USER'; |
| 84 | return("In SetMaker as user $user"); |
84 | return("In SetMaker2 as user $user"); |
| 85 | } |
85 | } |
| 86 | |
86 | |
| 87 | ## This is for searching the disk for directories containing pg files. |
87 | ## This is for searching the disk for directories containing pg files. |
| 88 | ## to make the recursion work, this returns an array where the first |
88 | ## to make the recursion work, this returns an array where the first |
| 89 | ## item is the number of pg files in the directory. The second is a |
89 | ## item is the number of pg files in the directory. The second is a |
| … | |
… | |
| 311 | } |
311 | } |
| 312 | } |
312 | } |
| 313 | return($deletedcount); |
313 | return($deletedcount); |
| 314 | } |
314 | } |
| 315 | |
315 | |
|
|
316 | ##order the problems as they are after user reorder |
|
|
317 | sub reorderProblems { |
|
|
318 | my $self = shift; |
|
|
319 | my $db = shift; |
|
|
320 | my $setID = shift; |
|
|
321 | my $r = shift; |
|
|
322 | #my (@problemIDList) = @_; |
|
|
323 | #my ($prob1, $prob2, $prob); |
|
|
324 | my $index = 1; |
|
|
325 | #get all the problems |
|
|
326 | my @problems = (); |
|
|
327 | while (defined($r->param("reorder$index"))) { |
|
|
328 | #this will work if i can get problems by name |
|
|
329 | my $problemRecord; # checked |
|
|
330 | foreach my $problem ($db->listGlobalProblems($setID)) { |
|
|
331 | my $tempProblem = $db->getGlobalProblem($setID, $problem); |
|
|
332 | if($tempProblem->source_file eq $r->param("reorder$index")){ |
|
|
333 | $problemRecord = $tempProblem; |
|
|
334 | } |
|
|
335 | } |
|
|
336 | die "global " .$r->param("reorder$index") ." for set $setID not found." unless $problemRecord; |
|
|
337 | #print "found this problem to be reordered: ".$problemRecord."\n"; |
|
|
338 | push @problems, $problemRecord; |
|
|
339 | $index = $index + 1; |
|
|
340 | } |
|
|
341 | #then change their info |
|
|
342 | my @setUsers = $db->listSetUsers($setID); |
|
|
343 | my $user; |
|
|
344 | $index = 1; |
|
|
345 | foreach my $problem (@problems) { |
|
|
346 | $problem->problem_id($index); |
|
|
347 | die "global $problem not found." unless $problem; |
|
|
348 | #print "problem to be reordered: ".$problem."\n"; |
|
|
349 | $db->putGlobalProblem($problem); |
|
|
350 | |
|
|
351 | #need to deal with users? |
|
|
352 | foreach $user (@setUsers) { |
|
|
353 | my $prob1 = $db->getUserProblem($user, $setID, $index); #checked |
|
|
354 | die " problem $index for set $setID and effective user $user not found" unless $prob1; |
|
|
355 | $prob1->problem_id($index); |
|
|
356 | $db->putUserProblem($prob1); |
|
|
357 | } |
|
|
358 | $index = $index + 1; |
|
|
359 | } |
|
|
360 | } |
| 316 | |
361 | |
| 317 | ############# List of sets of problems in templates directory |
362 | ############# List of sets of problems in templates directory |
| 318 | |
363 | |
| 319 | sub get_problem_directories { |
364 | sub get_problem_directories { |
| 320 | my $ce = shift; |
365 | my $ce = shift; |
| … | |
… | |
| 336 | ############# Everyone has a view problems line. Abstract it |
381 | ############# Everyone has a view problems line. Abstract it |
| 337 | sub view_problems_line { |
382 | sub view_problems_line { |
| 338 | my $internal_name = shift; |
383 | my $internal_name = shift; |
| 339 | my $label = shift; |
384 | my $label = shift; |
| 340 | my $r = shift; # so we can get parameter values |
385 | my $r = shift; # so we can get parameter values |
| 341 | my $result = CGI::submit(-name=>"$internal_name", -value=>$label); |
386 | my $self = shift; |
| 342 | |
387 | my $urlpath = $r->urlpath; |
|
|
388 | my $getProblemPath = $self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::GetLibrarySetProblems", courseID =>$urlpath->arg("courseID"))); |
|
|
389 | my $result = "<span><button type='button' onclick='viewProblems(\"$internal_name\" ,\"mainform\", \"".$r->uri."\", \"view_problems_spinner\");'>$label</button><img id='view_problems_spinner' style='display:none;' src='/webwork2_files/images/ajax-loader-small.gif'></img></span>"; |
|
|
390 | #$result .= CGI::hidden(-name=>"$internal_name"); |
| 343 | my %display_modes = %{WeBWorK::PG::DISPLAY_MODES()}; |
391 | my %display_modes = %{WeBWorK::PG::DISPLAY_MODES()}; |
| 344 | my @active_modes = grep { exists $display_modes{$_} } |
392 | my @active_modes = grep { exists $display_modes{$_} } |
| 345 | @{$r->ce->{pg}->{displayModes}}; |
393 | @{$r->ce->{pg}->{displayModes}}; |
| 346 | push @active_modes, 'None'; |
394 | push @active_modes, 'None'; |
| 347 | # We have our own displayMode since its value may be None, which is illegal |
395 | # We have our own displayMode since its value may be None, which is illegal |
| … | |
… | |
| 384 | unshift @{$list_of_prob_dirs}, $default_value; |
432 | unshift @{$list_of_prob_dirs}, $default_value; |
| 385 | $library_selected = $default_value; |
433 | $library_selected = $default_value; |
| 386 | } |
434 | } |
| 387 | } |
435 | } |
| 388 | debug("library is $lib and sets are $library_selected"); |
436 | debug("library is $lib and sets are $library_selected"); |
| 389 | my $view_problem_line = view_problems_line('view_local_set', 'View Problems', $self->r); |
437 | my $view_problem_line = view_problems_line('view_local_set', 'View Problems', $self->r, $self); |
| 390 | my @popup_menu_args = ( |
438 | my @popup_menu_args = ( |
|
|
439 | -size => 4, |
| 391 | -name => 'library_sets', |
440 | -name => 'library_sets', |
| 392 | -values => $list_of_prob_dirs, |
441 | -values => $list_of_prob_dirs, |
| 393 | -default => $library_selected, |
442 | -default => $library_selected, |
| 394 | ); |
443 | ); |
| 395 | # make labels without the $lib prefix -- reduces the width of the popup menu |
444 | # make labels without the $lib prefix -- reduces the width of the popup menu |
| 396 | if (length($lib)) { |
445 | if (length($lib)) { |
| 397 | my %labels = map { my($l)=$_=~/^$lib\/(.*)$/;$_=>$l } @$list_of_prob_dirs; |
446 | my %labels = map { my($l)=$_=~/^$lib\/(.*)$/;$_=>$l } @$list_of_prob_dirs; |
| 398 | push @popup_menu_args, -labels => \%labels; |
447 | push @popup_menu_args, -labels => \%labels; |
| 399 | } |
448 | } |
| 400 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "$name Problems: ", |
449 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "<p style='margin-bottom:0'>$name Problems: </p>", |
| 401 | CGI::popup_menu(@popup_menu_args), |
450 | CGI::popup_menu(@popup_menu_args), |
| 402 | CGI::br(), |
451 | CGI::br(), |
| 403 | $view_problem_line, |
452 | $view_problem_line, |
| 404 | ); |
453 | ); |
| 405 | } |
454 | } |
| … | |
… | |
| 416 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
465 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| 417 | } elsif (not $library_selected or $library_selected eq $default_value) { |
466 | } elsif (not $library_selected or $library_selected eq $default_value) { |
| 418 | unshift @{$list_of_local_sets}, $default_value; |
467 | unshift @{$list_of_local_sets}, $default_value; |
| 419 | $library_selected = $default_value; |
468 | $library_selected = $default_value; |
| 420 | } |
469 | } |
| 421 | |
470 | |
| 422 | #my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r); |
471 | my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r, $self); |
|
|
472 | |
|
|
473 | my $urlpath = $self->r->urlpath; |
|
|
474 | my $getProblemPath = $self->r->uri;#$self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::GetTargetSetProblems", courseID =>$urlpath->arg("courseID"))); |
| 423 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
475 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 424 | CGI::submit(-name=>"update", -style=>"width: 25ex; font-weight:bold;", |
476 | #CGI::submit(-name=>"update", -style=>"width: 25ex; font-weight:bold;", -value=>"Update Set"), |
| 425 | -value=>"Update Set"), |
477 | '<span>', |
| 426 | CGI::popup_menu(-name=> 'myset_sets', |
478 | CGI::popup_menu(-id=> 'myset_sets', |
|
|
479 | -name=> 'myset_sets', |
|
|
480 | -size=>6, |
|
|
481 | -onchange=>"viewSet(\'mainform\', \'$getProblemPath\', \'view_set_spinner\');", |
| 427 | -values=>$list_of_local_sets, |
482 | -values=>$list_of_local_sets, |
| 428 | -default=> $library_selected), |
483 | -default=> $library_selected), |
|
|
484 | "<img id='view_set_spinner' style='display:none;' src='/webwork2_files/images/ajax-loader-small.gif'></img></span>", |
|
|
485 | "<button type='button' onclick='document.getElementById(\"create_new_set\").style.display = \"block\";'>+</button>", |
| 429 | CGI::hidden(-name=> 'local_sets', -value=>$remember_local_set), |
486 | CGI::hidden(-name=> 'local_sets', -value=>$remember_local_set), |
| 430 | CGI::br(), |
487 | CGI::br(), |
|
|
488 | "<span>", |
|
|
489 | #'<button type="button" onclick="viewSet(\'mainform\', \'/webwork2/myTestCourse/instructor/setmaker2/\');">View Set</button>', |
| 431 | CGI::submit(-name=>"view_mysets_set", -value=>"View Set"), |
490 | #CGI::submit(-name=>"view_mysets_set", -value=>"View Set"), |
|
|
491 | "<span id='problem_counter' style='float:right;'>0</span>", |
|
|
492 | "</span>" |
| 432 | ); |
493 | ); |
| 433 | } |
494 | } |
| 434 | |
495 | |
| 435 | ##### Version 2.1 is local homework sets |
496 | ##### Version 2.1 is local homework sets |
| 436 | sub edit_mysets_panel { |
497 | sub edit_mysets_panel { |
| … | |
… | |
| 444 | } elsif (not $library_selected or $library_selected eq $default_value) { |
505 | } elsif (not $library_selected or $library_selected eq $default_value) { |
| 445 | unshift @{$list_of_local_sets}, $default_value; |
506 | unshift @{$list_of_local_sets}, $default_value; |
| 446 | $library_selected = $default_value; |
507 | $library_selected = $default_value; |
| 447 | } |
508 | } |
| 448 | |
509 | |
| 449 | my $view_problem_line = view_problems_line('edit_mysets_set', 'View Problems', $self->r); |
510 | my $view_problem_line = view_problems_line('edit_mysets_set', 'View Problems', $self->r, $self); |
| 450 | print CGI::Tr({}, |
511 | print CGI::Tr({}, |
| 451 | CGI::td({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", |
512 | CGI::td({-class=>"InfoPanel", -align=>"left"}, "<p style='margin-bottom:0;'>Browse from:</p>", |
| 452 | CGI::popup_menu(-name=> 'library_sets', |
513 | CGI::popup_menu(-name=> 'library_sets', |
|
|
514 | -size=> 4, |
| 453 | -values=>$list_of_local_sets, |
515 | -values=>$list_of_local_sets, |
| 454 | -default=> $library_selected), |
516 | -default=> $library_selected), |
| 455 | CGI::br(), |
517 | CGI::br(), |
| 456 | $view_problem_line |
518 | $view_problem_line |
| 457 | )); |
519 | )); |
| … | |
… | |
| 519 | } |
581 | } |
| 520 | |
582 | |
| 521 | unshift @sects, ALL_SECTIONS; |
583 | unshift @sects, ALL_SECTIONS; |
| 522 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
584 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
| 523 | |
585 | |
| 524 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); |
586 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r, $self); |
| 525 | |
587 | |
| 526 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
588 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 527 | CGI::div(["Chapter:", |
589 | CGI::div(["Chapter:", |
| 528 | CGI::popup_menu(-name=> 'library_chapters', |
590 | CGI::popup_menu(-name=> 'library_chapters', |
|
|
591 | -size=>4, |
| 529 | -values=>\@chaps, |
592 | -values=>\@chaps, |
| 530 | -default=> $chapter_selected, |
593 | -default=> $chapter_selected, |
| 531 | -onchange=>"submit();return true" |
594 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\', \'null\',\'view_problems_spinner\')" |
| 532 | ), |
595 | ), |
| 533 | CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")]), |
596 | CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")]), |
| 534 | CGI::div("Section:", |
597 | CGI::div("Section:", |
| 535 | CGI::popup_menu(-name=> 'library_sections', |
598 | CGI::popup_menu(-name=> 'library_sections', |
| 536 | -values=>\@sects, |
599 | -values=>\@sects, |
| … | |
… | |
| 557 | |
620 | |
| 558 | my $subject_selected = $r->param('library_subjects') || LIB2_DATA->{dbsubject}{all}; |
621 | my $subject_selected = $r->param('library_subjects') || LIB2_DATA->{dbsubject}{all}; |
| 559 | my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}{all}; |
622 | my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}{all}; |
| 560 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
623 | my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; |
| 561 | |
624 | |
| 562 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); |
625 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r, $self); |
| 563 | |
626 | |
| 564 | my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); |
627 | my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); |
| 565 | if($count_line==0) { |
628 | if($count_line==0) { |
| 566 | $count_line = "There are no matching pg files"; |
629 | $count_line = "There are no matching pg files"; |
| 567 | } else { |
630 | } else { |
| 568 | $count_line = "There are $count_line matching WeBWorK problem files"; |
631 | $count_line = "There are $count_line matching WeBWorK problem files"; |
| 569 | } |
632 | } |
| 570 | |
633 | |
| 571 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
634 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, |
| 572 | CGI::hidden(-name=>"library_is_basic", -default=>1,-override=>1), |
635 | CGI::hidden(-name=>"library_is_basic", -default=>1,-override=>1), |
| 573 | CGI::div({-style=>"float:left;"},["Subject:", |
636 | CGI::div({-style=>"float:left;"},"<p style='margin-bottom:0'>Subject:</p>", |
| 574 | CGI::popup_menu(-name=> 'library_subjects', |
637 | CGI::popup_menu(-name=> 'library_subjects', |
|
|
638 | -size=>4, |
| 575 | -values=>\@subjs, |
639 | -values=>\@subjs, |
| 576 | -default=> $subject_selected, |
640 | -default=> $subject_selected, |
| 577 | -onchange=>"submit();return true;" |
641 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\', \'null\',\'view_problems_spinner\')" |
| 578 | )]), |
642 | )), |
| 579 | CGI::div({-style=>"float:left;"},["Chapter:", |
643 | CGI::div({-style=>"float:left;"},"<p style='margin-bottom:0'>Chapter:</p>", |
| 580 | CGI::popup_menu(-name=> 'library_chapters', |
644 | CGI::popup_menu(-name=> 'library_chapters', |
|
|
645 | -size=>4, |
| 581 | -values=>\@chaps, |
646 | -values=>\@chaps, |
| 582 | -default=> $chapter_selected, |
647 | -default=> $chapter_selected, |
| 583 | -onchange=>"submit();return true;" |
648 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\', \'null\',\'view_problems_spinner\')" |
| 584 | )]), |
649 | )), |
| 585 | CGI::div({-style=>"float:left;"},["Section:", |
650 | CGI::div({-style=>"float:left;"},"<p style='margin-bottom:0'>Section:</p>", |
| 586 | CGI::popup_menu(-name=> 'library_sections', |
651 | CGI::popup_menu(-name=> 'library_sections', |
|
|
652 | -size=>4, |
| 587 | -values=>\@sects, |
653 | -values=>\@sects, |
| 588 | -default=> $section_selected, |
654 | -default=> $section_selected, |
| 589 | -onchange=>"submit();return true" |
655 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\', \'null\',\'view_problems_spinner\')" |
| 590 | )]), |
656 | )), |
|
|
657 | '<div colspan=2 align="right">', |
|
|
658 | '<button type="button" onclick="updateLibCategories(\'mainform\', \''.$r->uri.'\', \'library_advanced\', \'view_problems_spinner\')">Advanced Search</button>', |
|
|
659 | '</div>', |
|
|
660 | '<div colspan=2 align="right">', |
|
|
661 | '<button type="button" onclick="updateLibCategories(\'mainform\', \''.$r->uri.'\', \'lib_select_subject\', \'view_problems_spinner\')">Update Chapter/Section Lists</button>', |
|
|
662 | '</div>', |
| 591 | CGI::div({-colspan=>2, -align=>"right"}, |
663 | #CGI::div({-colspan=>2, -align=>"right"}, |
| 592 | CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")), |
664 | # CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")), |
| 593 | CGI::div({-colspan=>2, -align=>"right"}, |
665 | #CGI::div({-colspan=>2, -align=>"right"}, |
| 594 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")), |
666 | # CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")), |
|
|
667 | '<div style="clear:both;"></div>', |
| 595 | CGI::div({-colspan=>3}, $view_problem_line), |
668 | CGI::div({-colspan=>3}, $view_problem_line), |
| 596 | CGI::div({-colspan=>3, -align=>"center"}, $count_line) |
669 | CGI::div({-colspan=>3, -align=>"center"}, $count_line) |
| 597 | ); |
670 | ); |
| 598 | |
671 | |
| 599 | } |
672 | } |
| … | |
… | |
| 652 | for my $j (qw( dbsection dbchapter dbsubject textbook textchapter textsection )) { |
725 | for my $j (qw( dbsection dbchapter dbsubject textbook textchapter textsection )) { |
| 653 | $selected{$j} = $r->param(LIB2_DATA->{$j}{name}) || LIB2_DATA->{$j}{all}; |
726 | $selected{$j} = $r->param(LIB2_DATA->{$j}{name}) || LIB2_DATA->{$j}{all}; |
| 654 | } |
727 | } |
| 655 | |
728 | |
| 656 | my $text_popup = CGI::popup_menu(-name => 'library_textbook', |
729 | my $text_popup = CGI::popup_menu(-name => 'library_textbook', |
|
|
730 | -size => 4, |
| 657 | -values =>\@textarray, |
731 | -values =>\@textarray, |
| 658 | -labels => \%textlabels, |
732 | -labels => \%textlabels, |
| 659 | -default=>$selected{textbook}, |
733 | -default=>$selected{textbook}, |
| 660 | -onchange=>"submit();return true"); |
734 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\', \'null\',\'view_problems_spinner\')"); |
| 661 | |
735 | |
| 662 | |
736 | |
| 663 | my $library_keywords = $r->param('library_keywords') || ''; |
737 | my $library_keywords = $r->param('library_keywords') || ''; |
| 664 | |
738 | |
| 665 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); |
739 | my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r, $self); |
| 666 | |
740 | |
| 667 | my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); |
741 | my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); |
| 668 | if($count_line==0) { |
742 | if($count_line==0) { |
| 669 | $count_line = "There are no matching pg files"; |
743 | $count_line = "There are no matching pg files"; |
| 670 | } else { |
744 | } else { |
| … | |
… | |
| 675 | CGI::hidden(-name=>"library_is_basic", -default=>2,-override=>1), |
749 | CGI::hidden(-name=>"library_is_basic", -default=>2,-override=>1), |
| 676 | # Html done by hand since it is temporary |
750 | # Html done by hand since it is temporary |
| 677 | CGI::div({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"'), |
751 | CGI::div({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"'), |
| 678 | CGI::div(["Subject:", |
752 | CGI::div(["Subject:", |
| 679 | CGI::popup_menu(-name=> 'library_subjects', |
753 | CGI::popup_menu(-name=> 'library_subjects', |
|
|
754 | -size => 4, |
| 680 | -values=>\@subjs, |
755 | -values=>\@subjs, |
| 681 | -default=> $selected{dbsubject}, |
756 | -default=> $selected{dbsubject}, |
| 682 | -onchange=>"submit();return true" |
757 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\',\'view_problems_spinner\')" |
| 683 | )]), |
758 | )]), |
| 684 | CGI::div({-colspan=>2, -align=>"right"}, |
759 | CGI::div({-colspan=>2, -align=>"right"}, |
| 685 | CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", |
760 | '<button type="button" style="'.$right_button_style.'" onclick="updateLibCategories(\'mainform\', \''.$r->uri.'\', \'lib_select_subject\', \'view_problems_spinner\')">Update Menus</button>'), |
| 686 | -style=> $right_button_style)), |
|
|
| 687 | CGI::div(["Chapter:", |
761 | CGI::div(["Chapter:", |
| 688 | CGI::popup_menu(-name=> 'library_chapters', |
762 | CGI::popup_menu(-name=> 'library_chapters', |
|
|
763 | -size => 4, |
| 689 | -values=>\@chaps, |
764 | -values=>\@chaps, |
| 690 | -default=> $selected{dbchapter}, |
765 | -default=> $selected{dbchapter}, |
| 691 | -onchange=>"submit();return true" |
766 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\',\'view_problems_spinner\')" |
| 692 | )]), |
767 | )]), |
| 693 | CGI::div({-colspan=>2, -align=>"right"}, |
768 | CGI::div({-colspan=>2, -align=>"right"}, |
| 694 | CGI::submit(-name=>"library_reset", -value=>"Reset", |
769 | '<button type="button" style="'.$right_button_style.'" onclick="updateLibCategories(\'mainform\', \''.$r->uri.'\', \'library_reset\', \'view_problems_spinner\')">Reset</button>'), |
| 695 | -style=>$right_button_style)), |
|
|
| 696 | CGI::div(["Section:", |
770 | CGI::div(["Section:", |
| 697 | CGI::popup_menu(-name=> 'library_sections', |
771 | CGI::popup_menu(-name=> 'library_sections', |
|
|
772 | -size => 4, |
| 698 | -values=>\@sects, |
773 | -values=>\@sects, |
| 699 | -default=> $selected{dbsection}, |
774 | -default=> $selected{dbsection}, |
| 700 | -onchange=>"submit();return true" |
775 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\',\'view_problems_spinner\')" |
| 701 | )]), |
776 | )]), |
| 702 | CGI::div({-colspan=>2, -align=>"right"}, |
777 | CGI::div({-colspan=>2, -align=>"right"}, |
| 703 | CGI::submit(-name=>"library_basic", -value=>"Basic Search", |
778 | '<button type="button" style="'.$right_button_style.'" onclick="updateLibCategories(\'mainform\', \''.$r->uri.'\', \'library_basic\', \'view_problems_spinner\')">Basic Search</button>'), |
| 704 | -style=>$right_button_style)), |
|
|
| 705 | CGI::div(["Textbook:", $text_popup]), |
779 | CGI::div(["Textbook:", $text_popup]), |
| 706 | CGI::div(["Text chapter:", |
780 | CGI::div(["Text chapter:", |
| 707 | CGI::popup_menu(-name=> 'library_textchapter', |
781 | CGI::popup_menu(-name=> 'library_textchapter', |
|
|
782 | -size => 4, |
| 708 | -values=>\@textchaps, |
783 | -values=>\@textchaps, |
| 709 | -default=> $selected{textchapter}, |
784 | -default=> $selected{textchapter}, |
| 710 | -onchange=>"submit();return true" |
785 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\',\'view_problems_spinner\')" |
| 711 | )]), |
786 | )]), |
| 712 | CGI::div(["Text section:", |
787 | CGI::div(["Text section:", |
| 713 | CGI::popup_menu(-name=> 'library_textsection', |
788 | CGI::popup_menu(-name=> 'library_textsection', |
|
|
789 | -size => 4, |
| 714 | -values=>\@textsecs, |
790 | -values=>\@textsecs, |
| 715 | -default=> $selected{textsection}, |
791 | -default=> $selected{textsection}, |
| 716 | -onchange=>"submit();return true" |
792 | -onchange=>"updateLibCategories(\'mainform\', \'".$r->uri."\',\'view_problems_spinner\')" |
| 717 | )]), |
793 | )]), |
| 718 | CGI::div("Keywords:"),CGI::div({-colspan=>2}, |
794 | CGI::div("Keywords:"),CGI::div({-colspan=>2}, |
| 719 | CGI::textfield(-name=>"library_keywords", |
795 | CGI::textfield(-name=>"library_keywords", |
| 720 | -default=>$library_keywords, |
796 | -default=>$library_keywords, |
| 721 | -override=>1, |
797 | -override=>1, |
| … | |
… | |
| 744 | @list_of_set_defs = (NO_LOCAL_SET_STRING); |
820 | @list_of_set_defs = (NO_LOCAL_SET_STRING); |
| 745 | } elsif (not $library_selected or $library_selected eq $default_value) { |
821 | } elsif (not $library_selected or $library_selected eq $default_value) { |
| 746 | unshift @list_of_set_defs, $default_value; |
822 | unshift @list_of_set_defs, $default_value; |
| 747 | $library_selected = $default_value; |
823 | $library_selected = $default_value; |
| 748 | } |
824 | } |
| 749 | my $view_problem_line = view_problems_line('view_setdef_set', 'View Problems', $self->r); |
825 | my $view_problem_line = view_problems_line('view_setdef_set', 'View Problems', $self->r, $self); |
| 750 | my $popupetc = CGI::popup_menu(-name=> 'library_sets', |
826 | my $popupetc = CGI::popup_menu(-size=> 4, |
|
|
827 | -name=> 'library_sets', |
| 751 | -values=>\@list_of_set_defs, |
828 | -values=>\@list_of_set_defs, |
| 752 | -default=> $library_selected). |
829 | -default=> $library_selected). |
| 753 | CGI::br(). $view_problem_line; |
830 | CGI::br(). $view_problem_line; |
| 754 | if($list_of_set_defs[0] eq NO_LOCAL_SET_STRING) { |
831 | if($list_of_set_defs[0] eq NO_LOCAL_SET_STRING) { |
| 755 | $popupetc = "there are no set definition files in this course to look at." |
832 | $popupetc = "there are no set definition files in this course to look at." |
| 756 | } |
833 | } |
| 757 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", |
834 | print CGI::div({-class=>"InfoPanel", -align=>"left"}, "<p style='margin-bottom:0;'>Browse from:</p>", |
| 758 | $popupetc |
835 | $popupetc |
| 759 | ); |
836 | ); |
| 760 | } |
837 | } |
| 761 | |
838 | |
| 762 | sub make_mysets_row { |
839 | sub make_mysets_row { |
| … | |
… | |
| 781 | #} |
858 | #} |
| 782 | #$libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
859 | #$libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
| 783 | |
860 | |
| 784 | my $these_widths = "width: 25ex"; |
861 | my $these_widths = "width: 25ex"; |
| 785 | |
862 | |
|
|
863 | |
| 786 | if($have_local_sets ==0) { |
864 | #if($have_local_sets ==0) { |
| 787 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
865 | # $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| 788 | } elsif (not defined($set_selected) or $set_selected eq "" |
866 | #} elsif (not defined($set_selected) or $set_selected eq "" |
| 789 | or $set_selected eq SELECT_SET_STRING) { |
867 | # or $set_selected eq SELECT_SET_STRING) { |
| 790 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
868 | # unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
| 791 | $set_selected = SELECT_SET_STRING; |
869 | # $set_selected = SELECT_SET_STRING; |
| 792 | } |
870 | #} |
| 793 | 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;'; |
871 | my $myjs = 'document.getElementById(\"create_new_set\").style.display = \"none\";document.mainform.selfassign.value=confirm("Should I assign the new set to you now?\nUse OK for yes and Cancel for no.");true;'; |
| 794 | ## edited this, as a demo for the current set problem list |
872 | ## edited this, as a demo for the current set problem list |
| 795 | print CGI::div({-class=>"InfoPanel"}, |
873 | print CGI::div({-id=>"create_new_set", -class=>"InfoPanel shadowed"}, |
| 796 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
874 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
| 797 | -onclick=>$myjs |
875 | -onclick=>$myjs |
| 798 | ), |
876 | ), |
| 799 | " ", |
877 | " ", |
| 800 | CGI::textfield(-name=>"new_set_name", |
878 | CGI::textfield(-name=>"new_set_name", |
| 801 | -default=>"Name for new set here", |
879 | -default=>"Name for new set here", |
| 802 | -override=>1, -size=>30), |
880 | -override=>1, -size=>30), |
|
|
881 | '<button type="button" onclick="document.getElementById(\'create_new_set\').style.display = \'none\';">Cancel</button>', |
| 803 | ); |
882 | ); |
| 804 | # Tidy this list up since it is used in two different places |
883 | # Tidy this list up since it is used in two different places |
| 805 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
884 | #if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
| 806 | shift @{$list_of_local_sets}; |
885 | # shift @{$list_of_local_sets}; |
| 807 | } |
886 | #} |
| 808 | |
887 | |
| 809 | #print CGI::div(CGI::div({-bgcolor=>"black"})); |
888 | #print CGI::div(CGI::div({-bgcolor=>"black"})); |
| 810 | #print CGI::hr(); |
889 | #print CGI::hr(); |
| 811 | |
890 | |
| 812 | $self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); |
891 | #$self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); |
| 813 | } |
892 | } |
| 814 | |
893 | |
| 815 | sub make_top_row { |
894 | sub make_top_row { |
| 816 | my $self = shift; |
895 | my $self = shift; |
| 817 | my $r = $self->r; |
896 | my $r = $self->r; |
| … | |
… | |
| 828 | @dis2 = (-disabled=>1) if($browse_which eq 'browse_local'); |
907 | @dis2 = (-disabled=>1) if($browse_which eq 'browse_local'); |
| 829 | @dis3 = (-disabled=>1) if($browse_which eq 'edit_mysets'); |
908 | @dis3 = (-disabled=>1) if($browse_which eq 'edit_mysets'); |
| 830 | @dis4 = (-disabled=>1) if($browse_which eq 'browse_setdefs'); |
909 | @dis4 = (-disabled=>1) if($browse_which eq 'browse_setdefs'); |
| 831 | |
910 | |
| 832 | ## Make buttons for additional problem libraries |
911 | ## Make buttons for additional problem libraries |
| 833 | my $libs = ''; |
912 | #my $libs = ''; |
| 834 | foreach my $lib (sort(keys(%problib))) { |
913 | #foreach my $lib (sort(keys(%problib))) { |
| 835 | $libs .= ' '. CGI::submit(-name=>"browse_$lib", -value=>$problib{$lib}, |
914 | # $libs .= ' '. CGI::submit(-name=>"browse_$lib", -value=>$problib{$lib}, |
| 836 | ($browse_which eq "browse_$lib")? (-disabled=>1): ()) |
915 | # ($browse_which eq "browse_$lib")? (-disabled=>1): ()) |
| 837 | if (-d "$ce->{courseDirs}{templates}/$lib"); |
916 | # if (-d "$ce->{courseDirs}{templates}/$lib"); |
| 838 | } |
917 | #} |
| 839 | $libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
918 | #$libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
| 840 | |
919 | |
| 841 | my $these_widths = "width: 25ex"; |
920 | my $these_widths = "width: 25ex"; |
| 842 | |
921 | |
| 843 | if($have_local_sets ==0) { |
922 | if($have_local_sets ==0) { |
| 844 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
923 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| … | |
… | |
| 851 | # Tidy this list up since it is used in two different places |
930 | # Tidy this list up since it is used in two different places |
| 852 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
931 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
| 853 | shift @{$list_of_local_sets}; |
932 | shift @{$list_of_local_sets}; |
| 854 | } |
933 | } |
| 855 | |
934 | |
| 856 | print CGI::div({-class=>"InfoPanel"}, |
935 | #print CGI::div({-class=>"InfoPanel"}, |
| 857 | "Browse ", |
936 | # "Browse ", |
| 858 | CGI::submit(-name=>"browse_npl_library", -value=>"National Problem Library", -style=>$these_widths, @dis1), |
937 | # CGI::submit(-name=>"browse_npl_library", -value=>"National Problem Library", -style=>$these_widths, @dis1), |
| 859 | CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, @dis2), |
938 | # CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, @dis2), |
| 860 | CGI::submit(-name=>"edit_mysets", -value=>"From This Course", -style=>$these_widths, @dis3), |
939 | # CGI::submit(-name=>"edit_mysets", -value=>"From This Course", -style=>$these_widths, @dis3), |
| 861 | CGI::submit(-name=>"browse_setdefs", -value=>"Set Definition Files", -style=>$these_widths, @dis4), |
940 | # CGI::submit(-name=>"browse_setdefs", -value=>"Set Definition Files", -style=>$these_widths, @dis4), |
| 862 | $libs, |
941 | # $libs, |
| 863 | ); |
942 | #); |
| 864 | |
943 | |
| 865 | if ($browse_which eq 'browse_local') { |
944 | #if ($browse_which eq 'browse_local') { |
| 866 | $self->browse_local_panel($library_selected); |
945 | # $self->browse_local_panel($library_selected); |
| 867 | } elsif ($browse_which eq 'edit_mysets') { |
946 | #} elsif ($browse_which eq 'edit_mysets') { |
| 868 | $self->edit_mysets_panel($library_selected, $list_of_local_sets); |
947 | # $self->edit_mysets_panel($library_selected, $list_of_local_sets); |
| 869 | } elsif ($browse_which eq 'browse_npl_library') { |
948 | #} elsif ($browse_which eq 'browse_npl_library') { |
| 870 | $self->browse_library_panel(); |
949 | # $self->browse_library_panel(); |
| 871 | } elsif ($browse_which eq 'browse_setdefs') { |
950 | #} elsif ($browse_which eq 'browse_setdefs') { |
| 872 | $self->browse_setdef_panel($library_selected); |
951 | # $self->browse_setdef_panel($library_selected); |
| 873 | } else { ## handle other problem libraries |
952 | #} else { ## handle other problem libraries |
| 874 | $self->browse_local_panel($library_selected,$browse_which); |
953 | # $self->browse_local_panel($library_selected,$browse_which); |
| 875 | } |
954 | #} |
| 876 | |
955 | |
| 877 | print CGI::div({-class=>"InfoPanel"}, |
956 | #, |
| 878 | CGI::submit(-name=>"select_all", -style=>$these_widths, |
|
|
| 879 | -value=>"Mark All For Adding"), |
|
|
| 880 | CGI::submit(-name=>"select_none", -style=>$these_widths, |
|
|
| 881 | -value=>"Clear All Marks"), |
|
|
| 882 | ), |
|
|
| 883 | CGI::div({}, |
957 | #CGI::div({}, |
| 884 | CGI::submit(-name=>"rerandomize", |
958 | # CGI::submit(-name=>"rerandomize", |
| 885 | -style=>$these_widths, |
959 | # -style=>$these_widths, |
| 886 | -value=>"Rerandomize"), |
960 | # -value=>"Rerandomize"), |
| 887 | CGI::submit(-name=>"cleardisplay", |
961 | # CGI::submit(-name=>"cleardisplay", |
| 888 | -style=>$these_widths, |
962 | # -style=>$these_widths, |
| 889 | -value=>"Clear Problem Display") |
963 | # -value=>"Clear Problem Display"), |
| 890 | ); |
964 | #); |
|
|
965 | |
|
|
966 | print "<div class='inforPanel' style='float:left;'> |
|
|
967 | <p style='margin-bottom:0'>Browse:</p> |
|
|
968 | <select id='library_selector' size=4 onchange='changeLibrary(\"mainform\", \"".$r->uri."\", this, \"view_problems_spinner\")'>"; |
|
|
969 | foreach my $lib (sort(keys(%problib))) { |
|
|
970 | print "<option value=\'browse_$lib\'>".$problib{$lib}."</option>" |
|
|
971 | } |
|
|
972 | print "<option value=\'browse_npl_library\'>National Problem Library</option> |
|
|
973 | <option value=\'browse_local\'>Local Problems</option> |
|
|
974 | <option value=\'edit_mysets\'>From this Course</option> |
|
|
975 | <option value=\'browse_setdefs\'>Set Definition Files</option>"; |
|
|
976 | print "</select> |
|
|
977 | </div>"; |
|
|
978 | |
| 891 | } |
979 | } |
| 892 | |
980 | |
| 893 | sub make_data_row { |
981 | sub make_data_row { |
| 894 | my $self = shift; |
982 | my $self = shift; |
| 895 | my $sourceFileName = shift; |
983 | my $sourceFileName = shift; |
| … | |
… | |
| 947 | sourceFilePath => "$sourceFileName", |
1035 | sourceFilePath => "$sourceFileName", |
| 948 | displayMode => $displayMode, |
1036 | displayMode => $displayMode, |
| 949 | } |
1037 | } |
| 950 | ), target=>"WW_View"}, "Try it"); |
1038 | ), target=>"WW_View"}, "Try it"); |
| 951 | |
1039 | |
| 952 | my %add_box_data = ( -id=>"trial$cnt" ,-name=>"trial$cnt",-value=>1,-label=>"Add this problem to the target set on the next update"); |
1040 | my %add_box_data = ( -id=>"trial$cnt", -class=>"add_problem_checkbox" ,-name=>"trial$cnt",-value=>1,-label=>"Add this problem to the target set on the next update"); |
| 953 | #allow for a move command from one problem set to anoter |
1041 | #allow for a move command from one problem set to anoter |
| 954 | my $move_box_data; |
1042 | my $move_box_data; |
| 955 | if($self->r->param('edit_mysets_set')){ |
1043 | if($self->r->param('edit_mysets_set')){ |
| 956 | $move_box_data = CGI::checkbox( -id=>"moved$cnt" ,-name=>"moved$cnt",-value=>1,,-override=>1,-label=>"Move this problem from this set to the target set on the next update"); |
1044 | $move_box_data = CGI::checkbox( -id=>"moved$cnt" ,-name=>"moved$cnt",-value=>1,,-override=>1,-label=>"Move this problem from this set to the target set on the next update"); |
| 957 | } |
1045 | } |
| … | |
… | |
| 970 | CGI::p({},"File name: $sourceFileName "), |
1058 | CGI::p({},"File name: $sourceFileName "), |
| 971 | CGI::p({}, $edit_link, " ", $try_link), |
1059 | CGI::p({}, $edit_link, " ", $try_link), |
| 972 | CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), |
1060 | CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), |
| 973 | CGI::p(CGI::checkbox((%add_box_data),-override=>1)), |
1061 | CGI::p(CGI::checkbox((%add_box_data),-override=>1)), |
| 974 | CGI::p($move_box_data), |
1062 | CGI::p($move_box_data), |
| 975 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
1063 | CGI::hidden(-id=>"filetrial$cnt", -name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
| 976 | CGI::p($problem_output) |
1064 | CGI::p($problem_output) |
| 977 | ); |
1065 | ); |
| 978 | } |
1066 | } |
| 979 | else{ |
1067 | else{ |
| 980 | print CGI::div({-class=>"problem libraryProblem used", -align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, |
1068 | print CGI::div({-class=>"problem libraryProblem used", -align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, |
| 981 | CGI::p({},"File name: $sourceFileName "), |
1069 | CGI::p({},"File name: $sourceFileName "), |
| 982 | CGI::p({}, $edit_link, " ", $try_link), |
1070 | CGI::p({}, $edit_link, " ", $try_link), |
| 983 | CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), |
1071 | CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), |
| 984 | CGI::p(CGI::checkbox((%add_box_data),-override=>1)), |
1072 | CGI::p(CGI::checkbox((%add_box_data),-override=>1)), |
| 985 | CGI::p($move_box_data), |
1073 | CGI::p($move_box_data), |
| 986 | CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
1074 | CGI::hidden(-id=>"filetrial$cnt", -name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). |
| 987 | CGI::p($problem_output), |
1075 | CGI::p($problem_output), |
| 988 | CGI::b("(This problem is in the target set)") |
1076 | CGI::b("(This problem is in the target set)") |
| 989 | ); |
1077 | ); |
| 990 | } |
1078 | } |
| 991 | } |
1079 | } |
| … | |
… | |
| 1053 | |
1141 | |
| 1054 | print CGI::div({-class=>"problem myProblem", -draggable=>"true", -href=>"#", -id=>("$cnt".'myset')}, |
1142 | print CGI::div({-class=>"problem myProblem", -draggable=>"true", -href=>"#", -id=>("$cnt".'myset')}, |
| 1055 | CGI::p({},"File name: $sourceFileName "), |
1143 | CGI::p({},"File name: $sourceFileName "), |
| 1056 | CGI::p({}, $edit_link, " ", $try_link), |
1144 | CGI::p({}, $edit_link, " ", $try_link), |
| 1057 | CGI::p(CGI::checkbox((%delete_box_data),-override=>1)), |
1145 | CGI::p(CGI::checkbox((%delete_box_data),-override=>1)), |
| 1058 | CGI::hidden(-name=>"mysetfiletrial$cnt", -default=>$sourceFileName,-override=>1). |
1146 | CGI::hidden(-id=>"filetrial$cnt".'myset', -name=>"mysetfiletrial$cnt", -default=>$sourceFileName,-override=>1), |
| 1059 | CGI::p($problem_output), |
1147 | CGI::p($problem_output), |
| 1060 | ); |
1148 | ); |
| 1061 | } |
1149 | } |
| 1062 | |
1150 | |
| 1063 | sub clear_default { |
1151 | sub clear_default { |
| … | |
… | |
| 1148 | } |
1236 | } |
| 1149 | |
1237 | |
| 1150 | ############# Default of which problem selector to display |
1238 | ############# Default of which problem selector to display |
| 1151 | |
1239 | |
| 1152 | my $browse_which = $r->param('browse_which') || 'browse_npl_library'; |
1240 | my $browse_which = $r->param('browse_which') || 'browse_npl_library'; |
|
|
1241 | my $gridded = $r->param('gridify') || 'false'; |
| 1153 | |
1242 | |
| 1154 | |
1243 | |
| 1155 | |
1244 | |
| 1156 | ## check for problem lib buttons |
1245 | ## check for problem lib buttons |
| 1157 | my $browse_lib = ''; |
1246 | my $browse_lib = ''; |
| … | |
… | |
| 1321 | } |
1410 | } |
| 1322 | |
1411 | |
| 1323 | ##### Add selected problems to the current local set |
1412 | ##### Add selected problems to the current local set |
| 1324 | |
1413 | |
| 1325 | } elsif ($r->param('update')) { |
1414 | } elsif ($r->param('update')) { |
|
|
1415 | |
| 1326 | ## first handle problems to be added before we hide them |
1416 | ## first handle problems to be added before we hide them |
| 1327 | my($localSet, @selected); |
1417 | my($localSet, @selected); |
| 1328 | |
1418 | |
| 1329 | my @add_pg_files = grep {(($_->[1] & ADDED)) != 0 } @{$self->{past_problems}}; |
1419 | my @add_pg_files = grep {(($_->[1] & ADDED)) != 0 } @{$self->{past_problems}}; |
| 1330 | my @add_selected = map {$_->[0]} @add_pg_files; |
1420 | my @add_selected = map {$_->[0]} @add_pg_files; |
| … | |
… | |
| 1338 | my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; |
1428 | my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; |
| 1339 | # There are now good reasons to do an update without selecting anything. |
1429 | # There are now good reasons to do an update without selecting anything. |
| 1340 | #if(scalar(@action_files) == 0) { |
1430 | #if(scalar(@action_files) == 0) { |
| 1341 | # $self->addbadmessage('Update requested, but no problems were marked.'); |
1431 | # $self->addbadmessage('Update requested, but no problems were marked.'); |
| 1342 | #} |
1432 | #} |
| 1343 | |
|
|
| 1344 | if (scalar(@add_selected)>0) { # if some are to be added, they need a place to go |
1433 | if (scalar(@add_selected)>0) { # if some are to be added, they need a place to go |
| 1345 | $localSet = $r->param('myset_sets'); |
1434 | $localSet = $r->param('myset_sets'); |
| 1346 | if (not defined($localSet) or |
1435 | if (not defined($localSet) or |
| 1347 | $localSet eq SELECT_SET_STRING or |
1436 | $localSet eq SELECT_SET_STRING or |
| 1348 | $localSet eq NO_LOCAL_SET_STRING) { |
1437 | $localSet eq NO_LOCAL_SET_STRING) { |
| … | |
… | |
| 1393 | but you did not select a "Target Set" name as a target.'); |
1482 | but you did not select a "Target Set" name as a target.'); |
| 1394 | } else { |
1483 | } else { |
| 1395 | my $newSetRecord = $db->getGlobalSet($localSet); |
1484 | my $newSetRecord = $db->getGlobalSet($localSet); |
| 1396 | my $otherNewSetRecord = $db->getGlobalSet($otherSet); |
1485 | my $otherNewSetRecord = $db->getGlobalSet($otherSet); |
| 1397 | if (not defined($newSetRecord) or not defined($otherNewSetRecord)) { |
1486 | if (not defined($newSetRecord) or not defined($otherNewSetRecord)) { |
| 1398 | $self->addbadmessage("You are trying to move problems from $otherNewSetRecord to $localSet, |
1487 | $self->addbadmessage("You are trying to move problems from $otherSet to $localSet, |
| 1399 | but that set does not seem to exist! I bet you used your \"Back\" button."); |
1488 | but that set does not seem to exist! I bet you used your \"Back\" button."); |
| 1400 | } else { |
1489 | } else { |
| 1401 | my $addcount = add_selected($self, $db, $localSet); |
1490 | my $addcount = add_selected($self, $db, $localSet); |
| 1402 | my $deletecount = delete_selected($self, $db, $otherSet); |
1491 | my $deletecount = delete_selected($self, $db, $otherSet); |
| 1403 | if($addcount > 0 && $deletecount > 0) { |
1492 | if($addcount > 0 && $deletecount > 0) { |
| … | |
… | |
| 1417 | @all_past_list = (@all_past_list[0..($first_shown-1)], |
1506 | @all_past_list = (@all_past_list[0..($first_shown-1)], |
| 1418 | @pg_files, |
1507 | @pg_files, |
| 1419 | @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]); |
1508 | @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]); |
| 1420 | $last_shown = $first_shown+$maxShown -1; debug("last_shown 3: ", $last_shown); |
1509 | $last_shown = $first_shown+$maxShown -1; debug("last_shown 3: ", $last_shown); |
| 1421 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 4: ", $last_shown); |
1510 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 4: ", $last_shown); |
|
|
1511 | |
|
|
1512 | #want to reorder in addition to anything else |
|
|
1513 | if ($r->param('isReordered')){ |
|
|
1514 | #this might work, i'm not sure if this is the right ID |
|
|
1515 | reorderProblems($self, $db, $r->param('myset_sets'), $r); |
|
|
1516 | } |
| 1422 | |
1517 | |
| 1423 | } elsif ($r->param('next_page')) { |
1518 | } elsif ($r->param('next_page')) { |
| 1424 | $first_shown = $last_shown+1; |
1519 | $first_shown = $last_shown+1; |
| 1425 | $last_shown = $first_shown+$maxShown-1; debug("last_shown 5: ", $last_shown); |
1520 | $last_shown = $first_shown+$maxShown-1; debug("last_shown 5: ", $last_shown); |
| 1426 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 6: ", $last_shown); |
1521 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 6: ", $last_shown); |
|
|
1522 | $self->addgoodmessage("It sees the next_page parameter, last shown is: $last_shown and first shown is: $first_shown"); |
| 1427 | @past_marks = (); |
1523 | @past_marks = (); |
| 1428 | } elsif ($r->param('prev_page')) { |
1524 | } elsif ($r->param('prev_page')) { |
| 1429 | $last_shown = $first_shown-1; |
1525 | $last_shown = $first_shown-1; |
| 1430 | $first_shown = $last_shown - $maxShown+1; |
1526 | $first_shown = $last_shown - $maxShown+1; |
| 1431 | |
1527 | |
| … | |
… | |
| 1449 | @past_marks = (); |
1545 | @past_marks = (); |
| 1450 | } else { |
1546 | } else { |
| 1451 | #nothing |
1547 | #nothing |
| 1452 | } ##### end of the if elsif ... |
1548 | } ##### end of the if elsif ... |
| 1453 | |
1549 | |
|
|
1550 | #I'm worried this will break something |
| 1454 | my $default_set = $self->{current_myset_set}; |
1551 | my $default_set = $self->{current_myset_set}; |
| 1455 | #debug("set_to_display is $default_set"); |
1552 | #debug("set_to_display is $default_set"); |
| 1456 | if (not defined($default_set) |
1553 | if (not defined($default_set) |
| 1457 | or $default_set eq "Select a Homework Set" |
1554 | or $default_set eq "Select a Homework Set" |
| 1458 | or $default_set eq NO_LOCAL_SET_STRING) { |
1555 | or $default_set eq NO_LOCAL_SET_STRING) { |
| … | |
… | |
| 1467 | die "global $problem for set $default_set not found." unless |
1564 | die "global $problem for set $default_set not found." unless |
| 1468 | $problemRecord; |
1565 | $problemRecord; |
| 1469 | push @myset_files, $problemRecord->source_file; |
1566 | push @myset_files, $problemRecord->source_file; |
| 1470 | |
1567 | |
| 1471 | } |
1568 | } |
| 1472 | @myset_files = sortByName(undef,@myset_files); |
1569 | #@myset_files = sortByName(undef,@myset_files); |
| 1473 | $use_previous_problems=0; |
|
|
| 1474 | } |
1570 | } |
| 1475 | |
1571 | |
| 1476 | ############# List of local sets |
1572 | ############# List of local sets |
| 1477 | |
1573 | |
| 1478 | # DBFIXME sorting in database, please! |
1574 | # DBFIXME sorting in database, please! |
| … | |
… | |
| 1489 | } |
1585 | } |
| 1490 | ############# Now store data in self for retreival by body |
1586 | ############# Now store data in self for retreival by body |
| 1491 | $self->{first_shown} = $first_shown; |
1587 | $self->{first_shown} = $first_shown; |
| 1492 | $self->{last_shown} = $last_shown; |
1588 | $self->{last_shown} = $last_shown; |
| 1493 | $self->{browse_which} = $browse_which; |
1589 | $self->{browse_which} = $browse_which; |
|
|
1590 | $self->{gridded} = $gridded; |
| 1494 | #$self->{problem_seed} = $problem_seed; |
1591 | #$self->{problem_seed} = $problem_seed; |
| 1495 | $self->{pg_files} = \@pg_files; |
1592 | $self->{pg_files} = \@pg_files; |
| 1496 | $self->{myset_files} = \@myset_files; |
1593 | $self->{myset_files} = \@myset_files; |
| 1497 | $self->{past_marks} = \@past_marks; |
1594 | $self->{past_marks} = \@past_marks; |
| 1498 | $self->{all_db_sets} = \@all_db_sets; |
1595 | $self->{all_db_sets} = \@all_db_sets; |
| … | |
… | |
| 1511 | } |
1608 | } |
| 1512 | |
1609 | |
| 1513 | sub head { |
1610 | sub head { |
| 1514 | print '<script src="/webwork2_files/js/dnd.js"></script>'; |
1611 | print '<script src="/webwork2_files/js/dnd.js"></script>'; |
| 1515 | print '<script src="/webwork2_files/js/problem_grid.js"></script>'; |
1612 | print '<script src="/webwork2_files/js/problem_grid.js"></script>'; |
|
|
1613 | print '<script src="/webwork2_files/js/form_builder.js"></script>'; |
|
|
1614 | #my ($self) = @_; |
|
|
1615 | #my $r = $self->r; |
|
|
1616 | #start a timer to save people's stuff idk if people want this |
|
|
1617 | #print "<script> setInterval('saveChanges(\"mainform\", \"".$r->uri."\")', 680000); </script>"; |
| 1516 | print '<link rel="stylesheet" type="text/css" href="/webwork2_files/css/setmaker2.css" />'; |
1618 | print '<link rel="stylesheet" type="text/css" href="/webwork2_files/css/setmaker2.css" />'; |
| 1517 | print '<script>window.addEventListener("load", setup, false);</script>'; |
1619 | print '<script>window.addEventListener("load", setup, false);</script>'; |
| 1518 | return ""; |
1620 | return ""; |
| 1519 | } |
1621 | } |
| 1520 | |
1622 | |
| 1521 | sub body { |
1623 | sub body { |
|
|
1624 | #big wrapper div that will hopefully fix theme issues |
|
|
1625 | print '<div id="set_maker_two_box">'; |
|
|
1626 | |
| 1522 | my ($self) = @_; |
1627 | my ($self) = @_; |
| 1523 | |
1628 | |
| 1524 | my $r = $self->r; |
1629 | my $r = $self->r; |
| 1525 | my $ce = $r->ce; # course environment |
1630 | my $ce = $r->ce; # course environment |
| 1526 | my $db = $r->db; # database |
1631 | my $db = $r->db; # database |
| … | |
… | |
| 1548 | ########## Extract information computed in pre_header_initialize |
1653 | ########## Extract information computed in pre_header_initialize |
| 1549 | |
1654 | |
| 1550 | my $first_shown = $self->{first_shown}; |
1655 | my $first_shown = $self->{first_shown}; |
| 1551 | my $last_shown = $self->{last_shown}; |
1656 | my $last_shown = $self->{last_shown}; |
| 1552 | my $browse_which = $self->{browse_which}; |
1657 | my $browse_which = $self->{browse_which}; |
|
|
1658 | my $gridded = $self->{gridded}; |
| 1553 | my $problem_seed = $self->{problem_seed}||1234; |
1659 | my $problem_seed = $self->{problem_seed}||1234; |
| 1554 | my @pg_files = @{$self->{pg_files}}; |
1660 | my @pg_files = @{$self->{pg_files}}; |
| 1555 | my @myset_files =@{$self->{myset_files}}; |
1661 | my @myset_files =@{$self->{myset_files}}; |
| 1556 | my @all_db_sets = @{$self->{all_db_sets}}; |
1662 | my @all_db_sets = @{$self->{all_db_sets}}; |
|
|
1663 | |
|
|
1664 | my $displayModePlaceholder; |
|
|
1665 | if (not defined($r->param('mydisplayMode'))){ |
|
|
1666 | $displayModePlaceholder = "images"; |
|
|
1667 | } |
|
|
1668 | else{ |
|
|
1669 | $displayModePlaceholder = $r->param('mydisplayMode'); |
|
|
1670 | } |
| 1557 | |
1671 | |
| 1558 | my @pg_html; |
1672 | my @pg_html; |
| 1559 | if ($last_shown >= $first_shown) { |
1673 | if ($last_shown >= $first_shown) { |
| 1560 | @pg_html = renderProblems( |
1674 | @pg_html = renderProblems( |
| 1561 | r=> $r, |
1675 | r=> $r, |
| 1562 | user => $user, |
1676 | user => $user, |
| 1563 | problem_list => [@pg_files[$first_shown..$last_shown]], |
1677 | problem_list => [@pg_files[$first_shown..$last_shown]], |
| 1564 | displayMode => 'images', |
1678 | displayMode => $displayModePlaceholder, |
| 1565 | showHints => $showHints, |
1679 | showHints => $showHints, |
| 1566 | showSolutions => $showSolutions, |
1680 | showSolutions => $showSolutions, |
| 1567 | ); |
1681 | ); |
| 1568 | } |
1682 | } |
| 1569 | my @myset_html; |
1683 | my @myset_html; |
| 1570 | my $displayModePlaceholder; |
1684 | |
| 1571 | if (not defined($r->param('mydisplayMode'))){ |
|
|
| 1572 | $displayModePlaceholder = "None"; |
|
|
| 1573 | } |
|
|
| 1574 | else{ |
|
|
| 1575 | $displayModePlaceholder = $r->param('mydisplayMode'); |
|
|
| 1576 | } |
|
|
| 1577 | if (scalar(@myset_files) >= $first_shown) { |
|
|
| 1578 | @myset_html = renderProblems( |
1685 | @myset_html = renderProblems( |
| 1579 | r=> $r, |
1686 | r=> $r, |
| 1580 | user => $user, |
1687 | user => $user, |
| 1581 | problem_list => [@myset_files[$first_shown..(scalar(@myset_files)-1)]], |
1688 | problem_list => [@myset_files], |
| 1582 | displayMode => 'images', |
1689 | displayMode => $displayModePlaceholder, |
| 1583 | showHints => $showHints, |
1690 | showHints => $showHints, |
| 1584 | showSolutions => $showSolutions, |
1691 | showSolutions => $showSolutions, |
| 1585 | ); |
1692 | ); |
| 1586 | } |
|
|
| 1587 | |
1693 | |
| 1588 | my %isInSet; |
1694 | my %isInSet; |
| 1589 | my $setName = $r->param("myset_sets"); |
1695 | my $setName = $r->param("myset_sets"); |
| 1590 | if ($setName) { |
1696 | if ($setName) { |
| 1591 | # DBFIXME where clause, iterator |
1697 | # DBFIXME where clause, iterator |
| … | |
… | |
| 1598 | $isInSet{$problemRecord->source_file} = 1; |
1704 | $isInSet{$problemRecord->source_file} = 1; |
| 1599 | } |
1705 | } |
| 1600 | } |
1706 | } |
| 1601 | $self->{isInSet} = \%isInSet; |
1707 | $self->{isInSet} = \%isInSet; |
| 1602 | my $jj; |
1708 | my $jj; |
|
|
1709 | ########## Loading Screen |
|
|
1710 | print '<div id="loading"></div>'; |
|
|
1711 | |
| 1603 | ########## Top part |
1712 | ########## Top part |
|
|
1713 | print '<span><button onclick="fullWindowMode();">Full Screen</button>'; |
| 1604 | print '<button id="gridifyButton" onclick="gridify();">Gridify!!</button>'; |
1714 | print '<span><button id="gridifyButton" onclick="gridify();">Gridify!!</button>'; |
|
|
1715 | print '<span>Hover Magnification: <button type="button" onclick="increaseMagnification();">+</button><span id="magnification">1</span><button type="button" onclick="decreaseMagnification();">-</button></span></span>'; |
|
|
1716 | print '<button type="button" onclick="toggleHelp(this);" value="false">?</button>'; |
|
|
1717 | print '<div id="help" style="display:none;position:absolute;z-index:1500;background:white;" class="shadowed">', |
|
|
1718 | '<h1>What can you do?</h1>', |
|
|
1719 | '<p>Drag a problem from the library to the target set to add.</p>', |
|
|
1720 | '<p>Drag a problem set off the target set to remove.</p>', |
|
|
1721 | '<p>If you have a local problem set in the library<br/>you can shift drag to move a problem from there to the target set.<br/>This will remove the problem from one set and add it to the other</p>', |
|
|
1722 | '<h1>Legend</h1>', |
|
|
1723 | '<p><div class="problem" style="width:16px;height:16px;border:solid 1px;"></div><span>Normal problem</span></p>', |
|
|
1724 | '<p><div class="used" style="width:16px;height:16px;border:solid 1px;"></div><span>Problem already in set</span></p>', |
|
|
1725 | '<p><div class="libProblem" style="width:16px;height:16px;border:solid 1px;"></div><span>Problem will be added to target on next update</span></p>', |
|
|
1726 | '<p><div class="removedProblem" style="width:16px;height:16px;border:solid 1px;"></div><span>Problem will be deleted from target on next update</span></p>', |
|
|
1727 | '<p><div class="ResultsWithError" style="width:16px;height:16px;border:solid 1px;"></div><span>Errors</span></p>', |
|
|
1728 | '</div>'; |
|
|
1729 | #'<p>In the target set you can drag problems to reorder them.<br/>The problem will be placed in front of the one you drop it on,<br/>or at the end of the list if you drop it on an empty space in the table.</p>', |
|
|
1730 | print '<span><button type="button" style="float:right;" onclick="saveChanges(\'mainform\', \''.$r->uri.'\', \'save_changes_spinner\');">save changes</button><img id="save_changes_spinner" style="display:none;float:right;" src="/webwork2_files/images/ajax-loader-small.gif"></img></span>'; |
| 1605 | print '<div id="editor-form">'; |
1731 | print '<div id="editor-form">'; |
| 1606 | print CGI::start_form({-method=>"POST", -action=>$r->uri, -name=>'mainform'}), |
1732 | print CGI::start_form({-id=>"mainform", -method=>"POST", -action=>$r->uri, -name=>'mainform'}), |
| 1607 | $self->hidden_authen_fields; |
1733 | $self->hidden_authen_fields; |
|
|
1734 | |
| 1608 | print '<div id="control_panel">'; |
1735 | #print '<div id="control_panel">'; |
| 1609 | print '<div id="myset_control" class="mysets control">'; |
1736 | #print '<div id="myset_control" class="mysets control">'; |
| 1610 | $self->make_mysets_row('all_db_sets'=>\@all_db_sets); |
1737 | |
|
|
1738 | #some work for the moved controls |
|
|
1739 | my $list_of_local_sets = $self->{all_db_sets}; |
|
|
1740 | my $have_local_sets = scalar(@$list_of_local_sets); |
|
|
1741 | my $library_selected = $self->{current_library_set}; |
|
|
1742 | my $set_selected = $r->param('local_sets'); |
|
|
1743 | |
|
|
1744 | if($have_local_sets ==0) { |
|
|
1745 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
|
|
1746 | } elsif (not defined($set_selected) or $set_selected eq "" |
|
|
1747 | or $set_selected eq SELECT_SET_STRING) { |
|
|
1748 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
|
|
1749 | $set_selected = SELECT_SET_STRING; |
|
|
1750 | } |
|
|
1751 | |
|
|
1752 | # Tidy this list up since it is used in two different places |
|
|
1753 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
|
|
1754 | shift @{$list_of_local_sets}; |
|
|
1755 | } |
| 1611 | print '</div>'; |
1756 | #print '</div>'; |
| 1612 | print '<div id="library_control" class="setmaker_library control">'; |
1757 | |
| 1613 | $self->make_top_row('all_db_sets'=>\@all_db_sets, 'browse_which'=> $browse_which); |
|
|
| 1614 | print '</div>'; |
|
|
| 1615 | print '</div>'; |
1758 | #print '</div>'; |
| 1616 | print '<div style="clear:both;padding:0px;margin:0px;"></div>'; |
1759 | print '<div style="clear:both;padding:0px;margin:0px;"></div>'; |
| 1617 | ######### Table of mysets problems |
1760 | ######### Table of mysets problems |
| 1618 | print '<div id="problem_container">'; |
1761 | print '<div id="problem_container">'; |
|
|
1762 | print '<div id="mysets_problems_box" class="mysets">'; |
|
|
1763 | print '<h1>Target Set</h1>'; |
|
|
1764 | print '<div class="setSelector">'; |
|
|
1765 | #work for moved controlls |
|
|
1766 | $list_of_local_sets = $self->{all_db_sets}; |
|
|
1767 | $have_local_sets = scalar(@$list_of_local_sets); |
|
|
1768 | $library_selected = $self->{current_myset_set}; |
|
|
1769 | $set_selected = $r->param('myset_sets'); |
|
|
1770 | my $remember_local_set = $r->param('local_sets'); |
|
|
1771 | |
|
|
1772 | my $these_widths = "width: 25ex"; |
|
|
1773 | |
|
|
1774 | if($have_local_sets ==0) { |
|
|
1775 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
|
|
1776 | } elsif (not defined($set_selected) or $set_selected eq "" |
|
|
1777 | or $set_selected eq SELECT_SET_STRING) { |
|
|
1778 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
|
|
1779 | $set_selected = SELECT_SET_STRING; |
|
|
1780 | } |
|
|
1781 | # Tidy this list up since it is used in two different places |
|
|
1782 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
|
|
1783 | shift @{$list_of_local_sets}; |
|
|
1784 | } |
|
|
1785 | |
|
|
1786 | $self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); |
|
|
1787 | $self->make_mysets_row('all_db_sets'=>\@all_db_sets); |
|
|
1788 | print '</div>'; |
| 1619 | print '<div id="mysets_problems" class="problemList mysets">'; |
1789 | print '<div id="mysets_problems" class="problemList">'; |
| 1620 | for ($jj=0; $jj<scalar(@myset_html); $jj++) { |
1790 | for ($jj=0; $jj<scalar(@myset_html); $jj++) { |
| 1621 | $myset_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
1791 | $myset_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
| 1622 | $self->make_myset_data_row($myset_files[$jj+$first_shown], $myset_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
1792 | $self->make_myset_data_row($myset_files[$jj], $myset_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
| 1623 | } |
1793 | } |
| 1624 | print '</div>'; |
1794 | print '</div>'; |
| 1625 | |
1795 | print '<p><button type="button" onclick="increasMysetsAcross();">+</button><span id="mysetsAcross">1</span><button type="button" onclick="decreaseMysetsAcross();">-</button><span> problems across</span></p>'; |
|
|
1796 | print '</div>'; |
|
|
1797 | print '<div id="horizontal_slider">=</div>'; |
| 1626 | print '<div id="size_slider"><p>||</p></div>'; |
1798 | print '<div id="size_slider"><p>||</p></div>'; |
| 1627 | |
1799 | |
|
|
1800 | #some work for the moved controls |
|
|
1801 | $list_of_local_sets = $self->{all_db_sets}; |
|
|
1802 | $have_local_sets = scalar(@$list_of_local_sets); |
|
|
1803 | $library_selected = $self->{current_library_set}; |
|
|
1804 | $set_selected = $r->param('local_sets'); |
|
|
1805 | |
|
|
1806 | if($have_local_sets ==0) { |
|
|
1807 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
|
|
1808 | } elsif (not defined($set_selected) or $set_selected eq "" |
|
|
1809 | or $set_selected eq SELECT_SET_STRING) { |
|
|
1810 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
|
|
1811 | $set_selected = SELECT_SET_STRING; |
|
|
1812 | } |
|
|
1813 | |
|
|
1814 | # Tidy this list up since it is used in two different places |
|
|
1815 | if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { |
|
|
1816 | shift @{$list_of_local_sets}; |
|
|
1817 | } |
| 1628 | print '<div id="setmaker_library_box" class="setmaker_library">'; |
1818 | print '<div id="setmaker_library_box" class="setmaker_library">'; |
|
|
1819 | print '<h1>Library</h1>'; |
|
|
1820 | print '<div class="setSelector">'; |
|
|
1821 | ########################################### |
|
|
1822 | # Library repository controls |
|
|
1823 | ########################################### |
|
|
1824 | print '<div id="setmaker_library" class="control">'; |
|
|
1825 | $self->make_top_row('all_db_sets'=>\@all_db_sets, 'browse_which'=> $browse_which); |
|
|
1826 | print '<div id="library_categories">'; |
|
|
1827 | #misplaced controlls |
|
|
1828 | if ($browse_which eq 'browse_local') { |
|
|
1829 | $self->browse_local_panel($library_selected); |
|
|
1830 | } elsif ($browse_which eq 'edit_mysets') { |
|
|
1831 | $self->edit_mysets_panel($library_selected, $list_of_local_sets); |
|
|
1832 | } elsif ($browse_which eq 'browse_npl_library') { |
|
|
1833 | $self->browse_library_panel(); |
|
|
1834 | } elsif ($browse_which eq 'browse_setdefs') { |
|
|
1835 | $self->browse_setdef_panel($library_selected); |
|
|
1836 | } else { ## handle other problem libraries |
|
|
1837 | $self->browse_local_panel($library_selected,$browse_which); |
|
|
1838 | } |
|
|
1839 | print '</div>'; |
|
|
1840 | print CGI::div({-class=>"InfoPanel"}, |
|
|
1841 | '<span class="js_action_span" onclick="selectAll();">all</span> |
|
|
1842 | <span style="margin-left:10px;" class="js_action_span" onclick="selectNone();">none</span>' |
|
|
1843 | #<span style="margin-left:10px;" class="js_action_span" onclick="rerandomize();">Rerandomize</span> |
|
|
1844 | # <span style="margin-left:10px;" class="js_action_span" onclick="cleardisplay();">Clear Problem Display</span>' |
|
|
1845 | ); |
|
|
1846 | print '</div>'; |
|
|
1847 | ########################################### |
|
|
1848 | print '</div>'; |
|
|
1849 | |
|
|
1850 | print '<div class="setSelectorLib">';#what is this? |
|
|
1851 | print '</div>'; |
|
|
1852 | #hidden inputs for memeory |
|
|
1853 | #remember gridify |
|
|
1854 | print '<div id="setmaker_library_data">'; |
|
|
1855 | print CGI::hidden(-id=>'pastGridded', -name=>'gridify', -value=>$gridded, -override=>1); |
|
|
1856 | print CGI::hidden(-id=>'isReordered', -name=>'isReordered', -vale=>0 ,-override=>0); |
| 1629 | print CGI::hidden(-name=>'browse_which', -value=>$browse_which,-override=>1), |
1857 | print CGI::hidden(-name=>'browse_which', -value=>$browse_which,-override=>1), |
| 1630 | CGI::hidden(-name=>'problem_seed', -value=>$problem_seed, -override=>1); |
1858 | CGI::hidden(-name=>'problem_seed', -value=>$problem_seed, -override=>1); |
| 1631 | for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { |
1859 | for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { |
| 1632 | print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1); |
1860 | print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1); |
| 1633 | } |
1861 | } |
| … | |
… | |
| 1638 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
1866 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
| 1639 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
1867 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
| 1640 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
1868 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
| 1641 | } |
1869 | } |
| 1642 | print '</div>'; |
1870 | print '</div>'; |
|
|
1871 | print '<p><button type="button" onclick="increaseLibAcross();">+</button><span id="libAcross">4</span><button type="button" onclick="decreaseLibAcross();">-</button><span> problems across</span></p>'; |
| 1643 | ########## Finish things off |
1872 | ########## Finish things off |
| 1644 | my ($next_button, $prev_button) = ("", ""); |
1873 | my ($next_button, $prev_button) = ("", ""); |
| 1645 | if ($first_shown > 0) { |
1874 | if ($first_shown > 0) { |
| 1646 | $prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", -value=>"Previous page"); |
1875 | #$prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", -value=>"Previous page"); |
|
|
1876 | my $urlpath = $r->urlpath; |
|
|
1877 | my $getProblemPath = $self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::GetLibrarySetProblems", courseID =>$urlpath->arg("courseID"))); |
|
|
1878 | $prev_button = "<span><button type='button' onclick='viewProblems(\"prev_page\" ,\"mainform\", \"".$r->uri."\", \"prev_spinner\");'>Previous page</button><img id='prev_spinner' style='display:none;' src='/webwork2_files/images/ajax-loader-small.gif'></img></span>"; |
| 1647 | } |
1879 | } |
| 1648 | if ((1+$last_shown)<scalar(@pg_files)) { |
1880 | if ((1+$last_shown)<scalar(@pg_files)) { |
| 1649 | $next_button = CGI::submit(-name=>"next_page", -style=>"width:15ex", -value=>"Next page"); |
1881 | #$next_button = CGI::submit(-name=>"next_page", -style=>"width:15ex", -value=>"Next page"); |
|
|
1882 | my $urlpath = $r->urlpath; |
|
|
1883 | my $getProblemPath = $self->systemLink($urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::GetLibrarySetProblems", courseID =>$urlpath->arg("courseID"))); |
|
|
1884 | $next_button = "<span><button type='button' onclick='viewProblems(\"next_page\" ,\"mainform\", \"".$r->uri."\", \"next_spinner\");'>Next page</button><img id='next_spinner' style='display:none;' src='/webwork2_files/images/ajax-loader-small.gif'></img></span>"; |
| 1650 | } |
1885 | } |
| 1651 | if (scalar(@pg_files)>0) { |
1886 | if (scalar(@pg_files)>0) { |
| 1652 | print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files)." shown.", $prev_button, " ", $next_button, |
1887 | print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files)." shown.", $prev_button, " ", $next_button, |
| 1653 | CGI::submit(-name=>"update", -style=>"width:15ex; font-weight:bold", -value=>"Update Set")); |
1888 | '<span><button type="button" style="float:right;" onclick="saveChanges(\'mainform\', \''.$r->uri.'\', \'save_changes_spinner2\');">save changes</button><img id="save_changes_spinner2" style="display:none;float:right;" src="/webwork2_files/images/ajax-loader-small.gif"></img></span>'); |
| 1654 | } |
1889 | } |
|
|
1890 | #close setmaker_library_data |
|
|
1891 | print '</div>'; |
| 1655 | #close setmaker_library |
1892 | #close setmaker_library |
| 1656 | print '</div>'; |
1893 | print '</div>'; |
| 1657 | #close problem_container |
1894 | #close problem_container |
| 1658 | print '</div>'; |
1895 | print '</div>'; |
| 1659 | print CGI::endform(), "\n"; |
1896 | print CGI::endform(), "\n"; |
| … | |
… | |
| 1661 | print '</div>'; |
1898 | print '</div>'; |
| 1662 | print '<div style="clear:both;"></div>'; |
1899 | print '<div style="clear:both;"></div>'; |
| 1663 | # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { |
1900 | # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { |
| 1664 | |
1901 | |
| 1665 | # } |
1902 | # } |
| 1666 | |
1903 | # end big wrapper div that will hopefully fix theme issues |
| 1667 | |
1904 | print '</div>'; |
| 1668 | return ""; |
1905 | return ""; |
| 1669 | } |
1906 | } |
| 1670 | |
1907 | |
| 1671 | =head1 AUTHOR |
1908 | =head1 AUTHOR |
| 1672 | |
1909 | |