[svn r19675] form with form titles

form layout
improved security
form consistancy
skala
Patrick Cool 16 years ago
parent 5cbbc98208
commit 4ad88bf292
  1. 6
      main/exercice/admin.php
  2. 13
      main/exercice/exercise.class.php
  3. 128
      main/exercice/hotpotatoes.php
  4. 9
      main/exercice/question.class.php
  5. 20
      main/exercice/question_admin.inc.php

@ -1,4 +1,4 @@
<?php // $Id: admin.php 19500 2009-04-02 15:15:56Z cvargas1 $
<?php // $Id: admin.php 19675 2009-04-09 08:46:51Z pcool $
/*
==============================================================================
@ -67,7 +67,7 @@
*
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: admin.php 19500 2009-04-02 15:15:56Z cvargas1 $
* @version $Id: admin.php 19675 2009-04-09 08:46:51Z pcool $
*/
@ -441,7 +441,7 @@ Display::display_header($nameTools,'Exercise');
echo '<div class="actions">';
echo Display::return_icon('preview.gif', get_lang('Preview')).'<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('Preview').'</a>';
echo Display::return_icon('lp_quiz.png', get_lang('ModifyExercise')).'<a href="exercise_admin.php?modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
echo '</div>';

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 19599 2009-04-07 15:28:35Z cvargas1 $
* @version $Id: exercise.class.php 19675 2009-04-09 08:46:51Z pcool $
*/
@ -850,7 +850,16 @@ class Exercise
if(empty($type)){
$type='full';
}
// form title
if (!empty($_GET['exerciseId']))
{
$form_title = get_lang('ModifyExercise');
}
else
{
$form_title = get_lang('NewEx');
}
$form->addElement('header', '', $form_title);
// title
$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles"');
// fck editor

