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();
