Permalink
Browse files

Merge pull request #9 from koopa/master

Course + PDO
  • Loading branch information...
2 parents 17dbee0 + ef4c011 commit 899675de45308516d7b6b2de341e044c70f250b3 @Roobarb Roobarb committed Oct 23, 2012
View
@@ -1,2 +1,4 @@
+.idea
+log.lua
private_settings.php
forum/cache/data*
@@ -1,74 +1,55 @@
-<?
+<?php
+$msg = !$loggedin ? $notloggedintext : '';
+return array(
+ 'nav' => array(
+ 'default' => array(
+ 'chapter1' => 'How IRC works',
+ 'chapter2' => 'IRC Security',
+ ),
+ 'exercises' => array(
+ 'exercise1' => 'Exercise 1',
+ ),
+ 'exam' => array(
+ 'exam1' => 'Exam',
+ )
+ ),
+ 'content' => array(
+ 'default' => array(
+ 'index' => <<<°
+ <h1>Internet Relay Chat (IRC)</h1>
+ <p>Under construction!</p>
+°
+ ,
+ 'chapter1' => <<<°
+ <p class="center">How IRC works</p>
+°
+ ,
+ 'chapter2' => <<<°
+ <p class="center">IRC Security</p>
+°
+ ,
+ ),
+ 'exercises' => array(
+ 'exercise1' => <<<°
+ <h3>Exercise 1:</h3>
+ <p>Nothing yet</p>
+°
+ ,
+ ),
+ 'exam' => array(
+ 'exam1' => <<<°
+ <h2>No Exam Time yet!</h2><br />
+ <form id="examnform" name="examnform" method="post" action="">
+ <div class="question">
+ <h3>Question 1</h3><br />
+ <p>Nothing yet</p>
+ <input type="radio" value="A" id="radio1" name="1" /><label for="radio1">bla</label><br />
+ <input type="radio" value="B" id="radio2" name="1" /><label for="radio2">bla</label><br />
+ <input type="radio" value="C" id="radio3" name="1" /><label for="radio3">bla</label><br />
+ </div>
+ </form>
+°
+ ),
+ )
+);
-require("courseheader.php");
-
-?>
-
-<div id="coursenavigation">
- <ol class="tree">
- <li class="file"><a href="#" onClick="selectPart('default')">Introduction</a></li>
- <li>
- <label for="theory">Theory</label><input type="checkbox" checked id="theory" />
- <ol>
- <li class="file"><a href="#" onClick="selectPart('chapter1')">Chapter 1</a></li>
- *** add more chapter links here ***
- </ol>
- </li>
- <li>
- <label for="exercises">Exercises</label> <input type="checkbox" checked id="exercises" />
- <ol>
- <li class="file"><a href="#" onClick="selectPart('exercise1')">Exercise 1</a></li>
- *** add more exercise links here ***
- </ol>
- </li>
- <li class="file"><a href="#" onClick="selectPart('examn')">Exam</a></li>
- </ol>
-</div>
-
-<div id="coursecontent">
-
- <div id="default">
- Default
- <p class="center"><a href="#" onClick="selectPart('chapter1')">>> Next Chapter >></a></p>
- </div>
-
- <div id="chapter1">
- Chapter 1
- </div>
-
- *** add more chapter content here ***
-
- <div id="exercise1">
- <h3>Exercise 1:</h3>
- <p>Exercise text</p>
- <div class="revealbutton" onClick="$('#answer1').show(); $('.revealbutton').hide(); ">Reveal Answer</div>
- <div class="answer" id="answer1">
- <p>Answer</p>
- </div>
- </div>
-
- *** add more exercise content here ***
-
- <div id="examn">
- <h2>Exam Time!</h2><br /><? if(!$loggedin) echo $notloggedintext; ?>
-
- <form id="examnform" name="examnform" method="post" action="">
-
- <div class="question">
- <h3>Question 1</h3><br />
- <p>Questiontext</p>
- <input type="radio" value="A" id="radio1" name="1" /><label for="radio1">Answer1</label><br />
- <input type="radio" value="B" id="radio2" name="1" /><label for="radio2">Answer2</label><br />
- <input type="radio" value="C" id="radio3" name="1" /><label for="radio3">Answer3</label><br />
- </div>
-
- *** add more questions here ***
-
- <div id="examnsubmit">
- <button>Submit</button>
- </div>
-
- </form>
-
- </div>
-</div>
View
@@ -23,24 +23,63 @@
?>
<div id="course">
<?
- //
- // Description: Load the course file specified by the GET variable 'id'
- //
+ $category = isset($_GET['category']) ? $_GET['category'] : null;
+ $course = isset($_GET['course']) ? $_GET['course'] : null;
+ $chapter = isset($_GET['chapter']) ? $_GET['chapter'] : null;
+ //TODO: implement static pages for non-js browsers (via url rewriting)
+ $mincourseid = 0;
+ $maxcourseid = 100000;
- $courseid = $_GET['id'];
- $errorstring = "<p class=\"center\"><img alt=\"Y U NO GIVE ID\" src=\"images/yuno.png\" /><br /><br />No active course, select a valid course from the overview!</p>";
- $filename = "courses/course".$courseid.".php";
- $mincourseid = 0;
- $maxcourseid = 100000;
+ $selectCourse = "<p class=\"center\"><img alt=\"Y U NO GIVE ID\" src=\"images/yuno.png\" /><br /><br />No active course, select a valid course from the navigation on the left!
+ </p>";
+
+
+ echo '<div id="coursenavigation">
+ <ol class="tree">';
+
+ foreach($categories as $id => $name){
+ echo '<li><a href="/course/'.urlencode($name).'"><label for="'.urlencode($name).'">
+ '.$name.'</label></a>
+ <input type="checkbox" id="'.urlencode($name).'" />';
+ if(count($tree[$id]) > 0){
+ echo '<ol>';
+ }
+ foreach($tree[$id] as $course){
+ echo '<li><a href="/course/'.urlencode($name)
+ .'/'.urlencode($course['title']).'"><label for="'.urlencode($course['title']).'">
+ '.$course['title'].'</label></a>
+ <input type="checkbox" id="'.urlencode($course['title']).'" />
+ <ol>';
+ $filename = "courses/course".$course['id'].".php";
+ if(is_readable($filename)){
+ $courseData = include($filename);
+ }
+ if($courseData['nav']) foreach($courseData['nav'] as $chapterType => $chapters){
+ if($chapters) foreach($chapters as $contentId => $chapterName){
+ //$chapterType class to style icons
+ echo '<li class="file '.$chapterType.'"><a
+ data-contentid="'.$contentId.'"
+ data-chapterid="'.$chapterName.'_'.$course['id'].'"
+ href="/course/'.urlencode($name)
+ .'/'.urlencode($course['title'])
+ .'/'.urlencode($chapterName).'">'.$chapterName.'
+ </a>
+ <script type="text/html" id="'.$chapterName.'_'.$course['id'].'">
+ '.$courseData['content'][$chapterType][$contentId].'
+ </script>
+ </li>';
+ }
+ }
+ echo '</ol></li>';
+ }
+ if(count($tree[$id]) > 0){
+ echo '</ol>';
+ }
+ echo '</li>';
+ }
+ echo '</ol><!-- end ol class tree -->
+ </div><!-- end div id="coursenavigation" -->';
- if(!isset($courseid)||!is_numeric($courseid)||$courseid<$mincourseid||$courseid>$maxcourseid)
- echo $errorstring;
- else
- {
- if(is_readable($filename))
- include($filename);
- else
- echo $errorstring;
- }
?>
-</div>
+ <div id="coursecontent"><?php echo $selectCourse; ?></div>
+</div>
View
@@ -20,25 +20,21 @@
// //
///////////////////////////////////////////////////////////////////////////////////
-require("../getsmfuser.php");
+require_once("../getsmfuser.php");
$notloggedintext = "<p class=\"warning\">Warning: You aren't logged in to the Hackits forum, submitting this exam will only count if you are logged in!</p>";
+$courseid = isset($_GET['id']) ? $_GET['id'] : 0;
?>
<script type="text/javascript">
-
- // shows the specified div and hides all others
- function selectPart(part){ $("#"+part).show().siblings().hide(); }
-
// when the examn form is submitted, show the results in a dialog window
$(document).ready(function(){
$("#examnform").submit( function () {
$.post(
'examnhandler.php?id=<? echo $courseid; ?>',
$(this).serialize(),
function(data){
- $("#examnresult").empty().append( data );
- $("#examnresult").dialog("open");
+ $("#examnresult").empty().append(data).dialog("open");
}
);
return false;
@@ -51,4 +47,4 @@ function(data){
</script>
-<div id="examnresult" title="Exam Results"></div>
+<div id="examnresult" title="Exam Results"></div>
Oops, something went wrong.

0 comments on commit 899675d

Please sign in to comment.