@ -22,38 +22,52 @@
* Code for Hotpotatoes integration.
* @package dokeos.exercise
* @author Istvan Mandak
* @version $Id: hotpotatoes.php 19328 2009-03-25 21:22:36Z aportugal $
* @version $Id: hotpotatoes.php 19675 2009-04-09 08:46:51Z pcool $
*/
// name of the language file that needs to be included
$language_file ='exercice';
// including the global Dokeos file
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
// include additional libraries
include_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH).'document.lib.php');
include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
include_once(api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
include("hotpotatoes.lib.php");
$finish = (!empty($_POST['finish'])?$_POST['finish']:0);
$imgcount = (!empty($_POST['imgcount'])?$_POST['imgcount']:null);
$fld = (!empty($_POST['fld'])?$_POST['fld']:null);
// section (for the tabs)
$this_section=SECTION_COURSES;
// access restriction: only teachers are allowed here
if(!api_is_allowed_to_edit())
{
api_not_allowed();
}
include_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH).'document.lib.php');
// the breadcrumbs
$interbreadcrumb[]= array ("url"=>"./exercice.php", "name"=> get_lang('Exercices'));
$is_allowedToEdit=api_is_allowed_to_edit();
// Database table definitions
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
// setting some variables
$baseServDir = $_configuration['root_sys'];
$baseServUrl = $_configuration['url_append']."/";
$document_sys_path = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$uploadPath = "/HotPotatoes_files";
$finish = (!empty($_POST['finish'])?$_POST['finish']:0);
$imgcount = (!empty($_POST['imgcount'])?$_POST['imgcount']:null);
$fld = (!empty($_POST['fld'])?$_POST['fld']:null);
// if user is allowed to edit
if ($is_allowedToEdit)
if (api_is_allowed_to_edit())
{
include("hotpotatoes.lib.php");
//disable document parsing(?) - obviously deprecated
$enableDocumentParsing=false;
@ -70,7 +84,7 @@ if ($is_allowedToEdit)
/** display */
// if finish is set; it's because the user came from this script in the first place (displaying hidden "finish" field)
if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
if((api_is_allowed_to_edit()) && (($finish == 0) || ($finish == 2)))
//if(($is_allowedToEdit) )
{
$nameTools = get_lang('HotPotatoesTests');
@ -83,12 +97,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
// check something else than a string displayd on a button
if (strcmp($_POST['submit'],get_lang('Send'))===0)
{
/** el kell tarolni <- english please */
include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
/*======================================
FILEMANAGER BASIC VARIABLES DEFINITION
======================================*/
include_once(api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
//@todo: this value should be moved to the platform admin section
$maxFilledSpace = 100000000;
@ -208,21 +217,8 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
}
Display::display_header($nameTools,"Exercise");
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
/* -----*/
?>
<br />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="50%"><h3><?php echo $nameTools; ?></h3></td>
<td width="50%" align="right">
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<?php
if ($finish==2) //if we are in the img upload process
@ -236,20 +232,13 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
if ($dialogBox)
{
echo "<td>\n<!-- dialog box -->\n&nbsp;\n</td>\n";
Display::display_normal_message($dialogBox, false); //main API
echo "</td>\n";
}
else
{
echo "<td>\n<!-- dialog box -->\n&nbsp;\n</td>\n";
}
/*--------------------------------------
UPLOAD SECTION
--------------------------------------*/
echo "<!-- upload -->\n",
"<td align=\"left\" height=\"150\" style=\"background-image: url('../img/hotpotatoes.jpg'); background-repeat: no-repeat; background-position: 600px;\" valign=\"middle\">\n",
"<form action=\"".api_get_self()."\" method=\"post\" enctype=\"multipart/form-data\" >\n",
"<input type=\"hidden\" name=\"uploadPath\" value=\"\">\n",
"<input type=\"hidden\" name=\"fld\" value=\"$fld\">\n",
@ -261,48 +250,33 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
echo " : ",
"<input type=\"file\" name=\"userFile\">\n",
"<input type=\"submit\" name=\"submit\" value=\"".get_lang('Send')."\"><br/>\n";*/
echo '<table>';
echo '<tr>';
echo '<td width="250">';
if ($finish==0){
echo get_lang('DownloadFile').' : ';
}
else{
echo get_lang('DownloadImg').' : ';
}
echo '</td>';
echo '<td>';
echo '<input type="file" name="userFile">';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td width="250">';
echo '</td>';
echo '<td>';
echo '<button type="submit" class="save" name="submit" value="'.get_lang('Send').'">'.get_lang('SendFile').'</button>';
echo '</td>';
echo '</tr>';
echo '</table>';
Display::display_icon('hotpotatoes.jpg','',array('align'=> 'right', 'style' => 'position: absolute; padding-top: 30px; margin-left: 500px;'));
echo '<div class="row"><div class="form_header">'.$nameTools.'</div></div>';
echo '<div class="row">';
echo '<div class="label">';
echo '<span class="form_required">*</span>';
if ($finish==0){
echo get_lang('DownloadFile').' : ';
}
else{
echo get_lang('DownloadImg').' : ';
}
echo '</div>';
echo '<div class="formw">';
echo '<input type="file" name="userFile">';
echo '</div>';
echo '</div>';
echo '<div class="row">';
echo '<div class="label">';
echo '</div>';
echo '<div class="formw"> <button type="submit" class="save" name="submit" value="'.get_lang('Send').'">'.get_lang('SendFile').'</button> </div>';
echo '</div>';
?>
</td>
</tr>
</table>
<?php
Display::display_footer();
}
/*
else
{
if ($finish == 1)
{ // ok
//include("exercice.php");
header("Location: exercice.php");
}
else
{
}
}
*/
// display the footer
Display::display_footer();
?>

@ -1,4 +1,4 @@
<?php // $Id: question.class.php 19660 2009-04-08 21:30:20Z cvargas1 $
<?php // $Id: question.class.php 19675 2009-04-09 08:46:51Z pcool $
/*
==============================================================================
@ -28,7 +28,7 @@
* File containing the Question class.
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: question.class.php 19660 2009-04-08 21:30:20Z cvargas1 $
* @version $Id: question.class.php 19675 2009-04-09 08:46:51Z pcool $
*/
@ -1105,6 +1105,11 @@ abstract class Question
echo '</div>';
echo '<div style="clear:both"></div>';
}
static function get_types_information()
{
return self::$questionTypes;
}
}
endif;
?>

@ -27,7 +27,7 @@
* It is included from the script admin.php
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: question_admin.inc.php 19500 2009-04-02 15:15:56Z cvargas1 $
* @version $Id: question_admin.inc.php 19675 2009-04-09 08:46:51Z pcool $
*/
/*
@ -90,10 +90,6 @@ if(is_object($objQuestion))
* FORM CREATION
*********************/
$objQuestion -> createForm ($form,array('Height'=>150));
$objQuestion -> createAnswersForm ($form);
if(isset($_GET['editQuestion'])) {
$class="save";
$text=get_lang('ModifyQuestion');
@ -102,6 +98,20 @@ if(is_object($objQuestion))
$text=get_lang('AddQuestionToExercise');
}
$types_information = $objQuestion->get_types_information();
$form_title_extra = get_lang($types_information[$_REQUEST['answerType']][1]);
// form title
$form->addElement('header', '', $text.': '.$form_title_extra);
// question form elements
$objQuestion -> createForm ($form,array('Height'=>150));
// answer form elements
$objQuestion -> createAnswersForm ($form);
// submit button
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<div class="row"><div class="label">{label}</div><div class="formw">{element}</div></div>','submitQuestion');

Loading…
Cancel
Save