Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/main/exercise/hotspot.class.php

139 lines
3.2 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* Class HotSpot
*
* This class allows to instantiate an object of type HotSpot (MULTIPLE CHOICE, UNIQUE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package chamilo.exercise
**/
class HotSpot extends Question
{
9 years ago
public static $typePicture = 'hotspot.png';
public static $explanationLangVar = 'HotSpot';
9 years ago
/**
* HotSpot constructor.
*/
10 years ago
public function __construct()
10 years ago
{
10 years ago
parent::__construct();
9 years ago
$this->type = HOT_SPOT;
}
10 years ago
public function display()
{
}
/**
* @param FormValidator $form
* @param int $fck_config
*/
public function createForm (&$form, $fck_config=0)
10 years ago
{
parent::createForm($form, $fck_config);
if (!isset($_GET['editQuestion'])) {
9 years ago
$form->addElement(
'file',
'imageUpload',
array(
'<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />',
get_lang('UploadJpgPicture'),
)
);
// setting the save button here and not in the question class.php
// Saving a question
$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
10 years ago
//$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
} else {
// setting the save button here and not in the question class.php
// Editing a question
10 years ago
$form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
}
}
/**
* @param FormValidator $form
* @param null $objExercise
* @return null|false
*/
10 years ago
public function processCreation($form, $objExercise = null)
{
$file_info = $form->getSubmitValue('imageUpload');
$_course = api_get_course_info();
parent::processCreation($form, $objExercise);
if(!empty($file_info['tmp_name'])) {
$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
// fixed width ang height
if (file_exists($picturePath.'/'.$this->picture)) {
$this->resizePicture('width', 800);
$this->save();
} else {
return false;
}
}
}
9 years ago
function createAnswersForm($form)
{
10 years ago
// nothing
}
9 years ago
function processAnswersCreation($form)
{
// nothing
}
}
/**
* Class HotSpotDelineation
*/
class HotSpotDelineation extends HotSpot
{
9 years ago
public static $typePicture = 'hotspot-delineation.png';
public static $explanationLangVar = 'HotspotDelineation';
9 years ago
/**
* HotSpotDelineation constructor.
*/
public function __construct()
10 years ago
{
10 years ago
parent::__construct();
$this -> type = HOT_SPOT_DELINEATION;
}
9 years ago
function createForm(&$form, $fck_config=0)
10 years ago
{
parent::createForm ($form, $fck_config);
}
10 years ago
function processCreation ($form, $objExercise = null)
{
$file_info = $form -> getSubmitValue('imageUpload');
parent::processCreation ($form, $objExercise);
}
10 years ago
function createAnswersForm ($form)
{
parent::createAnswersForm ($form);
}
10 years ago
function processAnswersCreation ($form)
{
parent::processAnswersCreation ($form);
}
}