Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-15-2011, 05:51 AM   PM User | #1
jmc0228
New to the CF scene

 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jmc0228 is an unknown quantity at this point
View different links on page depending on user level

Hi, I have very little knowledge of php so please talk to me as if you where talking to a kid

What I want to do is quite complicated, the best way to describe it is something like a game but I am not making a game is actually a website where people can take exams but I want them to view the links depending on their user level, for example:

1st year students on level 1 can view the first exam of the first book, once they take the first exam on book one I want php to automatically boost that person to level 2 of the first year (is not necessary, we can boost them ourselves but it be cool if it was done automatically) but I want the exams to appear as they take the other exams, for example once they take exam 1 and pass it I want the link to exam two appear on their user page automatically and I want that if possible to be all on one page.

I want to put all the links to main.php and I want for php to look in the database that user level, if the user is on year one level 42 (this course takes 4 years to complete and there's over 250 short exams per year) I want them to be able to see on the navigation bar on the left as a drop down menu: year one - book 3 - exam 8 for example. I hope you understand what I am trying to achieve.

I would like it to be all in one page because I don't want to end with 1,000 same pages with different links for the different levels, I know is not so hard to make php redirect the person to a different page depending on their level but I don't want that, I want it to be done in one page (all the links) and php to hide the other links that the student haven't gone to yet.

Can someone tell me if this is possible?
jmc0228 is offline   Reply With Quote
Old 07-15-2011, 07:54 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
It's 100% possible, but you'll have to learn more about PHP and MySQL (for the database).

You'll also have to also the ability to add users, modify them, and let them login ...
again, this is all PHP and MySQL. Not much else I can say except learn it, or hire
a freelance programmer.


.
mlseim is online now   Reply With Quote
Old 07-15-2011, 09:27 PM   PM User | #3
jmc0228
New to the CF scene

 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jmc0228 is an unknown quantity at this point
I know I little bit of php and mysql, I already have the database setup and the users can already register and sign in, that's working fine the only thing I want to learn is how to make php appear the links that the users need depending on their level. How to hide it and how to show it.

I already have it setup that if a user that is not logged in they can't see the page and I am pretty sure that is easy to make it that if they are not on a certain level they won't be able to see the page if someone on a higher level gives them the link. My only problem is to auto hide/show the links automatically.
jmc0228 is offline   Reply With Quote
Old 07-16-2011, 12:24 AM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
You create a column in your MySQL user table that contains a level code or number.
Example, all new users might be level 0 ... each level 1,2,3 ... offers different access.

When a user logs in, you create a SESSION variable that contains their access level.
You then have one PHP script that looks at their level and determines what they can
do ... that script is 'included' at the top of any other script you need to test or control.

If your decisions are made in the navigation part of a page, that would be the part
that you 'include', so all pages are using the same script to determine user access.


.
mlseim is online now   Reply With Quote
Old 07-16-2011, 12:25 AM   PM User | #5
myfayt
Senior Coder

 
Join Date: Apr 2010
Posts: 1,159
Thanks: 46
Thanked 96 Times in 95 Posts
myfayt can only hope to improve
This is really easy to do. How do you want it setup?
myfayt is offline   Reply With Quote
Old 07-16-2011, 01:08 AM   PM User | #6
jmc0228
New to the CF scene

 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jmc0228 is an unknown quantity at this point
I got the idea on my head and I know what you mean mlseim what I don't know is the code that I need. How is it that I do it, how do I tell php that second year students on level 90 can see up to book 5 exam 20. Do I need to be specific (tell php one by one what links can be displayed depending on the level because if is like that I'll end up with a huge code because there's like 1,000 links) or there's a mathematical or logical way to tell php to increment the level and show the next link when they pass the exam.

The way I want the links is that students from year two to be able to see all the previous links from all their previous exams, I want it to increment the level once the person passes the exam and if they don't (we decide that manually since most of the exam is fill in the blank) not to boost them to the next level.

I want to write all the links on the pages necessary, not to create a page with link 1, then another with links 1 & 2 and then another with links 1,2 & 3 because if I do that it will be endless.
jmc0228 is offline   Reply With Quote
Old 07-16-2011, 05:37 AM   PM User | #7
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Let's say that you don't have 1000 pages, but instead you have 1000 files that are
identified by a number. The numbers are incremental, and the user's level simply
is the current file number (exam) they are on. Anything less can be viewed, but they
can't have their level incremented until they finish that exam.

I don't know how your exams are created. If it were me, I would create them as PDF
files that people can actually enter things on (interactive PDF). Once completed, the
PDF copy that the person is using can be saved, or emailed. In any event, the exam
number is the user's level.

My main point is, you don't have 1000 HTML pages. Your exams should not be HTML.
That's my personal opinion.

And another thing, each person could be given the same exam, but the questions
in different order.

I suppose I don't know enough about what your project is. sorry.


.
mlseim is online now   Reply With Quote
Old 07-16-2011, 06:09 AM   PM User | #8
jmc0228
New to the CF scene

 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jmc0228 is an unknown quantity at this point
What you say sounds pretty good, I didn't know about interactive PDF, we have some exams in pdf files they can download and print and we had it also as a doc file. I was trying to do it as a form, with radio buttons, check boxes, input text and textareas but I'll take a look at interactive PDF it might be easier.

As for the project, all the students are given the same exams I just don't want them to take or see the exams before they get there, of course they can always get around it if someone else show them their copy but that's out of my hands.

This is what I have in mind:

User login page -> student front page where it shows them their year, book they are at and exam number and their current grade. on the left they have the exam nav since we have on the top nav bar the links to the whole website. The nav on the left will only have the links to the exams, something like this:

1st Year
Book one - title
exam 1
exam 2
Book two - title
exam 1
2nd Year
Book one - title
and so forth.

I want all the students to go to the same page, lets call it main.php but obviously with mysql php will retrieve their info from the database and display it on the page. I want to put all the links for all the exams of all the four years in main.php and that when that user info is retrieve, I want a piece of code to auto hide the links to the exams that they are not at yet, that's the code I am looking for, also I want to know how to link the exam links to the database user level.

As for the exams, like I said before I'll take a look at interactive PDF and if I go with that then the links that I want to show/hide will be the link to those files but I need to put them on a php page so that php can check on the database if that student can access that file. If there's another way it be better, like I said at the beginning, I am new at php and I don't know many options to do what I need, I am pretty sure there are a lot of different ways, I would like to know the best that accommodates to my needs or desires.

I tried to explain my project as best as I can, I know that you'll need as much info as possible to help me so if you have any question, ask freely and thank you very much for helping me.

Last edited by jmc0228; 07-16-2011 at 06:12 AM..
jmc0228 is offline   Reply With Quote
Reply

Bookmarks

Tags
access, different pages, links, php, user level

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:25 PM.


Advertisement
Log in to turn off these ads.