[LON-CAPA-cvs] cvs: loncom /debugging_tools find_bad_problem_metadata.pl

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 27 Sep 2006 19:36:28 -0000


albertel		Wed Sep 27 15:36:28 2006 EDT

  Added files:                 
    /loncom/debugging_tools	find_bad_problem_metadata.pl 
  Log:
  - helper that attempts to quickly validtae metadata
  
  

Index: loncom/debugging_tools/find_bad_problem_metadata.pl
+++ loncom/debugging_tools/find_bad_problem_metadata.pl
use strict;
use warnings;
use lib '/home/httpd/lib/perl';
use File::Find;
use LONCAPA::Configuration;

my  $perlvar= &LONCAPA::Configuration::read_conf('loncapa.conf');

sub validate_parameter {
    my ($contents) = @_;
    foreach my $line (@{ $contents }) {
	return 1 if ($line =~ m/<parameter /);
    }
    return 0;
}


sub validate_meta {
    # only want to check problem metadata
    return if ($_!~m/\.problem\.meta$/);
    # can't do anything about old ones
    return if ($_=~m/\.\d+\.problem\.meta$/);
    # don't worry about the templates
    return if ($_=~m{/templates/});
    open(FILE,$_);
    my @contents = <FILE>;
    if (!&validate_parameter(\@contents)) {
	print("$_ parameters missing\n");
    }
}

sub main {
    find(
	 {
	     no_chdir   => 1,
	     wanted     => \&validate_meta,
	 }, 
	 $perlvar->{'lonDocRoot'}
	 );
}

&main();