Plaintiff Charles D. Keller, a federal prisoner, has sued the federal government to recover damages for an assault by another prisoner that he suffered in the United States Penitentiary in Terre Haute, . Indiana. Keller appeals from a grant of summary judgment in the government’s favor, so we must consider the evidence in the light most favorable to him and draw all reasonable inferences in his favor. Parrott v. United States, 536 F.3d 629, 630-31 (7th Cir.2008). Accordingly, we must assume the facts are as stated in this opinion, but without vouching for their objective truth.
When Keller was admitted to the Terre Haute facility, he told the intake psychologist, Dr. Joseph Bleier, that he suffered from mental illness that affected his ability to function and feared that he would be attacked if he were placed in the general prison population. Dr. Bleier nevertheless placed Keller in the general population. While on his way to lunch on October 25, 2007, Keller was attacked by another inmate without provocation. The attack lasted several minutes without intervention by guards. Keller was beaten brutally and left lying unconscious in the prison yard. The attack occurred at the base of prison watchtower 7, which stands at the boundary between Units 1 and 2 of the prison yard. No prison guard saw the attack. Keller was eventually spotted lying face-down and unconscious on the ground. Examinations by the prison medical staff and a nearby hospital emergency room revealed extensive injuries to his face and head.
Keller filed suit against the United States under the Federal Tort Claims Act, see 28 U.S.C. § 2674, alleging that the attack resulted from the prison’s negligence. He argues that several prison employees violated mandatory regulations and orders governing their conduct, thus allowing the attack to occur and continue. According to Keller, Dr. Bleier did not examine all of his available medical documents before deciding to release him into the general prison population, as required by applicable regulations. Keller also contends that the prison guards assigned to Tower 7, Unit 1, and Unit 2 failed to monitor their assigned areas of the yard because they were lazy or inattentive in violation of their post orders. The district court granted the government’s motion for summary judgment based on the discretionary function exception to liability under the Act. See 28 U.S.C. § 2680(a). This appeal followed.
The Federal Tort Claims Act (FTCA) gives district courts exclusive jurisdiction over claims “for injury or loss of property, or personal injury or death caused by the negligent or wrongful act or omission of any employee of the government while acting within the scope of his office or employment, under circumstances where the United States, if a private person, would be liable to the claimant in accordance with the law of the place where the act or omission occurred.” 28 U.S.C. § 1346(b)(1); see also 28 U.S.C. § 2674. Prisoners can sue under the FTCA “to recover damages from the United States Government for personal injuries sustained during confinement in a federal prison, by reason of the negligence of a government employee.” United States v. Muniz, 374 U.S. 150, 150, 83 S.Ct. 1850, 10 L.Ed.2d 805 (1963); see also, e.g., Coulthurst v. United States, 214 F.3d 106 (2d Cir.2000) (allowing prisoner to pursue *1023FTCA claim); Bultema v. United States, 359 F.3d 379 (6th Cir.2004) (same); Gil v. Reed, 381 F.3d 649, 659 (7th Cir.2004) (same); Mackovich v. United States, 630 F.3d 1134 (8th Cir.2011) (same).
This waiver of the United States’ sovereign immunity is limited by several exceptions, including the discretionary function exception codified in 28 U.S.C. § 2680(a). The exception is in the second half of a provision that states in full: “The provisions of this chapter and section 1346(b) of this title shall not apply to — (a) Any claim based upon an act or omission of an employee of the Government, exercising due care, in the execution of a statute or regulation, whether or not such statute or regulation be valid, or based upon the exercise or performance or the failure to exercise or perform a discretionary function or duty on the part of a federal agency or an employee of the Government, whether or not the discretion involved be abused.”
Case law elaborates the scope of this discretionary function exception. Two requirements must be met. First, the act involved must be discretionary in the sense that it “involves an element of judgment or choice.” Palay v. United States, 349 F.3d 418, 427 (7th Cir.2003), quoting United States v. Gaubert, 499 U.S. 315, 322, 111 S.Ct. 1267, 113 L.Ed.2d 335 (1991) (internal formatting omitted). This means that where an employee deviates from a course of action prescribed by federal statute, regulation or policy, the employee’s acts are not immune from suit. Gaubert, 499 U.S. at 322, 111 S.Ct. 1267; Berkovitz v. United States, 486 U.S. 531, 536, 108 S.Ct. 1954, 100 L.Ed.2d 531 (1988); Palay, 349 F.3d at 427. Second, “the exception protects only governmental actions and decisions based on considerations of public policy.” Gaubert, 499 U.S. at 322, 111 S.Ct. 1267; Palay, 349 F.3d at 427-28; Calderon v. United States, 123 F.3d 947, 949 (7th Cir.1997).
The discretionary function exception is an affirmative defense to liability under the FTCA that the government must plead and prove. Parrott v. United States, 536 F.3d 629, 634-35 (7th Cir.2008); Reynolds v. United States, 549 F.3d 1108, 1112 (7th Cir.2008); Stewart v. United States, 199 F.2d 517, 520 (7th Cir.1952); S.R.P. ex rel. Abunabba v. United States, 676 F.3d 329, 333 n. 2 (3d Cir.2012) (collecting cases from other circuits). To support summary judgment under the exception, the government must offer evidence that shows beyond reasonable dispute that its conduct was shielded by the exception. The district court, however, placed the burden on Keller to prove that the exception did not apply. This was a legal error that requires reversal unless the error was harmless.
The government argued in its summary judgment briefs that the discretionary function exception always shields the government from liability for inmate violence, citing our decision in Calderon v. United States, 123 F.3d 947 (7th Cir.1997). That argument substantially overstates our holding in Calderon and overlooks other cases on point. See, e.g., Parrott, 536 F.3d at 638 (reversing summary judgment based on discretionary function exception where prisoner alleged guards failed to comply with order separating him from another prisoner); Palay, 349 F.3d at 432 (reversing dismissal on pleadings based on discretionary function exception where prisoner alleged guards’ negligence allowed other prisoners to beat him). “Unstated but implicit in Calderon is the assumption that prison officials in that case had taken note of the threats against the plaintiff in that case and weighed the relevant considerations in deciding how best to act (or not) in response to those threats.” Palay, 349 F.3d at 432.
*1024By contrast, if prison officials behaved negligently without making a discretionary judgment of the type shielded by the exception, the discretionary functiqn exception would not apply to their conduct. Id. Prison guards who “left the unit unattended in order to enjoy a cigarette or a snack,” for example, would not be covered by the exception, because they would not have made the kind of discretionary judgment that the exception is designed to protect. Id. In other words, if prison personnel violate a mandatory regulation, the exception does not apply because “there is no room for choice and the action will be contrary to policy.” Gaubert, 499 U.S. at 324, 111 S.Ct. 1267; see also Parrott, 536 F.3d at 638.
Here, Keller has alleged that both the intake psychologist and the prison guards assigned to monitor the relevant sections of the yard violated mandatory regulations that governed their conduct. Unlike the guards in Calderon, Keller argues, the guards and intake psychologist in this case did not exercise discretion allowed to them under «applicable regulations, but rather failed to comply with mandatory regulations and orders. If that is the case, then their alleged negligence would not fall within the scope of the discretionary function exception. See Gaubert, 499 U.S. at 324, 111 S.Ct. 1267; Parrott, 536 F.3d at 638; Palay, 349 F.3d at 432.
At this stage, the record in this case presents a situation similar to Parrott v. United States, 536 F.3d 629 (7th Cir.2008). Parrott, also a federal prisoner at the Terre Haute facility, alleged that prison guards violated a mandatory separation order so that another inmate was able to attack him. We reversed summary judgment for the government because the discretionary function exception would not protect the government from liability under those circumstances. Parrott, 536 F.3d at 638. We see no reason to take a different approach in this case. We reject the government’s argument that all prisoner attacks fall within the discretionary function exception.
We therefore turn to the record to determine whether the discretionary function exception applied in this case. We cannot conclude, based on the evidence in the record, that the exception necessarily shields the government from liability for the attack on Keller. Keller contends that both the intake psychologist who screened him upon arrival at the Terre Haute facility and the prison guards assigned to Units 1 and 2 violated mandatory orders before the attack. According to Keller, the intake psychologist did not examine all of his available medical documents, as required by applicable regulations, before deciding to release him into the general prison population. Keller also argues that the prison guards assigned to Unit 1 and Unit 2 failed to monitor their assigned areas of the yard because they were lazy or inattentive, violating their post orders.1
The scant record available to both the district court and this panel makes it difficult to determine what procedures and regulations applied to the intake psychologist and prison guards at the Terre Haute facility. The government objected to nearly all of Keller’s discovery requests on the ground that releasing the information requested to a prisoner would create safety concerns. A magistrate judge reviewed the disputed documents in camera, concluded that many were not relevant to Keller’s case, and allowed the government to release the rest in heavily redacted *1025form. The district court did not have the unredacted documents before it when it ruled on the government’s summary judgment motion, which was based on the court’s determination that the documents contained no mandatory procedures or directives violated by the prison guards stationed at Units 1 and 2.
These extensive redactions make it impossible for this court to ascertain exactly what regulations and procedures governed the conduct of the intake psychologist and the prison guards. The information we do have, however, suggests that both the intake psychologist and the prison guards were subject to specific regulations and orders governing their conduct. For example, we know from the record that Program Statement 5824.07 requires psychology services to “develop local procedures to clear inmates with a PSY ALERT assignment,” which suggests that the Terre Haute facility had mandatory local procedures that needed to be followed when clearing inmates. Dr. Bleier’s affidavit similarly refers to procedures used to clear inmates like Keller who had a “PSY ALERT.” Those procedures are not in the record, and in their absence, we cannot conclude as a matter of law that they did not constrain Dr. Bleier’s discretion to place Keller in the general population.2
The government has also failed to establish that the actions of the prison guards assigned to Units 1 and 2 are protected by the discretionary function exception. The government relies on the declaration of a prison administrator that guards assigned to different areas of the compound are interchangeable and that guards do not need to be in any particular area at any given time. However, the heavily redacted documents in the record suggest that prison guards are assigned to specific areas of the yard and are required to monitor their areas and to respond to emergency situations within them. In other words, guards cannot choose, at least without a good reason, to stop monitoring their assigned areas without violating their explicit responsibilities under the post orders. Keller alleges that the guards stopped monitoring their assigned areas as required by the post orders because they were lazy and inattentive. There is no evidence to the contrary in the record. Based on the summary judgment record, then, we cannot conclude as a matter of law that the guards’ behavior is shielded by the discretionary function exception.
If as the government suggests in its brief the guards made a “policy” choice that caused them to neglect an area of the yard because they were pursuing other policy objectives within their discretion (such as walking the perimeter or supervising trash collection), then perhaps that would be shielded by the discretionary function exception. But there is no evidence to that effect in the record, and the government’s say-so in its briefs is not enough to support summary, judgment. The government points to no evidence in the record to contradict Keller’s claims that the guards were simply lazy or inattentive. “That type of carelessness would not be covered by the discretionary function exception, as it involves no element of choice or judgment grounded in public policy considerations.” Palay, 349 F.3d at 432.
*1026Accordingly, we conclude that the government did not sustain its burden to prove as a matter of law that the discretionary function exception shielded it from liability for the brutal attack that seriously injured Keller. Summary judgment was improperly granted for the government on that basis, and the district court’s error was not harmless.
We do not reach Keller’s claims that the district court abused its discretion in denying his motion to compel discovery or his motion for appointment of counsel. Keller is free to pursue further discovery on remand, and can of course renew his motion for appointment of counsel as well. We note in closing, however, that the district court may wish to revisit its determination on both matters in light of this opinion. See Parrott, 536 F.3d at 638-39 (finding that district court had abused its discretion in handling injured prisoner’s discovery requests). The district court’s resolution of the discovery disputes in this case resulted in a record so limited that it could not support summary judgment for the government. A better-developed record would have allowed the district court and this court to assess better the merits of the government’s motion for summary judgment.
We REVERSE the district court’s grant of summary judgment and REMAND the case for further proceedings consistent with this opinion.