Commit f0c16d4a authored by ggeller's avatar ggeller

Tweak format and variable names.

parent d481abfb
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-quiz_edit.tpl,v 1.6 2004-05-13 16:24:24 ggeller Exp $ *}
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-quiz_edit.tpl,v 1.7 2004-05-13 19:01:12 ggeller Exp $ *}
{* Copyright (c) 2004 *}
{* All Rights Reserved. See copyright.txt for details and a complete list of authors. *}
......@@ -25,8 +25,8 @@
<tr class="formcolor">
<td>{tr}General Options{/tr}</td>
<td {if $cols} colspan="{$cols}"{/if}>
[ <a class="link" href="javascript:show('general');">{tr}show{/tr}</a>
<td width="85%" {if $cols} colspan="{$cols}"{/if}>
[ <a class="link" href="javascript:show('general');">{tr}show{/tr}</a>
| <a class="link" href="javascript:hide('general');">{tr}hide{/tr}</a> ]
<div id="general" style="display:none;">
<table class="normal">
......@@ -41,13 +41,13 @@
<tr class="formcolor">
<td>{tr}Publication Date{/tr}</td>
<td>
{html_select_date prefix="publish_" time=$publishDateSite start_year="-5" end_year="+10"} {tr}at {/tr}{html_select_time prefix="publish_" time=$publishDateSite display_seconds=false} HRS&nbsp;{$siteTimeZone}
{html_select_date prefix="publish_" time=$quiz.publishDate start_year="-5" end_year="+10"} {tr}at {/tr}{html_select_time prefix="publish_" time=$quiz.publishDate display_seconds=false} HRS&nbsp;{$siteTimeZone}
</td>
</tr>
<tr class="formcolor">
<td>{tr}Expiration Date{/tr}</td>
<td>
{html_select_date prefix="expire_" time=$expireDateSite start_year="-5" end_year="+10"} {tr}at {/tr}{html_select_time prefix="expire_" time=$expireDateSite display_seconds=false} HRS&nbsp;{$siteTimeZone}
{html_select_date prefix="expire_" time=$quiz.expireDate start_year="-5" end_year="+10"} {tr}at {/tr}{html_select_time prefix="expire_" time=$quiz.expireDate display_seconds=false} HRS&nbsp;{$siteTimeZone}
</td>
</tr>
</table>
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-quiz_edit.php,v 1.3 2004-05-11 20:13:35 ggeller Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-quiz_edit.php,v 1.4 2004-05-13 19:01:10 ggeller Exp $
// Copyright (c) 2002-2004, Luis Argerich, Garland Foster, Eduardo Polidor,
// George G. Geller et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// include_once ("categorize.php"); put this somewhere for the save.
error_reporting(E_ALL);
// Initialization
require_once('tiki-setup.php');
......@@ -22,28 +21,13 @@ if ($feature_quizzes != 'y') {
die;
}
if ($tiki_p_admin_quizzes != 'y') {
$smarty->assign('msg', tra("You don't have permission to use this feature"));
$smarty->display("error.tpl");
die;
}
// When the quiz id is not indicated, we redirect to the list of quizzes.
if (!isset($_REQUEST["quizId"])) {
$smarty->assign('msg', tra("No quiz indicated"));
$smarty->display("error.tpl");
header ("location: tiki-list_quizzes.php");
die;
}
$smarty->assign('quizId', $_REQUEST["quizId"]);
$cat_type = 'quiz';
$cat_objid = $_REQUEST["quizId"];
$smarty->assign('individual', 'n');
if ($userlib->object_has_one_permission($_REQUEST["quizId"], 'quiz')) {
$smarty->assign('individual', 'y');
......@@ -66,145 +50,76 @@ if ($userlib->object_has_one_permission($_REQUEST["quizId"], 'quiz')) {
}
}
$quiz_info = $quizlib->get_quiz($_REQUEST["quizId"]);
$quiz_info["name"] = "Chapter 01";
$smarty->assign('quiz_info', $quiz_info);
if (!isset($_REQUEST["questionId"])) {
$_REQUEST["questionId"] = 0;
}
$smarty->assign('questionId', $_REQUEST["questionId"]);
if ($_REQUEST["questionId"]) {
$info = $quizlib->get_quiz_question($_REQUEST["questionId"]);
} else {
$info = array();
if ($tiki_p_admin_quizzes != 'y') {
$smarty->assign('msg', tra("You don't have permission to use this feature"));
$info["question"] = '';
$info["type"] = '';
$info["position"] = '';
$smarty->display("error.tpl");
die;
}
$smarty->assign('question', $info["question"]);
$smarty->assign('type', $info["type"]);
$smarty->assign('position', $info["position"]);
if (isset($_REQUEST["remove"])) {
$area = 'delquizquestion';
if (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"])) {
key_check($area);
$quizlib->remove_quiz_question($_REQUEST["remove"]);
} else {
key_get($area);
}
}
$cat_type = 'quiz';
$cat_objid = $_REQUEST["quizId"];
include_once ("categorize_list.php");
if (isset($_REQUEST["save"])) {
echo "Sorry, this is only a prototype at present.<br>";
die;
echo "line: ".__LINE__."<br>";
echo '$_REQUEST["quizId"] = '.$_REQUEST["quizId"]."<br>";
foreach ($_REQUEST as $request){
echo '$request = '.$request."<br>";
}
foreach ($_REQUEST as $key => $request){
echo $key." = ".$request."<br>";
}
check_ticket('edit-quiz-question');
$quizlib->replace_quiz_question($_REQUEST["questionId"], $_REQUEST["question"],
'o', $_REQUEST["quizId"], $_REQUEST["position"]);
$smarty->assign('question', '');
$smarty->assign('questionId', 0);
}
$cat_href = "tiki-quiz.php?quizId=" . $cat_objid;
$cat_name = $_REQUEST["name"];
$cat_desc = substr($_REQUEST["description"], 0, 200);
include_once ("categorize.php");
if (isset($_REQUEST["import"])) {
check_ticket('edit-quiz-question');
$questions = TextToQuestions($_REQUEST["input_data"]);
echo "line: ".__LINE__."<br>";
echo "Sorry, this is only a prototype at present.<br>";
foreach ($questions as $question){
$question_text = $question->getQuestion();
$id = $quizlib->replace_quiz_question(0, $question_text, 'o', $_REQUEST["quizId"], 0);
for ($i = 0; $i < $question->getChoiceCount(); $i++){
$a = $question->GetChoice($i);
$b = $question->GetCorrect($i);
$quizlib->replace_question_option(0, $a, $b, $id);
}
foreach ($_REQUEST as $key => $request){
echo $key." = ".$request."<br>";
}
$smarty->assign('question', '');
$smarty->assign('questionId', 0);
}
if (isset($_REQUEST["useQuestion"])) {
check_ticket('edit-quiz-question');
$info = $quizlib->get_quiz_question($_REQUEST["usequestionid"]);
$qid = $quizlib->replace_quiz_question(0, $info["question"], $info["type"], $_REQUEST["quizId"], $_REQUEST["position"]);
$options = $quizlib->list_quiz_question_options($info["questionId"], 0, -1, 'points_desc', '');
foreach ($options["data"] as $opt) {
$quizlib->replace_question_option(0, $opt["optionText"], $opt["points"], $qid);
}
// Have to parse the data and bail out if there is an error.
//
// Store the new or revised information
// If everything works, preview the quiz.
//
die;
}
if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'position_asc';
} else {
$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
$quiz = $quizlib->get_quiz($_REQUEST["quizId"]);
// echo "line ".__LINE__."<br>";
// foreach ($quiz as $key => $val){
// echo $key." = ".$val."<br>";
// }
// die;
$smarty->assign_by_ref('offset', $offset);
$smarty->assign('quiz', $quiz);
if (isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
$find = '';
}
// echo __LINE__."<br>";
// die;
$smarty->assign('find', $find);
// Fill array with possible number of questions per page
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $quizlib->list_quiz_questions($_REQUEST["quizId"], $offset, $maxRecords, $sort_mode, $find);
$positions = array();
$cant_pages = ceil($channels["cant"] / $maxRecords);
$smarty->assign_by_ref('cant_pages', $cant_pages);
$smarty->assign('actual_page', 1 + ($offset / $maxRecords));
for ($i = 1; $i < 100; $i++)
$positions[] = $i;
if ($channels["cant"] > ($offset + $maxRecords)) {
$smarty->assign('next_offset', $offset + $maxRecords);
} else {
$smarty->assign('next_offset', -1);
}
$smarty->assign('positions', $positions);
ask_ticket('edit-quiz-question');
// If offset is > 0 then prev_offset
if ($offset > 0) {
$smarty->assign('prev_offset', $offset - $maxRecords);
} else {
$smarty->assign('prev_offset', -1);
}
// GGG scaffolding -start
$smarty->assign_by_ref('channels', $channels["data"]);
$quiz['name'] = "Test Chapter 01";
$quiz['description'] = "Quiz on Chapter 01 of Tom Sawyer";
// Fill array with possible number of questions per page
$positions = array();
// The default publish date to be Jan 1, of this year at midnight.
$quiz['publishDate'] = mktime(0, 0, 0, 1, 1, date("Y"));
for ($i = 1; $i < 100; $i++)
$positions[] = $i;
// The default expire date to be 10 years after the default publish date
$quiz['expireDate'] = mktime(0, 0, 0, 1, 1, date("Y")+10);
include_once ("categorize_list.php");
// GGG scaffolding -end
$smarty->assign('positions', $positions);
ask_ticket('edit-quiz-question');
$smarty->assign_by_ref('quiz', $quiz);
// GGG scaffolding
// $smarty->assign('repetitionLimit', "10");
......@@ -236,8 +151,34 @@ $smarty->assign('questionsPerPage', "Unlimited");
$quiz_info["name"] = "Chapter 01";
// Additional data for smarty
$tzName = $tikilib->get_display_timezone($user);
if ($tzName == "Local"){
$tzName = "";
}
$smarty->assign('siteTimeZone', $tzName);
// Display the template
$smarty->assign('mid', 'tiki-quiz_edit.tpl');
$smarty->display("tiki.tpl");
// if (isset($_REQUEST["import"])) {
// check_ticket('edit-quiz-question');
// $questions = TextToQuestions($_REQUEST["input_data"]);
// foreach ($questions as $question){
// $question_text = $question->getQuestion();
// $id = $quizlib->replace_quiz_question(0, $question_text, 'o', $_REQUEST["quizId"], 0);
// for ($i = 0; $i < $question->getChoiceCount(); $i++){
// $a = $question->GetChoice($i);
// $b = $question->GetCorrect($i);
// $quizlib->replace_question_option(0, $a, $b, $id);
// }
// }
// $smarty->assign('question', '');
// $smarty->assign('questionId', 0);
// }
?>
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