You need to rearrange the relationships here:
TEACHER
|
opens --- approves --- is attended by
| | |
COURSE -- LEARNER ----
You have a separate entity called a CourseOpening, representing a Course that was opened by a Teacher. A Learner can attend a Course, but only if opened by a Teacher, and the Teacher has approved the Learner to that Course. So the Learner is foreign-keyed only against this new table, and therefore you can also enforce that they are approved by the Teacher for that same opening.
You can probably combine the approval and attendance into the same table, although you don't have to, as you can foreign-key one against the other.
CREATE TABLE Teacher (
Id int IDENTITY PRIMARY KEY,
Name varchar(100) NOT NULL
..
);
CREATE TABLE Course (
Id int IDENTITY PRIMARY KEY,
Name varchar(100) NOT NULL
..
);
CREATE TABLE Learner (
Id int IDENTITY PRIMARY KEY,
Name varchar(100) NOT NULL
..
);
CREATE TABLE CourseOpening (
CourseId int NOT NULL REFERENCES Course (Id),
TeacherId int NOT NULL REFERENCES Teacher (Id),
PRIMARY KEY (CourseId, TeacherId),
);
CREATE TABLE LearnerCourse (
CourseId int NOT NULL,
TeacherId int NOT NULL,
LearnerId int NOT NULL REFERENCES Learner (Id),
IsApproved bit NOT NULL,
IsAttending bit NOT NULL,
PRIMARY KEY (CourseId, TeacherId, LearnerId),
FOREIGN KEY (CourseId, TeacherId) REFERENCES CourseOpening (CourseId, TeacherId)
);
As you can see, a Learner can only be approved or attend a Course which has been opened by a Teacher.