manlio Posted April 18, 2015 Share Posted April 18, 2015 Hi I'm looking for advices to choose the most flexible and rational approach to manage a specific task in my project. I have several users (instructors) that can request certification cards for their students and I would like to store all the requests made by every instructor. Usually at the end of a course the instructor can insert one certification card for every student (I have developed an ajax front end for this) and I store every card in a page. I'm thinking to structure every request like this (the parent is the certification number request of the instructor) username1 >1 >>card1 >>card2 >>card3 >2 >>card1 >>card2 username2 >1 >>card1 >2 >>card1 >>card2 >>card3 ecc... As an additional note I have italian instructors and international ones and I was thinking to create two different parents "Italian" and "International" that contain all the usernames My first idea is to store temporarly the cards pages under another page (for example "temp"), and as soon as the request is completed create the request number page (1, 2, 3, ecc...) and change the parent of the certification cards. I don't know if this is a good approach or if you have a better one. Thank you for any advice you can give me. Ciao Italian Link to comment Share on other sites More sharing options...
felix Posted April 18, 2015 Share Posted April 18, 2015 Normally you'd make every "entity" (instructors, (nationalitys,) courses, certificates) a template on it's own and create relations between them (ignoring the page tree setup - this is more of a personal preference). The tricky questions in this case are: - Are courses likely to be given several times by different instructors or is every course (like an event) only happening once? - Are the cards only related to the course (see question above) or also to the instructor? - Are there plans to add Countries / Languages in the future? I'd go with this setup if courses are "one time events": Instructors: - Instructor 1 - Single (Page-)Relation to Instructortype - Instructor 2 - Single (Page-)Relation to Instructortype [...] Courses - Course #1 - Multi (1:n) (Page-)Relation to Instructor - Course #2 - Multi (1:n) (Page-)Relation to Instructor [...] Cards - Certificate #1 - Single(?) (Page-)Relation to Course - Certificate #2 [...] Instructortypes - International - Italian Regarding the Cards: Just don't publish them until they're valid. After a course is finished (timestamp check) just delete all unpublished cards related to the course. Example code for this setup: // get all (valid) cards for course with ID "42" wire('pages')->find('template=card, course.id=42'); // get all instructors for italian courses wire('pages')->find('template=instructor, type.title=italian'); // get all courses from Instructor 1 wire('pages')->find('template=course, instructor.title=Instructor 1'); Link to comment Share on other sites More sharing options...
manlio Posted April 21, 2015 Author Share Posted April 21, 2015 Thank you Felix for your helpful suggestions, and sorry for delay in my reply. I was thinking about page tree just for convenience and readability, but in the end with lister pro I have no problem retrieving data and using your approach I think have lot more flexibility (by the way, some parts of the project are already running in this way). I also would like to ask which is the better strategy to maintain the progressive numbering of card's requests. So every cards should contain a text field in which I store the request number. I want to have the flexibility that if something is wrong with second card request of an instructor, I can delete the second request and when the instructor recompile it the number will be again 2 and not 3. I found this in another thread, is the right thing to do? $val = $pages->find("template=mytempl, sort=-counter, limit=1")->first->counter + 1; Thank you Link to comment Share on other sites More sharing options...
felix Posted April 22, 2015 Share Posted April 22, 2015 I don't think I understand your question What second request? And what gets recompiled? Link to comment Share on other sites More sharing options...
manlio Posted April 22, 2015 Author Share Posted April 22, 2015 Sorry my bad!! And please, forget recompile Thanks for taking time although my previous bad reply. I try to explain better what is happening. At the end of a course, an instructor insert data for all his students (stored as pages in PW) and when finished, he clicks "submit card request" . The request is sent to the secretary (p.e. an email that contains all student data info ) that can produce physical certification cards for every students. My question is how to manage the incremental numbering of the requests for every instructor. For example if I'm an instructor and I've just completed my 4th course with 25 students, I insert 25 students data and then I send the request. I would like to show something like: "request n° 4".. Sometimes happens that some instructor send a wrong certification card request and I need to delete that. Than I ask the instructor to redo the request with correct data and would like that the request counter would be something progressive like 1,2,3,4,5... and not like 1,2,4,5... I was thinking that if I store request counter value inside every student data page/record, if I delete a request I have to reset request counter on all student data by hand (or with lister or API). Maybe in this case the tree could be an advantage? if I have the request number as a parent it is easier to change it. 1 //request number > student data 1 > student data 2 > student data 3 3 //I need to change only this to 2 > student data 1 > student data 2 Hope it is little more clear. Thank you again. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now