Dear Sir/Madam,
I am building a course platform. Below is the relationship between the different custom posts and custom field
Course - course is an unique custom post, it contains predefined teaching materials
Class - class is the child of a course, student register as WP user and apply application to enroll into a class, it also contains custom teaching materials designed by teacher which is similar to course but not the same to every class
Student - a custom user role to define a WP user is a student or normal user
Teacher - a custom user role to define a WP user is a teacher or normal user
Application - student enroll an application and application is linked to a class
When a student logs in and visits the class, he/she will redirect to a course panel which will list out all the materials belong to the course and the custom created by the teacher.
My question is about:
Question 1
When a student enrolls in a class, I create an application custom post and build the relationship between student and class, the application's author field is linked to the student and there is a custom field linked to the class. How can I make the relationship between a class (custom post) and a teacher (custom user role)? The relationship between class and teacher is many-to-many ( class >-< teacher ).
Question 2
A class is a child of a course, so when a student logs into and visits a class, all materials belong to the course will be shown and of course, all the materials created by the teacher linked to this class will also be shown. How can I get the materials from the course as I only know the student visiting which class (post id)
Is it a complicated relationship, hope you can instruct me the direction how I can build up all the relationship between all custom post and custom user role.
Best regards,
Kelvin.
Hi Kelvin,
Thank you for contacting us and I'd be happy to assist.
Based on the information you've shared, I'll recommend adding two more custom post types:
1. Student Profiles
2. Teacher Profiles
These two custom post types will be useful because, relationships can only be added between two post types and not between a WP user and a post type.
Whenever a new student or teacher user registers and logs in to the website, he/she can be made to create a "Student Profile" post or a "Teacher Profile" post, respectively, The user who adds this post will be set as the post author and each student or teacher user can only have 1 student or teacher profile.
Once, you'll have this anchoring post type that represents an individual user, linking them to the desired custom post type will be become simpler. With this approach, you'll no longer need the "Application" custom post type either.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Dear Waqar,
Thanks for your reply. I got your mean of Teacher Profile but how about if the school admin has to count the number of applications as the report? For a student who withdraws from a class, I can simply change the custom field to the application to indicate the status of an application or if an application is a subscription based, I can mark the expiry date of the application to restrict the student to access the class.
What are the pros and cons to the Student Profile in this case?
Best regards,
Kelvin.
Thanks for writing back and sharing further details.
If application tracking is required, you can keep the "Applications" post type. The flow of the class enrollment in this case would be:
1. A student comes to the website and fills the form to create a new "Application" post, selecting a "Class" post to enroll in.
( A one-to-many relationship will exist between "Classes" and "Applications" post type )
The student user will be linked to this application as a post author.
2. The website's admin can approve or reject the application using either application post status or a custom field.
3. Whenever, you'll need to get all the classes a student is enrolled in, you'll get all the approved "Applications" posts where he/she is the author, and then get the "Class" post linked to that "Application".
With this "Application" post type in place, I don't see much value in adding the "Student Profiles" post type and it will just add more steps and clutter in the process.