This is an application on behalf of the relator for mandamus to compel the defendant school district and its codefendant, the principal of one of its public schools, to receive and enroll in said school, Ralph Gr. Ranney, the infant son of the relator, six years old. The alternative writ, issued upon the relator’s petition on the 13th day of November, 1905, states that on the sixth, seventh and eighth days of November of that year he and his said son, who was then of school age and entitled -to enrollment as a pupil in the said school, demanded of respondents that he be enrolled and instructed therein, but that the said principal of the school and the president and directors of the school district wrongfully and wilfully, .in abuse of their authority and without just cause or excuse, refused so to enroll him, and on each of said days ordered him to return to his home; and that they then and there refused and still refuse to instruct him or in any manner recognize him as a pupil in said school for the following reason and no other: “That said Ralph Gr. Ranney had neglected or failed to apply for enrollment in said school on the first day of the term thereof, and that said president and directors of said school district, respondent, had made a rule by which pupils are not enrolled in the first grade, except at the beginning of each half-term, or during the first week of the same.” The writ further stated “that said rule is arbitrary, unreasonable and oppressive, and made without authority of law, and is in derogation and contravention of the rights of relator and *673Ms said cMld under section 1, article 11, of the Constitution of the State of Missouri.”
That said writ, following the petition therefor, commands the respondents to “receive and enroll in the public school of the city of Cape Girardeau the said Ralph G. Ranney whenever requested so to do by the said Robert G. Ranney, his father; and . . . at all times during the terms of school and during the school hours thereof to teach and instruct the said Ralph G. Ranney in all the branches of learning taught in said school, or that you appear before the Cape Girardeau Circuit Court, at the city of Jackson, on the first day of January, 1906, at two o’clock p. m., to show cause for your refusal so to do.”
The writ was served on the day of its issue. The respondents appeared on the return day, and after-wards, on August 27, Í906, filed their return. It states that relator’s son was only six years old at the time of his application, and admits all the allegations of the writ except that the rule pleaded “is arbitrary, unreasonable and oppressive and made without authority of law, and is in derogation or contravention of the rights of the said relator and his child under section 1, article 11, of the Constitution of the State of Missouri,” and “that in enforcing the said rule as aforesaid they acted wrongfully, illegally, oppressively, wilfully and in abuse of their authority and contrary to law and without just cause and excuse;” all of which they expressly deny.
They then plead with sufficient detail substantially that during the five years next preceding November, 1905, the population of the city of Cape Girardeau increased from about five thousand to about ten thousand. The population of the said school district was practically doubled during that- time; that the schools of the district were very much crowded; that the first grade room in the Lorimier School, which the relator’s *674child was entitled at proper times to enter, had a seating capacity of fifty scholars; that the enrollment of said grade in that room for the school month beginning October 30, and ending November 24, 1905, was fifty-five, with an average attendance of forty-eight; that the same crowded condition existed in the other schools; that the school year in that district consisted of thirty-six weeks, divided into four terms, and that relator and his son failed to apply for the admission of the son at the beginning of any half term, or during the first week thereof; “that the relator’s said child was admitted to the first grade of the said Lorimier School soon after the granting of the alternative writ of mandamus herein and then and there enrolled and has ever since been instructed and treated in all respects exactly like other children of the first grade in the said Lorimier School.”
The relator demurred to all that part of the return constituting the plea in avoidance above set out in substance, including the averment that relator’s child had already been admitted to and was, attending the school, on the following grounds: • “That said part of said answer does not state facts sufficient to constitute a defense to relator’s cause of action; that the allegations of said part of said answer are inconsistent with each other.”
The.demurrer was sustained by the court, and all of that part so demurred to was stricken out; and thereupon, the respondent declining to plead or otherwise proceed further, the court, without hearing evidence, adjudged that the writ be made peremptory.
This cause having been tried and decided upon the pleadings alone, the only question raised by the appeal is whether or not upon those pleadings, taken together, the trial court was wrong in its decision. Its action upon the demurrer to the return of the respondents, which it seems to have considered as a motion to strike out parts of that pleading, has no significance *675except in so far as it informs us of the theory upon which the case was disposed of. It stands here the same as if the final judgment of the court had been, entered upon a motion to make the writ peremptory upon the coming in of the return.
The alternative writ, issued and served November 13, 1905', after stating the exclusion of the relator’s child from the district school on the sixth, seventh and eighth days of the same month, sets out the rule of the board of education under which it was attempted to justify this action, and states “that said rule is arbitrary, unreasonable and oppressive and made without authority of law and is in derogation and contravention of the rights of relator and his said child under section 1, article 11, of the Constitution of the State of Missouri.” The power of the hoard of education “to make all needful rules and regulations for the organization, grading- and government in their school district,” is expressly given by the statute (R. S. 1899, sec. 9764), by which its nature and extent must he judged; with the qualification, however, that neither the Legislature, nor the hoard by its authority, can make or enforce any rule inconsistent with the constitutional requirement that these schools shall he maintained for the gratuitous instruction of all persons in the State between the ages of six and twenty years. From this constitutional mandate it necessarily results that the Legislature has power to authorize, and that the school authorities have power, to the extent of such authorization, to make such rules as shall he needful for the orderly conduct of the schools and to guard the moral and physical health of the pupils, so as to make them available to all alike who may he entitled to their advantages. These rules may, and some of them necessarily will, deprive some pupils tempor* arily of the' right to avail themselves of the facilities for instruction which they afford, hut all must he adapted to the promotion and accomplishment of the *676paramount object contemplated by the Constitution. They cannot arbitrarily and unnecessarily deprive any beneficiary of the Constitution of any part of the right guaranteed to him. Por example; a rule that no person should be enrolled in the public schools who had not attained the age of six years and one month would be evidently void, because tending only to defeat that object. On the contrary, a rule forbidding the attendance of persons afflicted with, smallpox would be evidently valid because it would tend to promote that object. Between these extremes lies a vast field for the exercise of this rule-making power, which depends, in some instances, upon local or temporary conditions of which the courts cannot take judicial notice, and to which their attention must therefore be directed by pleading and evidence. The fact that by their failure to demur to the alternative writ, and by the special plea in avoidance in their return, the respondents assume this case belongs to the class last mentioned, relieves us from any further consideration of that feature, and we may, and will, so far as is necessary, indulge the same assumption.
The wrong alleged in the alternative writ is the refusal of respondents to enroll relator’s son as a pupil in the school on the sixth, seventh and eighth days of November, 1905, and continuously up to the issue of the writ on the 13th day of the same month. It also states that such refusal was “for the following reasons and none other, to-wit: That said Ralph Gr. Ranney had neglected or failed to apply for enrollment in said school on the first day of the term thereof, and that said president and directors of said school district, respondent, had made a rule by which pupils are not enrolled in the first grade, except at the beginning of each half-term, or during the first week of the same. ” '
Upon service of the writ the respondents could obey it, or, in default of obedience, they might show *677cause against it (1) by demurrer, or (2) by return tendering issues of fact in justification of tbeir disobedience. In this case they made, nearly nine months after service, a return setting forth facts which they insist would have justified them had they chosen to disobey the writ, and also pleading “that the relator’s said child was admitted to the first grade of the said Lorimier School soon after the granting of the alternative writ of mandamus herein, and then and there enrolled, and has ever since been instructed and treated in all respects exactly like other children of the first grade in the said Lorimier School.” This averment is plain. It refers to the writ, and says that soon after its issue the respondents did the very act which it commanded. That it amounts to a return of unqualified obedience there can be no question. Even the rule, which only related to the initial step by which persons become pupils of the schools, their enrollment in the first and lowest grade, became functus officio as to relator’s child, and the controversy not only, but the subject of the controversy, ceased to exist. There was nothing in the mandate that respondents receive and instruct the child “at all times during the terms of school” which could prevent his exclusion for any cause thereafter accruing, or which gave it any additional force. The object of the peremptory writ of mandamus being to compel the performance of a specific act, when that act is performed the writ would be fruitless and should not issue. "When the performance is subsequent to the issue of the alternative writ the proper practice is to refuse to make it peremptory at respondent’s cost (State ex rel. v. Lafayette County Court, 41 Mo. 38), and that is the.judgment which should have been entered. Instead of doing this the trial court made the writ peremptory.
While this judgment affected no substantial right of the respondents, ordering them, as it did, merely to do something which they had already done, we think *678that its entry was such an error as we ought to correct on this appeal. The due and orderly conduct of judicial proceedings requires that a.final judgment should be for the one appearing to be the right party upon the whole record, notwithstanding any defect or error in the pleadings or proceedings which shall not affect the substantial rights of his adversary, and we see nothing in the terms of section 1850', Revised Statutes 1909, which requires that a judgment for the wrong party ought to remain upon the records of the court when properly questioned by appeal. Nor do we think there is anything in section 2553 which requires that costs be given one who obeys an alternative writ of -mandamus rightfully sued out against him.
For the reasons stated, and without expressing any opinion upon the force and effect of the rule of the respondent board of education in question otherwise than as to the effect given it by the pleadings for the purposes of this case only,, the judgment of the circuit court is reversed, and the cause remanded with directions to the circuit court to set aside its order striking out that part of the return stating that relator’s child had been enrolled and was being instructed in its school, and to enter judgment refusing to make ■ the alternative writ peremptory, and thát the costs in said court be adjudged against respondents in that suit, except the costs accruing upon the demurrer, including the setting aside of the order sustaining the same and the entry and vacation of the judgment appealed from, which shall be adjudged against relator. The costs of this appeal are adjudged against the relator.
.Blair, G., concurs. PER CURIAM.The foregoing opinion of Brown, C., is adopted as the opinion of the court.
All the judges concur.