Jump to content
MakeWebGames

Not sure where to start?


Razor42

Recommended Posts

Right so I have been re-coding the education system so that staff members can create grades which the courses will be added into, for a player to move onto a next grade so they must complete all classes in grade one .i.e. Grade 1 includes courses- attacking, defending & working then grade 2 includes- attacking advanced, defending advanced & working advanced. For players to do any of the courses in grade 2 they must complete all courses in grade 1.

Not sure where to start really with this so some pointers in the right direction would be great.

P.S. All staff files are re-coded and working its just the education.php I need help with.

Thank you.

Link to comment
Share on other sites

Think logically, for this to work you need only have some form of requirements that must be completed first. Assuming all you need is certain key courses to be complete prior to starting a new one, then the data structure becomes somewhat apparent:

Data Structures and Sample Data and Resulting "Tech" Tree

Edit: Addition of a little SQL to fetch the entire (cacheable) course list:

Edited by Octarine
Link to comment
Share on other sites

CREATE TABLE `grades` (

`grade_id` INT(11) NOT NULL AUTO_INCREMENT,

`grade_name` varchar(255) NOT NULL,

PRIMARY KEY(grade_id)

) ENGINE=MyISAM ;

Thats the MySQL's for my grades tables, I'm thinking I would need to add another column in either the courses tables or grades tables. Then when a staff member creates a course it will add the course id or even just +1 so that their is something which shows which or how many courses their are in this grade. then when someone completes a grade this would then remove the course id or -1 depending on how I did this. One thing is how would I make it so everytime a course is created it +1's to that exact grade number? And how would I make it so that everytime a grade is created, it gets its own grade_count?

Link to comment
Share on other sites

You are going in a different direction; why make it overly complex. ""Grades"" can be looked at as different courses in which case my original answer stands, or they can be looked as the same course with a modifier. Which you choose is dependant on your exact needs, but in either case you will need some for of course_completed table tracking the user ID, the course ID (and in your case, the grade they have reached).

Link to comment
Share on other sites

Why not put them in tiers?

For example;

  • Add a new column to the courses table, named `tier` (numeric)
  • Add a new column to the users table, named `tier` (numeric) (default: 1)
  • Put each course into a `tier` (1, 2, 3, 4...)
  • When starting a course, that isn't `tier`= 1, do the following check.
  • When completing a course, do this process.

 

That sir, I think, should do the trick.

Edited by sniko
Link to comment
Share on other sites

Why not put them in tiers?

For example;

  • Add a new column to the courses table, named `tier` (numeric)
  • Add a new column to the users table, named `tier` (numeric) (default: 1)
  • Put each course into a `tier` (1, 2, 3, 4...)
  • When starting a course, that isn't `tier`= 1, do the following check.
  • When completing a course, do this process.

 

That sir, I think, should do the trick.

 

I could hug you right now Sniko, This will help me out SO much with my crimes and gang school

Link to comment
Share on other sites

Why not put them in tiers?

For example;

  • Add a new column to the courses table, named `tier` (numeric)
  • Add a new column to the users table, named `tier` (numeric) (default: 1)
  • Put each course into a `tier` (1, 2, 3, 4...)
  • When starting a course, that isn't `tier`= 1, do the following check.
  • When completing a course, do this process.

That sir, I think, should do the trick.

Please stop using CodePad (or at least provide alternatives to, when CodePad decides to do it's loading fits. >_<)

Link to comment
Share on other sites

Because I'm Indie ;) haha, sure, I'll revert to the mainstream pasters.

You can still use codepad, just please provide an alt link too, for those that cannot access codepad occasionally. :)

@Razor42: Sorry.

Could have been worse we could have started talking about some random stuff, rather than the code he posted to help you (or rather the platform the code exists on.)

Link to comment
Share on other sites

Still off topic ;)

And you realize all these posts of yours (and now this one included) are contributing towards the off-topic direction the thread is heading.

