Commit c02d1375 authored by ggeller's avatar ggeller

New quiz editor, a work in progress.

parent dd5b7f49
......@@ -718,6 +718,7 @@ class HW_QuizQuestionYesNo extends HW_QuizQuestion {
}
class Quiz {
var $id;
var $version;
var $timestamp;
var $online;
......@@ -752,17 +753,17 @@ class Quiz {
$this->studentAttempts = 0;
$this->name = "";
$this->description = "";
$this->datePub = 0;
$this->dateExp = 0;
$this->datePub = mktime(0, 0, 0, 1, 1, date("Y"));
$this->dateExp = mktime(0, 0, 0, 1, 1, date("Y")+10);
$this->shuffleQuestions = "n";
$this->shuffleAnswers = "n";
$this->limitDisplay = "n";
$this->questionsPerPage = 0;
$this->limitDisplay = "y";
$this->questionsPerPage = 1;
$this->timeLimited = "n";
$this->timeLimit = "0";
$this->multiSession = "n";
$this->canRepeat = "n";
$this->repetitions = 0;
$this->canRepeat = "y";
$this->repetitions = 'unlimited';
$this->gradingMethod = "machine";
$this->showScore = "immediately";
$this->showCorrectAnswers = "immediately";
......@@ -772,9 +773,36 @@ class Quiz {
$this->forumName = "";
$this->data = "";
}
function from_text($lines){
// Set the question according to an array of text lines.
function show_html(){
// dump as html text
$lines = array();
$lines[] = "id = ".$this->id."<br />";
$lines[] = "version = ".$this->version."<br />";
$lines[] = "timestamp = ".date("r",$this->timestamp)."<br />";
$lines[] = "online = ".$this->online."<br />";
$lines[] = "studentAttempts = ".$this->studentAttempts."<br />";
$lines[] = "name = ".$this->name."<br />";
$lines[] = "description = ".$this->description."<br />";
$lines[] = "datePub = ".date("r",$this->datePub)."<br />";
$lines[] = "dateExp = ".date("r",$this->dateExp)."<br />";
$lines[] = "shuffleQuestions = ".$this->shuffleQuestions."<br />";
$lines[] = "shuffleAnswers = ".$this->shuffleAnswers."<br />";
$lines[] = "limitDisplay = ".$this->limitDisplay."<br />";
$lines[] = "questionsPerPage = ".$this->questionsPerPage."<br />";
$lines[] = "timeLimited = ".$this->timeLimited."<br />";
$lines[] = "timeLimit = ".$this->timeLimit."<br />";
$lines[] = "multiSession = ".$this->multiSession."<br />";
$lines[] = "canRepeat = ".$this->canRepeat."<br />";
$lines[] = "repetitions = ".$this->repetitions."<br />";
$lines[] = "gradingMethod = ".$this->gradingMethod."<br />";
$lines[] = "showScore = ".$this->showScore."<br />";
$lines[] = "showCorrectAnswers = ".$this->showCorrectAnswers."<br />";
$lines[] = "publishStats = ".$this->publishStats."<br />";
$lines[] = "additionalQuestions = ".$this->additionalQuestions."<br />";
$lines[] = "forum = ".$this->forum."<br />";
$lines[] = "forumName = ".$this->forumName."<br />";
$lines[] = "data = ".$this->data."<br />";
return $lines;
}
function getQuestion(){
return $this->question;
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-quiz_edit.php,v 1.7 2004-05-18 21:01:31 ggeller Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-quiz_edit.php,v 1.8 2004-05-20 12:29:34 ggeller Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor,
// George G. Geller et. al.
......@@ -42,10 +42,9 @@ if ($feature_quizzes != 'y') {
die;
}
// When the quiz id is not indicated, we redirect to the list of quizzes.
if (!isset($_REQUEST["quizId"])) {
header ("location: tiki-list_quizzes.php");
die;
// quizId of 0 is used as a default; There should not be a row in the db with an id of zero.
if(!isset($_REQUEST["quizId"])){
$_REQUEST["quizId"] = 0;
}
$smarty->assign('individual', 'n');
......@@ -102,17 +101,22 @@ function fetchYNOption(&$quiz, $_REQUEST, $option){
}
}
if (isset($_REQUEST["save"])) {
// foreach ($_REQUEST as $key => $val){
// echo $key." = ".$val."<br>";
// }
// die;
// When the quiz id is not indicated, create a new quiz
if ($_REQUEST["quizId"] == 0) {
$quizNew = new Quiz;
echo "line ".__LINE__."<br>";
$lines = $quizNew->show_html();
foreach ($lines as $line){
echo $line;
}
die;
} else if (isset($_REQUEST["save"])) {
check_ticket('edit-quiz-question');
$cat_href = "tiki-quiz.php?quizId=" . $cat_objid;
$cat_name = $_REQUEST["name"];
$cat_desc = substr($_REQUEST["description"], 0, 200);
// $cat_objid = $_REQUEST["quizId"];
include_once ("categorize.php");
echo "line: ".__LINE__."<br>";
......@@ -191,13 +195,14 @@ if (isset($_REQUEST["save"])) {
die;
}
// $quizOld = $quizlib->fetch_quiz($_REQUEST["quizId"]);
$quiz = $quizlib->get_quiz($_REQUEST["quizId"]);
// echo "line ".__LINE__."<br>";
// foreach ($quiz as $key => $val){
// echo $key." = ".$val."<br>";
// }
// die;
echo "line ".__LINE__."<br>";
foreach ($quiz as $key => $val){
echo $key." = ".$val."<br>";
}
echo date("r",$quiz['publishDate'])."<br>";
die;
$smarty->assign('quiz', $quiz);
......@@ -284,7 +289,7 @@ for ($i = 1; $i <= 10; $i++){
$qpp[] = $i;
$repetitions[] = $i;
}
$repetitions[] = "Unlimited";
$repetitions[] = "unlimited";
$smarty->assign('repetitions', $repetitions);
$smarty->assign('qpp', $qpp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment