The three-colleges law (sanshefa 三舍法), full designation sanshe kaoxuan fa 三舍考選法 "law on the examination in the three colleges" or sanshe xuancha shengbu fa 三舍選察升補法 "law on examination and promotion in the three colleges" regulated the introduction of the three colleges in the National University (taixue 太學) during the reign of Emperor Shenzong 宋神宗 (r. 1067-1085) of the Northern Song dynasty 北宋 (960-1126). It is often counted as one of the reforms carried out by the politician Wang Anshi 王安石 (1021-1086).
In 1071 the students enrolled in the National University were distributed over three colleges, namely the Outer College (waishe 外舍), the Inner College (neishe 内舍), and the Superior College (shangshe 上舍). New students were first attending the Outer College. The number of students enrolled there was not limited in the beginning (later limited to 700, and in 1079 raised to 2,000), and examinations were held twice a year. Students passing the exam were rising into the Inner College, where 200 (later 300) places were reserved. The Superior College was instructing 100 students. Successful candidates with excellent grades were directly appointed to state offices. Those with acceptable grades could directly attend the palace examination (dianshi 殿試, see examination system), the highest one in the examination system, and mediocre results allowed students to directly participate in provincial examinations (shengshi 省試).
Statutes for the colleges with 140 articles were issued in 1079. They regulated the procedures of various examinations (entrance exams, bushi 補試; individual exams, sishi 私試; collective exams, gongshi 公試; and college exams, sheshi 舍試), and the conditions under which students were promoted to a higher educational level. Individual exams were held monthly, collective ones annually, and college exams each second year (for students in the Superior College). These rules were twenty years later applied to all educational institutions (see schools) in the empire. In 1104 the examinations (keju kaoshi 科舉考試) in the commanderies and prefectures were abolished, and promotion in the educational system was made according to the three-colleges principle. There was an annual quota of students each prefecture could send to the colleges, namely one for the Superior College, and two for the Inner College.
Yet many officials argued that the new system just benefitted the rich and the young and was thus less fair than the conventional examination system. Sons and younger brothers of officials, for example, were allowed to enroll without being examined for their skills. The local application of this system was therefore given up in 1121, and it was retained for the National University, and also for military examinations (wuxue 武學) and the schools for members of the imperial clan (zongxue 宗學).
Students of the colleges were trained in just one of the Confucian Classics, depending on the institution they were applying for, but also in arithmetics and the basics of medicine. The study programmes of the two lower colleges were scheduled for one year, and that of the Superior College for two years.
One of the aims for introducing the Three-Colleges system was to set the focus more on conventional literature, while the Classics and their exegesis played a minor role. Wang Anshi desired to educate candidates with the moral principles found in the ancient Classics. His own commentaries Sanjing xinyi 三經新義, offering new interpretations on the Classics Shijing 詩, Shangshu 書 and Zhouli 周禮, were therefore part of the curriculum. Students were living in one of eighty lodges (zhai 齋), with 30 persons per lodge.