If you've solved your problem, then please tell us as we can then close the thread, if not also mention you haven't (as a few suggestions have been given), then we can get back to helping you.

And in a sense it was beneficial for me to mention the "off topic" discussion due to the fact if people can not access the code, Sniko's reply was almost pointless to those looking for help with the same problem you are having. ;)

Link to comment
Share on other sites

I took it into a different direction. Made it so that staff members set a required amount of courses complete to be able to enter a grade. If you haven't completed the set number of courses then you simply can't enter that grade and do the courses in it. I am having problems and unsure what i'm doing but i'm sure ill get it sorted. Thanks for your help Sniko it was much appreciated and also thank you Octarine.

Link to comment
Share on other sites

Something I need a little help on...

I want it so that when players click a grade link it takes them the courses within that grade. So far I have..

print "Hello and welcome too school. Before doing a course, you must first select a grade....<br />
<table width=75% cellspacing=1 class='table'><tr style='background:gray;'><th>Grade</th><th>Required Courses Complete</th><th>Enter</th></tr>";
while($r=$db->fetch_row($q))
{
$enter="<a href='education.php?gcourses={$r['grade_id']}'>Enter</a>"; 
print "<tr><td>{$r['grade_name']}</td><td>{$r['crREQUIRED']}</td><td>$enter</td></tr>";
}
print "</table>";

 

The part im unsure about is:

$enter="<a href='education.php?gcourses={$r['grade_id']}'>Enter</a>";

 

I know that at the moment that wouldn't work but i'm unsure what to do to make it so that when Enter is clicked they go to the courses within that grade. The column where the id of the grade in that course is called crGRADE.

Link to comment
Share on other sites

In the code, your grammar is incorrect - not a good view to players, anyway, I'll fix that up for you ;)

 

print "Hello and welcome to school. Before doing a course, you must first select a grade....
<table width=75% cellspacing=1 class='table'><tr style='background:gray;'><th>Grade</th><th>Required Courses Complete</th><th>Enter</th></tr>";
while($r=$db->fetch_row($q))
{
/* Is it `grade_id` or `crGRADE` */
$enter="<a href='education.php?gcourses={$r['grade_id']}'>Enter</a>"; 
print "<tr><td>{$r['grade_name']}</td><td>{$r['crREQUIRED']}</td><td>$enter</td></tr>";
}
print "</table>";

 

Now, do this

/* Filter & Sanitize */
$grade = filter_var($_GET['gcourses'], FILTER_VALIDATE_INT) ? abs( (int) $_GET['gcourses'] ) : 1;

/* Fetch them */
$get = $db->query("SELECT [... something ...] FROM [... table ...] WHERE `crGRADE` = ". $grade);

while( $r = $db->fetch_row($get) ) {
  /* Display data */
}

 

I think that's what you're after ;)

Edited by sniko
Link to comment
Share on other sites

Where abouts would I enter that? Above he initial print?

 

Either use the switch() method, or a different page...

 

<?php
include_once('globals.php');

switch($_GET['action']) {
  case 'choose_a_grade' : choose_a_grade(); break;
  case 'chosen_a_grade' : chosen_a_grade(); break;
  default: choose_a_grade(); break;
}

function choose_a_grade() {
/*
  -- Paste the script that gives the user the ability to choose  grade
  -- Ensure you include the action in the href of the chosen grade, for example
     <a href="?action=chosen_a_grade&grade=x">Grade X</a>
*/
}

function chosen_a_grade() {
/*
  -- Paste the script that gives the user the information after they've
     chosen a grade
*/
}
?>
  • Like 1
Link to comment
Share on other sites

Lol sorry for the fact that I needed help. If you feel that way then go ahead and close the thread.

Oh someone is a little testy.

My remark was simply this, if your problem had been solved (due to the many "Thanks" and suggestions offered) then please tell us, we'll close the thread (ala: stop off-topic posts).

If your problem hadn't been solved by the suggestions posted (how would we know?) then also tell us, and we'll continue to help.

;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...