Skip to content
GitLab
Explore
Sign in
formatest
FormATest_QuestionSetPool
Compare revisions
dac62171f9f4b208778bdbb4996d236af1fe3adc to 381d5850e2bde24749dbdf4affb7ff3984e296ea
Hide whitespace changes
Inline
Side-by-side
classes/class.ilQuestionSetPoolPlugin.php
View file @
381d5850
<?php
<?php
include_once
(
"./Services/Repository/classes/class.ilRepositoryObjectPlugin.php"
);
/**
/**
* Class ilQuestionSetPoolPlugin
* Class ilQuestionSetPoolPlugin
*
*
* Date: 23.09.13
* Date: 23.09.13
* Time: 10:33
* Time: 10:33
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolPlugin
extends
ilRepositoryObjectPlugin
class
ilQuestionSetPoolPlugin
extends
ilRepositoryObjectPlugin
{
{
/**
/**
* @var self|null
* @var self|null
*/
*/
private
static
$instance
;
private
static
$instance
;
/**
/**
* @var string
* @var string
*/
*/
private
static
$PLUGIN_CTYPE
=
'Services'
;
private
static
$PLUGIN_CTYPE
=
'Services'
;
/**
/**
* @var string
* @var string
*/
*/
private
static
$PLUGIN_CNAME
=
'Repository'
;
private
static
$PLUGIN_CNAME
=
'Repository'
;
/**
/**
* @var string
* @var string
*/
*/
private
static
$PLUGIN_SLOT_ID
=
"robj"
;
private
static
$PLUGIN_SLOT_ID
=
"robj"
;
/**
/**
* @var string
* @var string
*/
*/
private
static
$PLUGIN_ID
=
"xqsp"
;
private
static
$PLUGIN_ID
=
"xqsp"
;
/**
/**
* @var string
* @var string
*/
*/
private
static
$PLUGIN_NAME
=
"QuestionSetPool"
;
private
static
$PLUGIN_NAME
=
"QuestionSetPool"
;
/**
/**
* Get the ID of the of the Plugin
* Get the ID of the of the Plugin
*
*
* @return string
* @return string
*/
*/
public
static
function
getPluginId
()
public
static
function
getPluginId
()
{
{
return
self
::
$PLUGIN_ID
;
return
self
::
$PLUGIN_ID
;
}
}
/**
/**
* Get Plugin Name. Must be same as in class name il<Name>Plugin
* Get Plugin Name. Must be same as in class name il<Name>Plugin
* and must correspond to plugins subdirectory name.
* and must correspond to plugins subdirectory name.
* Must be overwritten in plugin class of plugin
* Must be overwritten in plugin class of plugin
* (and should be made final)
* (and should be made final)
* @return string Plugin Name
* @return string Plugin Name
*/
*/
public
function
getPluginName
()
public
function
getPluginName
()
{
{
return
self
::
$PLUGIN_NAME
;
return
self
::
$PLUGIN_NAME
;
}
}
public
static
function
getName
()
public
static
function
getName
()
{
{
return
self
::
$PLUGIN_NAME
;
return
self
::
$PLUGIN_NAME
;
}
}
/**
/**
* @return self|ilPlugin|ilRepositoryObjectPlugin
* @return self|ilPlugin|ilRepositoryObjectPlugin
*/
*/
public
static
function
getInstance
()
public
static
function
getInstance
()
{
{
if
(
null
!==
self
::
$instance
)
if
(
null
!==
self
::
$instance
)
{
{
return
self
::
$instance
;
return
self
::
$instance
;
}
}
return
(
self
::
$instance
=
ilPluginAdmin
::
getPluginObject
(
return
(
self
::
$instance
=
ilPluginAdmin
::
getPluginObject
(
self
::
$PLUGIN_CTYPE
,
self
::
$PLUGIN_CTYPE
,
self
::
$PLUGIN_CNAME
,
self
::
$PLUGIN_CNAME
,
self
::
$PLUGIN_SLOT_ID
,
self
::
$PLUGIN_SLOT_ID
,
self
::
$PLUGIN_NAME
self
::
$PLUGIN_NAME
));
));
}
}
/**
/**
* @return string
* @return string
*/
*/
public
function
getAdditionalDataTable
()
public
function
getAdditionalDataTable
()
{
{
return
"rep_robj_xqsp_data"
;
return
"rep_robj_xqsp_data"
;
}
}
/**
/**
* @return string
* @return string
*/
*/
public
function
getQuestionSetTable
()
public
function
getQuestionSetTable
()
{
{
return
"rep_robj_xqsp_qs"
;
return
"rep_robj_xqsp_qs"
;
}
}
/**
/**
* @param string $a_type
* @param string $a_type
* @param string $a_size
* @param string $a_size
* @return string
* @return string
*/
*/
public
static
function
_getIcon
(
$a_type
,
$a_size
)
public
static
function
_getIcon
(
$a_type
,
$a_size
)
{
{
return
ilPlugin
::
_getImagePath
(
return
ilPlugin
::
_getImagePath
(
IL_COMP_SERVICE
,
IL_COMP_SERVICE
,
'Repository'
,
'robj'
,
'Repository'
,
ilPlugin
::
lookupNameForId
(
IL_COMP_SERVICE
,
'Repository'
,
'robj'
,
$a_type
),
'robj'
,
'icon_'
.
$a_type
.
'.svg'
ilPlugin
::
lookupNameForId
(
IL_COMP_SERVICE
,
'Repository'
,
'robj'
,
$a_type
),
);
'icon_'
.
$a_type
.
'.svg'
}
);
}
protected
function
uninstallCustom
()
{
protected
function
uninstallCustom
()
/**
{
* @var $ilDB ilDB
/**
*/
* @var $ilDB ilDB
global
$ilDB
;
*/
global
$ilDB
;
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_data'
))
{
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_data'
))
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_data'
);
$ilDB
->
dropTable
(
'rep_robj_xqsp_data'
);
}
}
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_jmp_con'
))
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_jmp_con'
))
{
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_jmp_con'
);
$ilDB
->
dropTable
(
'rep_robj_xqsp_jmp_con'
);
}
}
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_jmp_con'
))
{
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_jmp_con'
))
$ilDB
->
dropSequence
(
'rep_robj_xqsp_jmp_con'
);
{
}
$ilDB
->
dropSequence
(
'rep_robj_xqsp_jmp_con'
);
}
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_node'
))
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_node'
);
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_node'
))
}
{
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_node'
))
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_node'
);
$ilDB
->
dropSequence
(
'rep_robj_xqsp_node'
);
}
}
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_node'
))
{
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_path'
))
{
$ilDB
->
dropSequence
(
'rep_robj_xqsp_node'
);
$ilDB
->
dropTable
(
'rep_robj_xqsp_path'
);
}
}
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_path'
))
{
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_path'
))
$ilDB
->
dropSequence
(
'rep_robj_xqsp_path'
);
{
}
$ilDB
->
dropTable
(
'rep_robj_xqsp_path'
);
}
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_qs'
))
{
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_path'
))
$ilDB
->
dropTable
(
'rep_robj_xqsp_qs'
);
{
}
$ilDB
->
dropSequence
(
'rep_robj_xqsp_path'
);
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_qs'
))
{
}
$ilDB
->
dropSequence
(
'rep_robj_xqsp_qs'
);
}
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_qs'
))
{
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_qs_qst'
))
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_qs'
);
$ilDB
->
dropTable
(
'rep_robj_xqsp_qs_qst'
);
}
}
if
(
$ilDB
->
sequenceExists
(
'rep_robj_xqsp_qs'
))
}
{
$ilDB
->
dropSequence
(
'rep_robj_xqsp_qs'
);
}
if
(
$ilDB
->
tableExists
(
'rep_robj_xqsp_qs_qst'
))
{
$ilDB
->
dropTable
(
'rep_robj_xqsp_qs_qst'
);
}
}
}
}
classes/class.ilQuestionSetPoolXmlValidator.php
View file @
381d5850
...
@@ -6,280 +6,271 @@
...
@@ -6,280 +6,271 @@
*/
*/
class
ilQuestionSetPoolXmlValidator
class
ilQuestionSetPoolXmlValidator
{
{
/**
/**
*
*
*/
*/
const
MODE_VALIDATION
=
1
;
const
MODE_VALIDATION
=
1
;
/**
/**
*
*
*/
*/
const
XSD_FILE
=
'./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/xml/xqsp_5_1.xsd'
;
const
XSD_FILE
=
'./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/xml/xqsp_5_1.xsd'
;
/**
/**
*
*
*/
*/
const
NAME_SPACE_URI
=
'http://www.ilias.de/Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
;
const
NAME_SPACE_URI
=
'http://www.ilias.de/Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
;
/**
/**
*
*
*/
*/
const
DOM_MISSING_NS_CODE
=
1845
;
const
DOM_MISSING_NS_CODE
=
1845
;
/**
/**
* @var
* @var
*/
*/
private
$mode
;
private
$mode
;
/**
/**
* @var string
* @var string
*/
*/
private
$schema
;
private
$schema
;
/**
/**
* @var
* @var
*/
*/
private
$xml
;
private
$xml
;
/**
/**
* @var array
* @var array
*/
*/
private
$assignments
=
array
();
private
$assignments
=
array
();
/**
/**
* @var array
* @var array
*/
*/
private
$errors
=
array
();
private
$errors
=
array
();
/**
/**
* @var bool
* @var bool
*/
*/
private
$has_errors
=
false
;
private
$has_errors
=
false
;
/**
/**
* @var null
* @var null
*/
*/
protected
$xml_file
=
NULL
;
protected
$xml_file
=
null
;
/**
/**
* @var null
* @var null
*/
*/
protected
$xsd_file
=
NULL
;
protected
$xsd_file
=
null
;
/**
/**
* @var string
* @var string
*/
*/
protected
$error_message
=
''
;
protected
$error_message
=
''
;
/**
/**
* ilQuestionSetPoolXmlValidator constructor.
* ilQuestionSetPoolXmlValidator constructor.
*/
*/
public
function
__construct
()
public
function
__construct
()
{
{
$this
->
schema
=
self
::
XSD_FILE
;
$this
->
schema
=
self
::
XSD_FILE
;
}
}
/**
/**
* @return mixed
* @return mixed
*/
*/
public
function
getMode
()
public
function
getMode
()
{
{
return
$this
->
mode
;
return
$this
->
mode
;
}
}
/**
/**
* @param mixed $mode
* @param mixed $mode
*/
*/
public
function
setMode
(
$mode
)
public
function
setMode
(
$mode
)
{
{
$this
->
mode
=
$mode
;
$this
->
mode
=
$mode
;
}
}
/**
/**
* @return string
* @return string
*/
*/
public
function
getSchema
()
public
function
getSchema
()
{
{
return
$this
->
schema
;
return
$this
->
schema
;
}
}
/**
/**
* @param string $schema
* @param string $schema
*/
*/
public
function
setSchema
(
$schema
)
public
function
setSchema
(
$schema
)
{
{
$this
->
schema
=
$schema
;
$this
->
schema
=
$schema
;
}
}
/**
/**
* @return mixed
* @return mixed
*/
*/
public
function
getXml
()
public
function
getXml
()
{
{
return
$this
->
xml
;
return
$this
->
xml
;
}
}
/**
/**
* @param mixed $xml
* @param mixed $xml
*/
*/
public
function
setXml
(
$xml
)
public
function
setXml
(
$xml
)
{
{
$this
->
xml
=
$xml
;
$this
->
xml
=
$xml
;
}
}
/**
/**
* @return array
* @return array
*/
*/
public
function
getAssignments
()
public
function
getAssignments
()
{
{
return
$this
->
assignments
;
return
$this
->
assignments
;
}
}
/**
/**
* @param array $assignments
* @param array $assignments
*/
*/
public
function
setAssignments
(
$assignments
)
public
function
setAssignments
(
$assignments
)
{
{
$this
->
assignments
=
$assignments
;
$this
->
assignments
=
$assignments
;
}
}
/**
/**
* @return array
* @return array
*/
*/
public
function
getErrors
()
public
function
getErrors
()
{
{
return
$this
->
errors
;
return
$this
->
errors
;
}
}
/**
/**
* @param array $errors
* @param array $errors
*/
*/
public
function
setErrors
(
$errors
)
public
function
setErrors
(
$errors
)
{
{
$this
->
errors
=
$errors
;
$this
->
errors
=
$errors
;
}
}
/**
/**
* @return boolean
* @return boolean
*/
*/
public
function
isHasErrors
()
public
function
isHasErrors
()
{
{
return
$this
->
has_errors
;
return
$this
->
has_errors
;
}
}
/**
/**
* @param boolean $has_errors
* @param boolean $has_errors
*/
*/
public
function
setHasErrors
(
$has_errors
)
public
function
setHasErrors
(
$has_errors
)
{
{
$this
->
has_errors
=
$has_errors
;
$this
->
has_errors
=
$has_errors
;
}
}
/**
/**
* @return null
* @return null
*/
*/
public
function
getXmlFile
()
public
function
getXmlFile
()
{
{
return
$this
->
xml_file
;
return
$this
->
xml_file
;
}
}
/**
/**
* @param null $xml_file
* @param null $xml_file
*/
*/
public
function
setXmlFile
(
$xml_file
)
public
function
setXmlFile
(
$xml_file
)
{
{
$this
->
xml_file
=
$xml_file
;
$this
->
xml_file
=
$xml_file
;
}
}
/**
/**
* @return null
* @return null
*/
*/
public
function
getXsdFile
()
public
function
getXsdFile
()
{
{
return
$this
->
xsd_file
;
return
$this
->
xsd_file
;
}
}
/**
/**
* @param null $xsd_file
* @param null $xsd_file
*/
*/
public
function
setXsdFile
(
$xsd_file
)
public
function
setXsdFile
(
$xsd_file
)
{
{
$this
->
xsd_file
=
$xsd_file
;
$this
->
xsd_file
=
$xsd_file
;
}
}
/**
/**
* @return string
* @return string
*/
*/
public
function
getErrorMessage
()
public
function
getErrorMessage
()
{
{
return
$this
->
error_message
;
return
$this
->
error_message
;
}
}
/**
/**
* @param string $error_message
* @param string $error_message
*/
*/
public
function
setErrorMessage
(
$error_message
)
public
function
setErrorMessage
(
$error_message
)
{
{
$this
->
error_message
=
$error_message
;
$this
->
error_message
=
$error_message
;
}
}
/**
/**
* @return bool
* @return bool
*/
*/
public
function
validate
()
public
function
validate
()
{
{
// validate against schema
// validate against schema
$this
->
setXml
(
@
file_get_contents
(
$this
->
getXmlFile
()));
$this
->
setXml
(
@
file_get_contents
(
$this
->
getXmlFile
()));
if
(
!
$this
->
validateXml
(
$this
->
getXml
(),
false
))
if
(
!
$this
->
validateXml
(
$this
->
getXml
(),
false
))
{
{
return
true
;
return
true
;
}
}
if
(
is_array
(
$this
->
errors
)
&&
count
(
$this
->
errors
))
{
if
(
is_array
(
$this
->
errors
)
&&
count
(
$this
->
errors
))
return
false
;
{
}
return
false
;
return
true
;
}
}
return
true
;
}
/**
* validate xml string
/**
* @param string $a_xml
* validate xml string
* @param bool|false $a_add_default_namespace
* @param string $a_xml
* @return bool
* @param bool|false $a_add_default_namespace
*/
* @return bool
protected
function
validateXml
(
$a_xml
,
$a_add_default_namespace
=
false
)
*/
{
protected
function
validateXml
(
$a_xml
,
$a_add_default_namespace
=
false
)
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
debug
(
$a_xml
);
{
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
debug
(
$a_xml
);
libxml_use_internal_errors
(
true
);
$dom
=
new
DOMDocument
();
libxml_use_internal_errors
(
true
);
$dom
->
loadXML
(
$a_xml
);
$dom
=
new
DOMDocument
();
$dom
->
schemaValidate
(
$this
->
getSchema
());
$dom
->
loadXML
(
$a_xml
);
$dom
->
schemaValidate
(
$this
->
getSchema
());
foreach
(
libxml_get_errors
()
as
$error
)
{
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
warning
(
'XML schema validation failed: '
.
$error
->
line
.
': '
.
$error
->
message
);
foreach
(
libxml_get_errors
()
as
$error
)
{
/* @var $error LibXMLError */
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
warning
(
'XML schema validation failed: '
.
$error
->
line
.
': '
.
$error
->
message
);
if
(
$error
->
code
==
self
::
DOM_MISSING_NS_CODE
)
{
if
(
!
$a_add_default_namespace
)
{
/* @var $error LibXMLError */
// add default namespace to xml
if
(
$error
->
code
==
self
::
DOM_MISSING_NS_CODE
)
$xml
=
simplexml_load_string
(
$a_xml
);
{
$xml
->
addAttribute
(
'xmlns'
,
self
::
NAME_SPACE_URI
);
if
(
!
$a_add_default_namespace
)
$xml
->
saveXml
();
{
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
debug
(
'Starting second validation with default namespace'
);
// add default namespace to xml
libxml_clear_errors
();
$xml
=
simplexml_load_string
(
$a_xml
);
return
$this
->
validateXml
(
$xml
->
asXML
(),
true
);
$xml
->
addAttribute
(
'xmlns'
,
self
::
NAME_SPACE_URI
);
}
$xml
->
saveXml
();
}
else
{
ilLoggerFactory
::
getLogger
(
'xqsp'
)
->
debug
(
'Starting second validation with default namespace'
);
$this
->
errors
[]
=
$error
->
line
.
': '
.
$error
->
message
;
libxml_clear_errors
();
}
return
$this
->
validateXml
(
$xml
->
asXML
(),
true
);
}
}
libxml_clear_errors
();
}
if
(
is_array
(
$this
->
errors
)
&&
count
(
$this
->
errors
))
{
else
return
false
;
{
}
$this
->
errors
[]
=
$error
->
line
.
': '
.
$error
->
message
;
return
true
;
}
}
}
}
libxml_clear_errors
();
if
(
is_array
(
$this
->
errors
)
&&
count
(
$this
->
errors
))
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
classes/controllers/abstract.ilPluginControllerFormGUI.php
View file @
381d5850
...
@@ -8,77 +8,76 @@ require_once "abstract.ilPluginControllerGUI.php";
...
@@ -8,77 +8,76 @@ require_once "abstract.ilPluginControllerGUI.php";
* Date: 02.10.13
* Date: 02.10.13
* Time: 15:10
* Time: 15:10
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract
class
ilPluginControllerFormGUI
extends
ilPluginControllerGUI
abstract
class
ilPluginControllerFormGUI
extends
ilPluginControllerGUI
{
{
/**
/**
* @var ilPropertyFormGUI
* @var ilPropertyFormGUI
*/
*/
protected
$form
;
protected
$form
;
public
function
edit
()
public
function
edit
()
{
{
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
}
public
function
update
()
public
function
update
()
{
{
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
if
(
$this
->
form
->
checkInput
())
if
(
$this
->
form
->
checkInput
())
{
{
$model
->
bindForm
(
$this
->
form
);
$model
->
bindForm
(
$this
->
form
);
$model
->
update
();
$model
->
update
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$this
->
redirect
(
$this
->
redirect
(
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectParams
(
$model
)
$this
->
getAfterUpdateRedirectParams
(
$model
)
);
);
}
}
$this
->
form
->
setValuesByPost
();
$this
->
form
->
setValuesByPost
();
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
}
/**
/**
* @param ilPluginModelInterface $model
* @param ilPluginModelInterface $model
*/
*/
protected
function
bindModelToForm
(
ilPluginModelInterface
$model
)
protected
function
bindModelToForm
(
ilPluginModelInterface
$model
)
{
{
$this
->
form
->
setValuesByArray
(
$model
->
toArray
());
$this
->
form
->
setValuesByArray
(
$model
->
toArray
());
}
}
/**
/**
* Loads and returns the Model for the controller gui
* Loads and returns the Model for the controller gui
*
*
* @return ilPluginModelInterface
* @return ilPluginModelInterface
*/
*/
abstract
protected
function
loadModel
();
abstract
protected
function
loadModel
();
/**
/**
* Initialize the PropertyFormGUI for this controller
* Initialize the PropertyFormGUI for this controller
*
*
* @param ilPluginModel $model
* @param ilPluginModel $model
*
*
* @return mixed
* @return mixed
*/
*/
abstract
protected
function
initForm
(
$model
);
abstract
protected
function
initForm
(
$model
);
/**
/**
* Get the redirect action after an update was successful
* Get the redirect action after an update was successful
*
*
* @return string
* @return string
*/
*/
abstract
protected
function
getAfterUpdateRedirectCmd
();
abstract
protected
function
getAfterUpdateRedirectCmd
();
/**
/**
* @param $model
* @param $model
*
*
* @return array
* @return array
*/
*/
abstract
protected
function
getAfterUpdateRedirectParams
(
$model
);
abstract
protected
function
getAfterUpdateRedirectParams
(
$model
);
}
}
classes/controllers/abstract.ilPluginControllerGUI.php
View file @
381d5850
...
@@ -8,137 +8,140 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/
...
@@ -8,137 +8,140 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/
* Date: 23.09.13
* Date: 23.09.13
* Time: 14:10
* Time: 14:10
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract
class
ilPluginControllerGUI
{
abstract
class
ilPluginControllerGUI
{
/**
* The main Controller of the Plugin
/**
*
* The main Controller of the Plugin
* @var ilObjQuestionSetPoolGUI
*
*/
* @var ilObjQuestionSetPoolGUI
public
$controller
;
*/
public
$controller
;
/**
* @var ilCtrl
/**
*/
* @var ilCtrl
public
$ctrl
;
*/
public
$ctrl
;
/**
* @var ilToolbarGUI;
/**
*/
* @var ilToolbarGUI;
protected
$toolbar
;
*/
protected
$toolbar
;
/**
* @var ilTemplate
/**
*/
* @var ilTemplate
protected
$tpl
;
*/
protected
$tpl
;
/**
* @var iPlugin
/**
*/
* @var ilPlugin
protected
$plugin
;
*/
protected
$plugin
;
/**
* @var ilLanguage
/**
*/
* @var ilLanguage
protected
$lng
;
*/
protected
$lng
;
/**
* @var ilTabsGUI
/**
*/
* @var ilTabsGUI
protected
$tabs
;
*/
protected
$tabs
;
/**
* @var ilObjUser
/**
*/
* @var ilObjUser
protected
$user
;
*/
protected
$user
;
/**
* @param ilObjQuestionSetPoolGUI $controller
/** @var \ILIAS\UI\Factory */
*/
protected
$uiFactory
;
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
/** @var \ILIAS\UI\Renderer */
{
protected
$uiRenderer
;
global
$DIC
;
/**
$this
->
controller
=
$controller
;
* @param ilObjQuestionSetPoolGUI $controller
$this
->
ctrl
=
$DIC
->
ctrl
();
*/
$this
->
tpl
=
$DIC
->
ui
()
->
mainTemplate
();
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
$this
->
plugin
=
$this
->
controller
->
plugin
;
{
$this
->
lng
=
$DIC
->
language
();
global
$DIC
;
$this
->
toolbar
=
$DIC
->
toolbar
();
$this
->
tabs
=
$DIC
->
tabs
();
$this
->
controller
=
$controller
;
$this
->
user
=
$DIC
->
user
();
$this
->
ctrl
=
$DIC
->
ctrl
();
$this
->
activateTab
();
$this
->
tpl
=
$DIC
->
ui
()
->
mainTemplate
();
$this
->
includeRequirements
();
$this
->
plugin
=
$this
->
controller
->
plugin
;
}
$this
->
lng
=
$DIC
->
language
();
$this
->
toolbar
=
$DIC
->
toolbar
();
protected
function
initToolbar
()
$this
->
tabs
=
$DIC
->
tabs
();
{
$this
->
user
=
$DIC
->
user
();
$this
->
toolbar
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
uiFactory
=
$DIC
->
ui
()
->
factory
();
}
$this
->
uiRenderer
=
$DIC
->
ui
()
->
renderer
();
protected
function
addToolbarButton
(
$text
,
$command
,
array
$params
=
array
())
$this
->
activateTab
();
{
$this
->
includeRequirements
();
if
(
$this
->
toolbar
==
null
)
}
{
$this
->
initToolbar
();
protected
function
initToolbar
()
}
{
$this
->
toolbar
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
foreach
(
$params
as
$key
=>
$param
)
}
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
$param
);
protected
function
addToolbarButton
(
$text
,
$command
,
array
$params
=
array
())
}
{
if
(
$this
->
toolbar
==
null
)
{
$link
=
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
$command
);
$this
->
initToolbar
();
}
foreach
(
$params
as
$key
=>
$param
)
{
foreach
(
$params
as
$key
=>
$param
)
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
$param
);
}
}
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
$text
),
$link
);
$link
=
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
$command
);
}
foreach
(
$params
as
$key
=>
$param
)
{
/**
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
""
);
* Activates the tab for the current GUI
}
*/
private
function
activateTab
()
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
$text
),
$link
);
{
}
$this
->
tabs
->
activateTab
(
$this
->
getCurrentTab
());
}
/**
* Activates the tab for the current GUI
private
function
includeRequirements
()
*/
{
private
function
activateTab
()
$requirements
=
$this
->
getRequirements
();
{
$this
->
tabs
->
activateTab
(
$this
->
getCurrentTab
());
if
(
!
empty
(
$requirements
))
}
{
foreach
(
$requirements
as
$requirement
)
private
function
includeRequirements
()
{
{
require_once
$this
->
controller
->
plugin
->
getDirectory
()
.
DIRECTORY_SEPARATOR
.
"classes"
.
DIRECTORY_SEPARATOR
.
$requirement
;
$requirements
=
$this
->
getRequirements
();
}
}
if
(
!
empty
(
$requirements
))
{
}
foreach
(
$requirements
as
$requirement
)
{
require_once
$this
->
controller
->
plugin
->
getDirectory
()
.
DIRECTORY_SEPARATOR
.
"classes"
.
DIRECTORY_SEPARATOR
.
$requirement
;
protected
function
redirect
(
$command
,
$params
=
array
())
}
{
}
foreach
(
$params
as
$key
=>
$param
)
}
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
$param
);
protected
function
redirect
(
$command
,
$params
=
array
())
}
{
foreach
(
$params
as
$key
=>
$param
)
{
$this
->
ctrl
->
redirect
(
$this
->
controller
,
$command
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
$key
,
$param
);
}
}
/**
$this
->
ctrl
->
redirect
(
$this
->
controller
,
$command
);
* Returns the current tab name
}
*
* return string
/**
*/
* Returns the current tab name
abstract
protected
function
getCurrentTab
();
*
* return string
/**
*/
* @return array
abstract
protected
function
getCurrentTab
();
*/
abstract
protected
function
getRequirements
();
/**
* @return array
*/
abstract
protected
function
getRequirements
();
}
}
classes/controllers/abstract.ilPluginControllerTableGUI.php
View file @
381d5850
...
@@ -8,17 +8,17 @@ require_once "abstract.ilPluginControllerGUI.php";
...
@@ -8,17 +8,17 @@ require_once "abstract.ilPluginControllerGUI.php";
* Date: 02.10.13
* Date: 02.10.13
* Time: 15:11
* Time: 15:11
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract
class
ilPluginControllerTableGUI
extends
ilPluginControllerGUI
abstract
class
ilPluginControllerTableGUI
extends
ilPluginControllerGUI
{
{
/**
/**
* @param string $key
* @param string $key
*
*
* @return bool
* @return bool
*/
*/
protected
function
dataSelected
(
$key
)
protected
function
dataSelected
(
$key
)
{
{
return
(
isset
(
$_POST
[
$key
])
&&
(
is_array
(
$_POST
[
$key
])
&&
count
(
$_POST
[
$key
])
>
0
));
return
(
isset
(
$_POST
[
$key
])
&&
(
is_array
(
$_POST
[
$key
])
&&
count
(
$_POST
[
$key
])
>
0
));
}
}
}
}
classes/controllers/abstract.ilQuestionSetPoolConditionGUI.php
View file @
381d5850
...
@@ -10,71 +10,65 @@ require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/Qu
...
@@ -10,71 +10,65 @@ require_once "Customizing/global/plugins/Services/Repository/RepositoryObject/Qu
* Date: 11.02.14
* Date: 11.02.14
* Time: 10:39
* Time: 10:39
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract
class
ilQuestionSetPoolConditionGUI
extends
ilPluginControllerFormGUI
abstract
class
ilQuestionSetPoolConditionGUI
extends
ilPluginControllerFormGUI
{
{
public
function
showPreview
()
{
$gui
=
assQuestion
::
instantiateQuestionGUI
((
int
)
$_GET
[
"question_id"
]);
$gui
->
setTargetGuiClass
(
"ilObjQuestionSetPoolGUI"
);
$gui
->
setQuestionHeaderBlockBuilder
(
new
ilQuestionSetPoolQuestionHeaderBuilder
(
$gui
->
object
->
getTitle
));
echo
$gui
->
getPreview
();
exit
;
}
public
function
showPreview
()
/**
{
*
$gui
=
assQuestion
::
instantiateQuestionGUI
((
int
)
$_GET
[
"question_id"
]);
*/
$gui
->
setTargetGuiClass
(
"ilObjQuestionSetPoolGUI"
);
public
function
afterQuestionChanged
()
$gui
->
setQuestionHeaderBlockBuilder
(
new
ilQuestionSetPoolQuestionHeaderBuilder
(
$gui
->
object
->
getTitle
));
{
echo
$gui
->
getPreview
(
);
$template
=
new
ilTemplate
(
'tpl.il_xqsp_after_question_changed.html'
,
false
,
false
,
'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
);
exit
;
$this
->
tpl
->
setContent
(
$template
->
get
())
;
}
}
/**
/**
*
* @param ilQuestionSetPoolNode $model
*/
* @param ilTemplate $template
public
function
afterQuestionChanged
()
*/
{
protected
function
renderQuestionInfo
(
$model
,
$template
)
$template
=
new
ilTemplate
(
'tpl.il_xqsp_after_question_changed.html'
,
FALSE
,
FALSE
,
'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
);
{
$this
->
tpl
->
setContent
(
$template
->
get
());
$questions
=
$model
->
getPath
()
->
getQuestionsLowerAndEqualsIndex
(
$model
->
getIndex
());
}
/**
$this
->
controller
->
populateContentStyleBlock
();
* @param ilQuestionSetPoolNode $model
$this
->
controller
->
populateSyntaxStyleBlock
();
* @param ilTemplate $template
*/
protected
function
renderQuestionInfo
(
$model
,
$template
)
{
$questions
=
$model
->
getPath
()
->
getQuestionsLowerAndEqualsIndex
(
$model
->
getIndex
());
$this
->
controller
->
populateContentStyleBlock
();
$mathJaxSetting
=
new
ilSetting
(
"MathJax"
);
$this
->
controller
->
populateSyntaxStyleBlock
();
if
(
$mathJaxSetting
->
get
(
"enable"
))
{
$this
->
controller
->
tpl
->
addJavaScript
(
$mathJaxSetting
->
get
(
"path_to_mathjax"
));
}
include_once
"./Services/Administration/classes/class.ilSetting.php"
;
foreach
(
$questions
as
$key
=>
$question_data
)
{
$mathJaxSetting
=
new
ilSetting
(
"MathJax"
);
$params
=
array
(
if
(
$mathJaxSetting
->
get
(
"enable"
))
'node_id'
=>
(
int
)
$_GET
[
'node_id'
],
{
'cmd'
=>
get_class
(
$this
)
.
'.afterQuestionChanged'
$this
->
controller
->
tpl
->
addJavaScript
(
$mathJaxSetting
->
get
(
"path_to_mathjax"
)
);
);
}
$edit
=
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_data
[
"question_id"
];
foreach
(
$questions
as
$key
=>
$question_data
)
$template
->
setCurrentBlock
(
"question_row"
);
{
$template
->
setVariable
(
"CSS_ROW"
,
"tblrow"
.
$key
%
2
);
$params
=
array
(
$template
->
setVariable
(
"QUESTION_INDEX"
,
"Q"
.
$question_data
[
"question_index"
]);
'node_id'
=>
(
int
)
$_GET
[
'node_id'
],
$template
->
setVariable
(
"QUESTION_ID"
,
$question_data
[
"question_id"
]);
'cmd'
=>
get_class
(
$this
)
.
'.afterQuestionChanged'
$template
->
setVariable
(
"PREVIEW"
,
$this
->
lng
->
txt
(
"preview"
));
);
$template
->
setVariable
(
"EDIT_LINK"
,
$edit
);
$edit
=
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_data
[
"question_id"
];
$template
->
setVariable
(
"EDIT"
,
$this
->
lng
->
txt
(
"edit"
));
$template
->
setVariable
(
"QUESTION_TITLE"
,
$question_data
[
"title"
]);
$template
->
parseCurrentBlock
();
}
$template
->
setCurrentBlock
(
"question_row"
);
$template
->
setVariable
(
"TXT_QUESTION"
,
$this
->
controller
->
lng
->
txt
(
'question'
));
$template
->
setVariable
(
"CSS_ROW"
,
"tblrow"
.
$key
%
2
);
$template
->
setVariable
(
"TXT_ACTIONS"
,
$this
->
controller
->
lng
->
txt
(
'actions'
));
$template
->
setVariable
(
"QUESTION_INDEX"
,
"Q"
.
$question_data
[
"question_index"
]);
$template
->
setVariable
(
"PREVIEW_LINK"
,
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
get_class
(
$this
)
.
".showPreview"
,
""
,
true
));
$template
->
setVariable
(
"QUESTION_ID"
,
$question_data
[
"question_id"
]);
$template
->
setVariable
(
'CLOSE_IMG_SRC'
,
ilGlyphGUI
::
get
(
ilGlyphGUI
::
CLOSE
));
$template
->
setVariable
(
"PREVIEW"
,
$this
->
lng
->
txt
(
"preview"
));
$template
->
setVariable
(
'CLOSE_IMG_ALT'
,
$this
->
controller
->
lng
->
txt
(
'close'
));
$template
->
setVariable
(
"EDIT_LINK"
,
$edit
);
}
$template
->
setVariable
(
"EDIT"
,
$this
->
lng
->
txt
(
"edit"
));
$template
->
setVariable
(
"QUESTION_TITLE"
,
$question_data
[
"title"
]);
$template
->
parseCurrentBlock
();
}
$template
->
setVariable
(
"TXT_QUESTION"
,
$this
->
controller
->
lng
->
txt
(
'question'
));
$template
->
setVariable
(
"TXT_ACTIONS"
,
$this
->
controller
->
lng
->
txt
(
'actions'
));
$template
->
setVariable
(
"PREVIEW_LINK"
,
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
get_class
(
$this
)
.
".showPreview"
,
""
,
true
));
include_once
"Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"
;
$template
->
setVariable
(
'CLOSE_IMG_SRC'
,
ilGlyphGUI
::
get
(
ilGlyphGUI
::
CLOSE
));
$template
->
setVariable
(
'CLOSE_IMG_ALT'
,
$this
->
controller
->
lng
->
txt
(
'close'
));
}
}
}
classes/controllers/class.ilQuestionSetPoolInitialConditionGUI.php
View file @
381d5850
...
@@ -8,273 +8,254 @@ require_once "abstract.ilQuestionSetPoolConditionGUI.php";
...
@@ -8,273 +8,254 @@ require_once "abstract.ilQuestionSetPoolConditionGUI.php";
* Date: 21.11.13
* Date: 21.11.13
* Time: 14:15
* Time: 14:15
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolInitialConditionGUI
extends
ilQuestionSetPoolConditionGUI
class
ilQuestionSetPoolInitialConditionGUI
extends
ilQuestionSetPoolConditionGUI
{
{
/**
/**
* @var array $feedback_types needed for tiny-mce
* @var array $feedback_types needed for tiny-mce
*/
*/
protected
$feedback_types
=
array
(
protected
$feedback_types
=
array
(
0
=>
array
(
'post_var'
=>
'true_feedback'
,
'obj_type'
=>
'itf'
),
0
=>
array
(
'post_var'
=>
'true_feedback'
,
'obj_type'
=>
'itf'
),
2
=>
array
(
'post_var'
=>
'false_feedback'
,
'obj_type'
=>
'iff'
));
2
=>
array
(
'post_var'
=>
'false_feedback'
,
'obj_type'
=>
'iff'
));
public
function
edit
()
public
function
edit
()
{
{
include_once
'Services/jQuery/classes/class.iljQueryUtil.php'
;
iljQueryUtil
::
initjQuery
();
iljQueryUtil
::
initjQuery
();
ilYuiUtil
::
initPanel
();
include_once
'Services/YUI/classes/class.ilYuiUtil.php'
;
ilYuiUtil
::
initOverlay
();
ilYuiUtil
::
initPanel
();
$this
->
tpl
->
addJavascript
(
'./Services/UIComponent/Overlay/js/ilOverlay.js'
);
ilYuiUtil
::
initOverlay
();
$this
->
tpl
->
addJavaScript
(
"./Services/JavaScript/js/Basic.js"
);
$this
->
tpl
->
addJavascript
(
'./Services/UIComponent/Overlay/js/ilOverlay.js'
);
$this
->
tpl
->
addJavaScript
(
"./Services/JavaScript/js/Basic.js"
);
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$model
=
$this
->
loadModel
();
$this
->
bindModelToForm
(
$model
);
$this
->
initForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$this
->
renderQuestionInfo
(
$model
,
$template
);
$this
->
renderQuestionInfo
(
$model
,
$template
);
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$button
=
ilLinkButton
::
getInstance
();
$button
->
addCSSClass
(
'toggle_feedback'
);
require_once
'Services/UIComponent/Button/classes/class.ilLinkButton.php'
;
$button
->
setCaption
(
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
),
false
);
$button
=
ilLinkButton
::
getInstance
();
$this
->
toolbar
->
addButtonInstance
(
$button
);
$button
->
addCSSClass
(
'toggle_feedback'
);
$template
->
setVariable
(
"TXT_SHOW_FEEDBACK"
,
$this
->
plugin
->
txt
(
'show_feedback_form_parts'
));
$button
->
setCaption
(
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
),
false
);
$template
->
setVariable
(
"TXT_HIDE_FEEDBACK"
,
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
));
$this
->
toolbar
->
addButtonInstance
(
$button
);
$template
->
setVariable
(
"TXT_SHOW_FEEDBACK"
,
$this
->
plugin
->
txt
(
'show_feedback_form_parts'
));
$this
->
tpl
->
setContent
(
$template
->
get
());
$template
->
setVariable
(
"TXT_HIDE_FEEDBACK"
,
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
));
}
$this
->
tpl
->
setContent
(
$template
->
get
());
public
function
update
()
}
{
$model
=
$this
->
loadModel
();
public
function
update
()
$this
->
initForm
(
$model
);
{
if
(
$this
->
form
->
checkInput
())
{
$model
=
$this
->
loadModel
();
$model
->
bindForm
(
$this
->
form
);
$this
->
initForm
(
$model
);
if
(
$this
->
form
->
checkInput
())
$isValid
=
ilQuestionSetPoolConditionValidator
::
isValid
(
{
$model
->
getInitialCondition
(),
$model
->
bindForm
(
$this
->
form
);
$model
,
$model
->
getPath
()
->
getNodes
()
->
getData
(),
$isValid
=
ilQuestionSetPoolConditionValidator
::
isValid
(
$this
->
plugin
$model
->
getInitialCondition
(),
);
$model
,
$model
->
getPath
()
->
getNodes
()
->
getData
(),
if
(
$isValid
)
{
$this
->
plugin
$model
->
update
();
);
$this
->
copyTemporaryMobs
(
$model
);
if
(
$isValid
)
$this
->
deleteUnusedMobs
(
$model
);
{
$model
->
update
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$this
->
redirect
(
$this
->
copyTemporaryMobs
(
$model
);
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
deleteUnusedMobs
(
$model
);
$this
->
getAfterUpdateRedirectParams
(
$model
)
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
}
$this
->
redirect
(
}
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectParams
(
$model
)
$this
->
form
->
setValuesByPost
();
);
}
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
}
$this
->
renderQuestionInfo
(
$model
,
$template
);
$this
->
form
->
setValuesByPost
();
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$this
->
renderQuestionInfo
(
$model
,
$template
);
$this
->
tpl
->
setContent
(
$template
->
get
());
}
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
public
function
remove
()
{
$this
->
tpl
->
setContent
(
$template
->
get
());
$model
=
$this
->
loadModel
();
}
$model
->
read
();
$model
->
setInitialCondition
(
null
);
public
function
remove
()
$model
->
update
();
{
$model
=
$this
->
loadModel
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$model
->
read
();
$this
->
redirect
(
$model
->
setInitialCondition
(
null
);
$this
->
getAfterUpdateRedirectCmd
(),
$model
->
update
();
$this
->
getAfterUpdateRedirectParams
(
$model
)
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
}
$this
->
redirect
(
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectParams
(
$model
)
/**
);
* Loads and returns the Model for the controller gui
}
* @return ilQuestionSetPoolNode
*/
protected
function
loadModel
()
/**
{
* Loads and returns the Model for the controller gui
$id
=
(
isset
(
$_GET
[
'node_id'
]))
?
(
int
)
$_GET
[
'node_id'
]
:
(
int
)
$_POST
[
'id'
];
* @return ilQuestionSetPoolNode
$model
=
new
ilQuestionSetPoolNode
(
$id
);
*/
$model
->
read
();
protected
function
loadModel
()
{
return
$model
;
$id
=
(
isset
(
$_GET
[
'node_id'
]))
?
(
int
)
$_GET
[
'node_id'
]
:
(
int
)
$_POST
[
'id'
];
}
$model
=
new
ilQuestionSetPoolNode
(
$id
);
$model
->
read
();
/**
* Initialize the PropertyFormGUI for this controller
return
$model
;
*
}
* @param $model ilQuestionSetPoolNode
*/
/**
protected
function
initForm
(
$model
)
* Initialize the PropertyFormGUI for this controller
{
*
$this
->
form
=
new
ilPropertyFormGUI
();
* @param $model ilQuestionSetPoolNode
$this
->
form
->
setName
(
'condition_form'
);
*/
$this
->
form
->
setTableWidth
(
"100%"
);
protected
function
initForm
(
$model
)
$this
->
form
->
setTitle
(
sprintf
(
{
$this
->
plugin
->
txt
(
"edit_initial_condition_title"
),
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
$model
->
getPath
()
->
getSet
()
->
getTitle
(),
$model
->
getPath
()
->
getTitle
(),
$this
->
form
=
new
ilPropertyFormGUI
();
$model
->
getIndex
()
$this
->
form
->
setName
(
'condition_form'
);
));
$this
->
form
->
setTableWidth
(
"100%"
);
$this
->
form
->
setTitle
(
sprintf
(
$node_id
=
new
ilHiddenInputGUI
(
"id"
);
$this
->
plugin
->
txt
(
"edit_initial_condition_title"
),
$node_id
->
setRequired
(
true
);
$model
->
getPath
()
->
getSet
()
->
getTitle
(),
$model
->
getPath
()
->
getTitle
(),
$initial_condition
=
new
ilConditionInputGUI
(
$this
->
plugin
->
txt
(
"initial_condition"
),
"initial_condition"
);
$model
->
getIndex
()
$initial_condition
->
setInlineStyle
(
'width:95%'
);
));
$initial_condition
->
setRequired
(
false
);
$node_id
=
new
ilHiddenInputGUI
(
"id"
);
$this
->
form
->
addItem
(
$node_id
);
$node_id
->
setRequired
(
true
);
$this
->
form
->
addItem
(
$initial_condition
);
$initial_condition
=
new
ilConditionInputGUI
(
$this
->
plugin
->
txt
(
"initial_condition"
),
"initial_condition"
);
$true_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_feedback'
),
'true_feedback'
);
$initial_condition
->
setInlineStyle
(
'width:95%'
);
$true_feedback
->
setUseRte
(
true
);
$initial_condition
->
setRequired
(
false
);
$true_feedback
->
addPlugin
(
"latex"
);
$true_feedback
->
addButton
(
"latex"
);
$this
->
form
->
addItem
(
$node_id
);
$true_feedback
->
setRTESupport
(
$model
->
getId
(),
'x_itf:html'
,
'assessment'
);
$this
->
form
->
addItem
(
$initial_condition
);
$true_feedback
->
setRteTagSet
(
'full'
);
$this
->
form
->
addItem
(
$true_feedback
);
$true_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_feedback'
),
'true_feedback'
);
$true_feedback
->
setUseRte
(
TRUE
);
$false_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'false_feedback'
),
'false_feedback'
);
$true_feedback
->
addPlugin
(
"latex"
);
$false_feedback
->
setUseRte
(
true
);
$true_feedback
->
addButton
(
"latex"
);
$false_feedback
->
addPlugin
(
"latex"
);
$true_feedback
->
setRTESupport
(
$model
->
getId
(),
'x_itf:html'
,
'assessment'
);
$false_feedback
->
addButton
(
"latex"
);
$true_feedback
->
setRteTagSet
(
'full'
);
$false_feedback
->
setRTESupport
(
$model
->
getId
(),
'x_iff:html'
,
'assessment'
);
$this
->
form
->
addItem
(
$true_feedback
);
$false_feedback
->
setInfo
(
$this
->
plugin
->
txt
(
'false_feedback_info'
));
$false_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'false_feedback'
),
'false_feedback'
);
$false_feedback
->
setRteTagSet
(
'full'
);
$false_feedback
->
setUseRte
(
TRUE
);
$this
->
form
->
addItem
(
$false_feedback
);
$false_feedback
->
addPlugin
(
"latex"
);
$false_feedback
->
addButton
(
"latex"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getPath
()
->
getId
());
$false_feedback
->
setRTESupport
(
$model
->
getId
(),
'x_iff:html'
,
'assessment'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getPath
()
->
getSet
()
->
getId
());
$false_feedback
->
setInfo
(
$this
->
plugin
->
txt
(
'false_feedback_info'
));
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$false_feedback
->
setRteTagSet
(
'full'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
form
->
addItem
(
$false_feedback
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolInitialConditionGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getPath
()
->
getId
());
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getPath
()
->
getSet
()
->
getId
());
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
/**
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
* Get the redirect action after an update was successful
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
* @return string
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolInitialConditionGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
*/
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
protected
function
getAfterUpdateRedirectCmd
()
}
{
return
"ilQuestionSetPoolNodesGUI.listNodes"
;
/**
}
* Get the redirect action after an update was successful
* @return string
/**
*/
* @param $model
protected
function
getAfterUpdateRedirectCmd
()
*
{
* @return array
return
"ilQuestionSetPoolNodesGUI.listNodes"
;
*/
}
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
/**
return
array
(
* @param $model
"set_id"
=>
$model
->
getPath
()
->
getSet
()
->
getId
(),
*
"path_id"
=>
$model
->
getPath
()
->
getId
()
* @return array
);
*/
}
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
/**
return
array
(
* Returns the current tab name
"set_id"
=>
$model
->
getPath
()
->
getSet
()
->
getId
(),
* return string
"path_id"
=>
$model
->
getPath
()
->
getId
()
*/
);
protected
function
getCurrentTab
()
}
{
return
"content"
;
/**
}
* Returns the current tab name
* return string
/**
*/
* @return array
protected
function
getCurrentTab
()
*/
{
protected
function
getRequirements
()
return
"content"
;
{
}
return
array
(
"models/class.ilQuestionSetPoolNode.php"
,
/**
"providers/class.ilParserQuestionProvider.php"
,
* @return array
"utils/abstract.ilQuestionSetPoolInfoBox.php"
,
*/
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
,
protected
function
getRequirements
()
"utils/class.ilConditionInputGUI.php"
{
);
return
array
(
}
"models/class.ilQuestionSetPoolNode.php"
,
"providers/class.ilParserQuestionProvider.php"
,
protected
function
copyTemporaryMobs
(
$model
)
"utils/abstract.ilQuestionSetPoolInfoBox.php"
,
{
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
,
global
$DIC
;
"utils/class.ilConditionInputGUI.php"
$ilUser
=
$DIC
->
user
();
);
}
foreach
(
$this
->
feedback_types
as
$type
)
{
$mediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
protected
function
copyTemporaryMobs
(
$model
)
$myMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$ilUser
->
getId
());
{
foreach
(
$mediaObjects
as
$mob
)
{
global
$DIC
;
foreach
(
$myMediaObjects
as
$myMob
)
{
$ilUser
=
$DIC
->
user
();
if
(
$mob
==
$myMob
)
{
// change usage
foreach
(
$this
->
feedback_types
as
$type
)
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$ilUser
->
getId
());
{
break
;
$mediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
}
$myMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$ilUser
->
getId
());
}
foreach
(
$mediaObjects
as
$mob
)
ilObjMediaObject
::
_saveUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
{
}
foreach
(
$myMediaObjects
as
$myMob
)
}
{
}
if
(
$mob
==
$myMob
)
{
protected
function
deleteUnusedMobs
(
$model
)
// change usage
{
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$ilUser
->
getId
());
foreach
(
$this
->
feedback_types
as
$type
)
{
break
;
$oldMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
}
$curMediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
}
foreach
(
$oldMediaObjects
as
$oldMob
)
{
ilObjMediaObject
::
_saveUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
$found
=
false
;
}
foreach
(
$curMediaObjects
as
$curMob
)
{
}
if
(
$oldMob
==
$curMob
)
{
}
$found
=
true
;
break
;
protected
function
deleteUnusedMobs
(
$model
)
}
{
}
foreach
(
$this
->
feedback_types
as
$type
)
if
(
!
$found
)
{
{
if
(
ilObjMediaObject
::
_exists
(
$oldMob
))
{
// remove usage of deleted media objects
ilObjMediaObject
::
_removeUsage
(
$oldMob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php'
;
$mob_obj
=
new
ilObjMediaObject
(
$oldMob
);
$oldMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
$mob_obj
->
delete
();
$curMediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
}
foreach
(
$oldMediaObjects
as
$oldMob
)
}
{
}
$found
=
false
;
}
foreach
(
$curMediaObjects
as
$curMob
)
}
{
if
(
$oldMob
==
$curMob
)
{
$found
=
true
;
break
;
}
}
if
(
!
$found
)
{
if
(
ilObjMediaObject
::
_exists
(
$oldMob
))
{
ilObjMediaObject
::
_removeUsage
(
$oldMob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$model
->
getId
());
$mob_obj
=
new
ilObjMediaObject
(
$oldMob
);
$mob_obj
->
delete
();
}
}
}
}
}
}
}
classes/controllers/class.ilQuestionSetPoolJumpConditionGUI.php
View file @
381d5850
...
@@ -8,463 +8,420 @@ require_once "abstract.ilQuestionSetPoolConditionGUI.php";
...
@@ -8,463 +8,420 @@ require_once "abstract.ilQuestionSetPoolConditionGUI.php";
* Date: 05.12.13
* Date: 05.12.13
* Time: 09:20
* Time: 09:20
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolJumpConditionGUI
extends
ilQuestionSetPoolConditionGUI
class
ilQuestionSetPoolJumpConditionGUI
extends
ilQuestionSetPoolConditionGUI
{
{
/**
/**
* @var array $feedback_types needed for tiny-mce
* @var array $feedback_types needed for tiny-mce
*/
*/
protected
$feedback_types
=
array
(
protected
$feedback_types
=
array
(
0
=>
array
(
'post_var'
=>
'true_feedback'
,
'obj_type'
=>
'tf'
),
0
=>
array
(
'post_var'
=>
'true_feedback'
,
'obj_type'
=>
'tf'
),
1
=>
array
(
'post_var'
=>
'true_jump_feedback'
,
'obj_type'
=>
'tjf'
),
1
=>
array
(
'post_var'
=>
'true_jump_feedback'
,
'obj_type'
=>
'tjf'
),
2
=>
array
(
'post_var'
=>
'false_feedback'
,
'obj_type'
=>
'ff'
));
2
=>
array
(
'post_var'
=>
'false_feedback'
,
'obj_type'
=>
'ff'
));
/**
/**
* @var ilQuestionSetPoolJumpCondition
* @var ilQuestionSetPoolJumpCondition
*/
*/
protected
$model
;
protected
$model
;
public
function
edit
()
public
function
edit
()
{
{
include_once
'Services/jQuery/classes/class.iljQueryUtil.php'
;
iljQueryUtil
::
initjQuery
();
iljQueryUtil
::
initjQuery
();
ilYuiUtil
::
initPanel
();
include_once
'Services/YUI/classes/class.ilYuiUtil.php'
;
ilYuiUtil
::
initOverlay
();
ilYuiUtil
::
initPanel
();
$this
->
tpl
->
addJavascript
(
'./Services/UIComponent/Overlay/js/ilOverlay.js'
);
ilYuiUtil
::
initOverlay
();
$this
->
tpl
->
addJavaScript
(
"./Services/JavaScript/js/Basic.js"
);
$this
->
tpl
->
addJavascript
(
'./Services/UIComponent/Overlay/js/ilOverlay.js'
);
$this
->
tpl
->
addJavaScript
(
"./Services/JavaScript/js/Basic.js"
);
$this
->
model
=
$this
->
loadModel
();
$this
->
initForm
(
$this
->
model
);
$this
->
model
=
$this
->
loadModel
();
$this
->
bindModelToForm
(
$this
->
model
);
$this
->
initForm
(
$this
->
model
);
$this
->
bindModelToForm
(
$this
->
model
);
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"jump_condition_target_question"
),
true
);
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"jump_condition_target_question"
),
true
);
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$this
->
renderQuestionInfo
(
$this
->
model
->
getNode
(),
$template
);
$this
->
renderQuestionInfo
(
$this
->
model
->
getNode
(),
$template
);
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$button
=
ilLinkButton
::
getInstance
();
$button
->
addCSSClass
(
'toggle_feedback'
);
require_once
'Services/UIComponent/Button/classes/class.ilLinkButton.php'
;
$button
->
setCaption
(
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
),
false
);
$button
=
ilLinkButton
::
getInstance
();
$this
->
toolbar
->
addButtonInstance
(
$button
);
$button
->
addCSSClass
(
'toggle_feedback'
);
$template
->
setVariable
(
"TXT_SHOW_FEEDBACK"
,
$this
->
plugin
->
txt
(
'show_feedback_form_parts'
));
$button
->
setCaption
(
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
),
false
);
$template
->
setVariable
(
"TXT_HIDE_FEEDBACK"
,
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
));
$this
->
toolbar
->
addButtonInstance
(
$button
);
$template
->
setVariable
(
"TXT_SHOW_FEEDBACK"
,
$this
->
plugin
->
txt
(
'show_feedback_form_parts'
));
$this
->
tpl
->
setContent
(
$template
->
get
());
$template
->
setVariable
(
"TXT_HIDE_FEEDBACK"
,
$this
->
plugin
->
txt
(
'hide_feedback_form_parts'
));
}
$this
->
tpl
->
setContent
(
$template
->
get
());
public
function
update
()
}
{
$this
->
model
=
$this
->
loadModel
();
public
function
update
()
{
$this
->
initForm
(
$this
->
model
);
include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php'
;
if
(
$this
->
form
->
checkInput
())
{
$this
->
model
=
$this
->
loadModel
();
$this
->
model
->
bindForm
(
$this
->
form
);
$this
->
initForm
(
$this
->
model
);
$isValid
=
ilQuestionSetPoolConditionValidator
::
isValid
(
if
(
$this
->
form
->
checkInput
())
$this
->
model
->
getJumpCondition
(),
{
$this
->
model
->
getNode
(),
$this
->
model
->
bindForm
(
$this
->
form
);
$this
->
model
->
getNode
()
->
getPath
()
->
getNodes
()
->
getData
(),
$this
->
plugin
$isValid
=
ilQuestionSetPoolConditionValidator
::
isValid
(
);
$this
->
model
->
getJumpCondition
(),
if
(
$isValid
)
{
$this
->
model
->
getNode
(),
$this
->
model
->
update
();
$this
->
model
->
getNode
()
->
getPath
()
->
getNodes
()
->
getData
(),
$this
->
plugin
$this
->
copyTemporaryMobs
();
);
$this
->
deleteUnusedMobs
();
if
(
$isValid
)
$this
->
deleteTemporaryMobs
();
{
$this
->
model
->
update
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$this
->
redirect
(
$this
->
copyTemporaryMobs
();
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
deleteUnusedMobs
();
$this
->
getAfterUpdateRedirectParams
(
$this
->
model
)
$this
->
deleteTemporaryMobs
();
);
}
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
}
$this
->
redirect
(
$this
->
form
->
setValuesByPost
();
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectParams
(
$this
->
model
)
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
);
}
$this
->
renderQuestionInfo
(
$this
->
model
->
getNode
(),
$template
);
}
$this
->
form
->
setValuesByPost
();
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
$template
=
new
ilTemplate
(
"tpl.il_xqsp_condition.html"
,
true
,
true
,
"Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool"
);
$this
->
tpl
->
setContent
(
$template
->
get
());
$this
->
renderQuestionInfo
(
$this
->
model
->
getNode
(),
$template
);
}
$template
->
setVariable
(
"FORM"
,
$this
->
form
->
getHTML
());
public
function
up
()
$template
->
setVariable
(
"INFO"
,
ilQuestionSetPoolInfoBox
::
render
(
$this
->
plugin
));
{
$condition
=
$this
->
loadModel
();
$this
->
tpl
->
setContent
(
$template
->
get
());
$data
=
$condition
->
getNode
()
->
getJumpConditionList
()
->
getData
();
}
foreach
(
$data
as
$key
=>
$element
)
{
if
(
$element
[
"id"
]
==
$condition
->
getId
())
{
public
function
up
()
$this
->
swap
(
$condition
,
$data
[
$key
-
1
][
"id"
]);
{
break
;
$condition
=
$this
->
loadModel
();
}
$data
=
$condition
->
getNode
()
->
getJumpConditionList
()
->
getData
();
}
foreach
(
$data
as
$key
=>
$element
)
{
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
if
(
$element
[
"id"
]
==
$condition
->
getId
())
"path_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getId
(),
{
"set_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
()
$this
->
swap
(
$condition
,
$data
[
$key
-
1
][
"id"
]);
));
break
;
}
}
}
public
function
down
()
{
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
$condition
=
$this
->
loadModel
();
"path_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getId
(),
$data
=
$condition
->
getNode
()
->
getJumpConditionList
()
->
getData
();
"set_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
()
foreach
(
$data
as
$key
=>
$element
)
{
));
if
(
$element
[
"id"
]
==
$condition
->
getId
())
{
}
$this
->
swap
(
$condition
,
$data
[
$key
+
1
][
"id"
]);
break
;
public
function
down
()
}
{
}
$condition
=
$this
->
loadModel
();
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
$data
=
$condition
->
getNode
()
->
getJumpConditionList
()
->
getData
();
"path_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getId
(),
foreach
(
$data
as
$key
=>
$element
)
"set_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
()
{
));
if
(
$element
[
"id"
]
==
$condition
->
getId
())
}
{
$this
->
swap
(
$condition
,
$data
[
$key
+
1
][
"id"
]);
/**
break
;
* @param ilQuestionSetPoolJumpCondition $condition
}
* @param $swap_condition_id
}
*/
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
protected
function
swap
(
$condition
,
$swap_condition_id
)
"path_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getId
(),
{
"set_id"
=>
$condition
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
()
$swap_condition
=
new
ilQuestionSetPoolJumpCondition
();
));
$swap_condition
->
setId
(
$swap_condition_id
);
}
$swap_condition
->
read
();
/**
$sorting
=
$condition
->
getSorting
();
* @param ilQuestionSetPoolJumpCondition $condition
$condition
->
setSorting
(
$swap_condition
->
getSorting
());
* @param $swap_condition_id
$swap_condition
->
setSorting
(
$sorting
);
*/
protected
function
swap
(
$condition
,
$swap_condition_id
)
$swap_condition
->
update
();
{
$condition
->
update
();
$swap_condition
=
new
ilQuestionSetPoolJumpCondition
();
}
$swap_condition
->
setId
(
$swap_condition_id
);
$swap_condition
->
read
();
public
function
remove
()
$sorting
=
$condition
->
getSorting
();
{
$condition
->
setSorting
(
$swap_condition
->
getSorting
());
$model
=
$this
->
loadModel
();
$swap_condition
->
setSorting
(
$sorting
);
$model
->
remove
();
$swap_condition
->
update
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$condition
->
update
();
$this
->
redirect
(
}
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
getAfterUpdateRedirectParams
(
$model
)
);
public
function
remove
()
}
{
$model
=
$this
->
loadModel
();
/**
$model
->
remove
();
* Loads and returns the Model for the controller gui
* @return ilQuestionSetPoolJumpCondition
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
*/
$this
->
redirect
(
protected
function
loadModel
()
$this
->
getAfterUpdateRedirectCmd
(),
{
$this
->
getAfterUpdateRedirectParams
(
$model
)
$id
=
(
isset
(
$_GET
[
'condition_id'
]))
?
(
int
)
$_GET
[
'condition_id'
]
:
(
int
)
$_POST
[
'id'
];
);
$model
=
new
ilQuestionSetPoolJumpCondition
(
$id
);
}
$model
->
read
();
/**
return
$model
;
* Loads and returns the Model for the controller gui
}
* @return ilQuestionSetPoolJumpCondition
*/
/**
protected
function
loadModel
()
* Initialize the PropertyFormGUI for this controller
{
*
$id
=
(
isset
(
$_GET
[
'condition_id'
]))
?
(
int
)
$_GET
[
'condition_id'
]
:
(
int
)
$_POST
[
'id'
];
* @param $model
$model
=
new
ilQuestionSetPoolJumpCondition
(
$id
);
*/
$model
->
read
();
protected
function
initForm
(
$model
)
{
return
$model
;
global
$DIC
;
}
$ilUser
=
$DIC
->
user
();
/**
$this
->
form
=
new
ilPropertyFormGUI
();
* Initialize the PropertyFormGUI for this controller
$this
->
form
->
setName
(
'condition_form'
);
*
$this
->
form
->
setTableWidth
(
"100%"
);
* @param $model
$this
->
form
->
setTitle
(
sprintf
(
*/
$this
->
plugin
->
txt
(
"jump_condition_title"
),
protected
function
initForm
(
$model
)
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getTitle
(),
{
$model
->
getNode
()
->
getPath
()
->
getTitle
(),
global
$DIC
;
$model
->
getNode
()
->
getIndex
()
$ilUser
=
$DIC
->
user
();
));
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
$node_id
=
new
ilHiddenInputGUI
(
"node_fi"
);
$condition_id
=
new
ilHiddenInputGUI
(
"id"
);
$this
->
form
=
new
ilPropertyFormGUI
();
$this
->
form
->
setName
(
'condition_form'
);
$condition
=
new
ilConditionInputGUI
(
$this
->
plugin
->
txt
(
"condition"
),
"jump_condition"
);
$this
->
form
->
setTableWidth
(
"100%"
);
$condition
->
setInlineStyle
(
'width:95%'
);
$this
->
form
->
setTitle
(
sprintf
(
$this
->
plugin
->
txt
(
"jump_condition_title"
),
$condition
->
setRequired
(
false
);
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getTitle
(),
$model
->
getNode
()
->
getPath
()
->
getTitle
(),
$questions
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
"target_question"
),
"question"
);
$model
->
getNode
()
->
getIndex
()
$questions
->
setRequired
(
true
);
));
$questions
->
setOptions
(
$this
->
getQuestions
());
$node_id
=
new
ilHiddenInputGUI
(
"node_fi"
);
$repititions
=
new
ilNumberInputGUI
(
$this
->
plugin
->
txt
(
"repititions"
),
"repititions"
);
$condition_id
=
new
ilHiddenInputGUI
(
"id"
);
$repititions
->
setSize
(
5
);
$repititions
->
allowDecimals
(
false
);
$condition
=
new
ilConditionInputGUI
(
$this
->
plugin
->
txt
(
"condition"
),
"jump_condition"
);
$repititions
->
setRequired
(
false
);
$condition
->
setInlineStyle
(
'width:95%'
);
$condition
->
setRequired
(
false
);
$this
->
form
->
addItem
(
$node_id
);
$this
->
form
->
addItem
(
$condition_id
);
$questions
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
"target_question"
),
"question"
);
$this
->
form
->
addItem
(
$condition
);
$questions
->
setRequired
(
true
);
$this
->
form
->
addItem
(
$questions
);
$questions
->
setOptions
(
$this
->
getQuestions
());
$this
->
form
->
addItem
(
$repititions
);
$repititions
=
new
ilNumberInputGUI
(
$this
->
plugin
->
txt
(
"repititions"
),
"repititions"
);
$true_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_feedback'
),
'true_feedback'
);
$repititions
->
setSize
(
5
);
$true_feedback
->
setUseRte
(
true
);
$repititions
->
allowDecimals
(
false
);
$true_feedback
->
addPlugin
(
"latex"
);
$repititions
->
setRequired
(
false
);
$true_feedback
->
addButton
(
"latex"
);
if
(
$_GET
[
"condition_id"
])
{
$this
->
form
->
addItem
(
$node_id
);
$true_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_tf'
,
'assessment'
);
$this
->
form
->
addItem
(
$condition_id
);
}
else
{
$this
->
form
->
addItem
(
$condition
);
$true_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_tf~'
,
'assessment'
);
$this
->
form
->
addItem
(
$questions
);
}
$this
->
form
->
addItem
(
$repititions
);
$true_feedback
->
setRteTagSet
(
'full'
);
$this
->
form
->
addItem
(
$true_feedback
);
$true_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_feedback'
),
'true_feedback'
);
$true_feedback
->
setUseRte
(
TRUE
);
$true_jump_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_jump_feedback'
),
'true_jump_feedback'
);
$true_feedback
->
addPlugin
(
"latex"
);
$true_jump_feedback
->
setUseRte
(
true
);
$true_feedback
->
addButton
(
"latex"
);
$true_jump_feedback
->
addPlugin
(
"latex"
);
if
(
$_GET
[
"condition_id"
])
$true_jump_feedback
->
addButton
(
"latex"
);
{
if
(
$_GET
[
"condition_id"
])
{
$true_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_tf'
,
'assessment'
);
$true_jump_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_tjf'
,
'assessment'
);
}
}
else
{
else
$true_jump_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_tjf~:html'
,
'assessment'
);
{
}
$true_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_tf~'
,
'assessment'
);
$true_jump_feedback
->
setRteTagSet
(
'full'
);
}
$this
->
form
->
addItem
(
$true_jump_feedback
);
$true_feedback
->
setRteTagSet
(
'full'
);
$this
->
form
->
addItem
(
$true_feedback
);
$false_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'false_feedback'
),
'false_feedback'
);
$false_feedback
->
setUseRte
(
true
);
$true_jump_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'true_jump_feedback'
),
'true_jump_feedback'
);
$false_feedback
->
addPlugin
(
"latex"
);
$true_jump_feedback
->
setUseRte
(
TRUE
);
$false_feedback
->
addButton
(
"latex"
);
$true_jump_feedback
->
addPlugin
(
"latex"
);
if
(
$_GET
[
"condition_id"
])
{
$true_jump_feedback
->
addButton
(
"latex"
);
$false_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_ff:html'
,
'assessment'
);
if
(
$_GET
[
"condition_id"
])
}
else
{
{
$false_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_ff~:html'
,
'assessment'
);
$true_jump_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_tjf'
,
'assessment'
);
}
}
$false_feedback
->
setRteTagSet
(
'full'
);
else
$this
->
form
->
addItem
(
$false_feedback
);
{
$true_jump_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_tjf~:html'
,
'assessment'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"condition_id"
,
$_GET
[
"condition_id"
]);
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getNode
()
->
getPath
()
->
getId
());
$true_jump_feedback
->
setRteTagSet
(
'full'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
());
$this
->
form
->
addItem
(
$true_jump_feedback
);
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$false_feedback
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
'false_feedback'
),
'false_feedback'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$false_feedback
->
setUseRte
(
TRUE
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"condition_id"
,
""
);
$false_feedback
->
addPlugin
(
"latex"
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolJumpConditionGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
$false_feedback
->
addButton
(
"latex"
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
if
(
$_GET
[
"condition_id"
])
}
{
$false_feedback
->
setRTESupport
(
$_GET
[
"condition_id"
],
'x_ff:html'
,
'assessment'
);
protected
function
bindModelToForm
(
ilPluginModelInterface
$model
)
}
{
else
parent
::
bindModelToForm
(
$model
);
{
$item
=
$this
->
form
->
getItemByPostVar
(
"node_fi"
);
$false_feedback
->
setRTESupport
(
$ilUser
->
getId
(),
'x_ff~:html'
,
'assessment'
);
$item
->
setValue
(
$model
->
getNode
()
->
getId
());
}
$false_feedback
->
setRteTagSet
(
'full'
);
$question_id
=
"-"
;
$this
->
form
->
addItem
(
$false_feedback
);
if
(
$model
->
getQuestion
()
!=
null
)
{
$question_id
=
$model
->
getQuestion
()
->
getId
();
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"condition_id"
,
$_GET
[
"condition_id"
]);
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getNode
()
->
getPath
()
->
getId
());
$item
=
$this
->
form
->
getItemByPostVar
(
"question"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
());
$item
->
setValue
(
$question_id
);
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"condition_id"
,
""
);
/**
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolJumpConditionGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
* @return array
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
*/
protected
function
getQuestions
()
}
{
global
$DIC
;
protected
function
bindModelToForm
(
ilPluginModelInterface
$model
)
$ilDB
=
$DIC
->
database
();
{
parent
::
bindModelToForm
(
$model
);
$questions
=
array
();
$item
=
$this
->
form
->
getItemByPostVar
(
"node_fi"
);
$item
->
setValue
(
$model
->
getNode
()
->
getId
());
$result
=
$ilDB
->
queryF
(
"SELECT qs_qst.question_index, q.title, q.question_id
$question_id
=
"-"
;
if
(
$model
->
getQuestion
()
!=
null
)
{
$question_id
=
$model
->
getQuestion
()
->
getId
();
}
$item
=
$this
->
form
->
getItemByPostVar
(
"question"
);
$item
->
setValue
(
$question_id
);
}
/**
* @return array
*/
protected
function
getQuestions
()
{
global
$DIC
;
$ilDB
=
$DIC
->
database
();
$questions
=
array
();
$result
=
$ilDB
->
queryF
(
"SELECT qs_qst.question_index, q.title, q.question_id
FROM rep_robj_xqsp_qs_qst qs_qst
FROM rep_robj_xqsp_qs_qst qs_qst
INNER JOIN rep_robj_xqsp_node n ON n.question_fi = qs_qst.question_fi
INNER JOIN rep_robj_xqsp_node n ON n.question_fi = qs_qst.question_fi
INNER JOIN qpl_questions q ON q.question_id = qs_qst.question_fi
INNER JOIN qpl_questions q ON q.question_id = qs_qst.question_fi
WHERE n.path_fi = %s AND n.node_index <= %s"
,
WHERE n.path_fi = %s AND n.node_index <= %s"
,
array
(
"integer"
,
"integer"
),
array
(
"integer"
,
"integer"
),
array
(
$this
->
model
->
getNode
()
->
getPath
()
->
getId
(),
$this
->
model
->
getNode
()
->
getIndex
())
array
(
$this
->
model
->
getNode
()
->
getPath
()
->
getId
(),
$this
->
model
->
getNode
()
->
getIndex
())
);
);
while
((
$row
=
$ilDB
->
fetchAssoc
(
$result
))
!=
null
)
while
((
$row
=
$ilDB
->
fetchAssoc
(
$result
))
!=
null
)
{
{
$questions
[
$row
[
"question_id"
]]
=
"Q"
.
$row
[
'question_index'
]
.
" - "
.
$row
[
"title"
];
$questions
[
$row
[
"question_id"
]]
=
"Q"
.
$row
[
'question_index'
]
.
" - "
.
$row
[
"title"
];
}
}
$questions
[
"-"
]
=
$this
->
plugin
->
txt
(
"tst_termination"
);
$questions
[
"-"
]
=
$this
->
plugin
->
txt
(
"tst_termination"
);
return
$questions
;
return
$questions
;
}
}
/**
/**
* Get the redirect action after an update was successful
* Get the redirect action after an update was successful
* @return string
* @return string
*/
*/
protected
function
getAfterUpdateRedirectCmd
()
protected
function
getAfterUpdateRedirectCmd
()
{
{
return
"ilQuestionSetPoolNodesGUI.listNodes"
;
return
"ilQuestionSetPoolNodesGUI.listNodes"
;
}
}
/**
/**
* @param $model
* @param $model
*
*
* @return array
* @return array
*/
*/
protected
function
getAfterUpdateRedirectParams
(
$model
)
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
{
return
array
(
return
array
(
"set_id"
=>
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
(),
"set_id"
=>
$model
->
getNode
()
->
getPath
()
->
getSet
()
->
getId
(),
"path_id"
=>
$model
->
getNode
()
->
getPath
()
->
getId
()
"path_id"
=>
$model
->
getNode
()
->
getPath
()
->
getId
()
);
);
}
}
/**
/**
* Returns the current tab name
* Returns the current tab name
* return string
* return string
*/
*/
protected
function
getCurrentTab
()
protected
function
getCurrentTab
()
{
{
return
"content"
;
return
"content"
;
}
}
/**
/**
* @return array
* @return array
*/
*/
protected
function
getRequirements
()
protected
function
getRequirements
()
{
{
return
array
(
return
array
(
"models/class.ilQuestionSetPoolJumpCondition.php"
,
"models/class.ilQuestionSetPoolJumpCondition.php"
,
"providers/class.ilParserQuestionProvider.php"
,
"providers/class.ilParserQuestionProvider.php"
,
"utils/abstract.ilQuestionSetPoolInfoBox.php"
,
"utils/abstract.ilQuestionSetPoolInfoBox.php"
,
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
,
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
,
"utils/class.ilConditionInputGUI.php"
"utils/class.ilConditionInputGUI.php"
);
);
}
}
/**
/**
*
*
*/
*/
protected
function
copyTemporaryMobs
()
protected
function
copyTemporaryMobs
()
{
{
global
$DIC
;
global
$DIC
;
$ilUser
=
$DIC
->
user
();
$ilUser
=
$DIC
->
user
();
foreach
(
$this
->
feedback_types
as
$type
)
{
foreach
(
$this
->
feedback_types
as
$type
)
$mediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
{
$myMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
$mediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
foreach
(
$mediaObjects
as
$mob
)
{
$myMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
foreach
(
$myMediaObjects
as
$myMob
)
{
foreach
(
$mediaObjects
as
$mob
)
if
(
$mob
==
$myMob
)
{
{
// change usage
foreach
(
$myMediaObjects
as
$myMob
)
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
{
break
;
if
(
$mob
==
$myMob
)
}
{
}
// change usage
ilObjMediaObject
::
_saveUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
}
break
;
}
}
}
}
ilObjMediaObject
::
_saveUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
/**
}
*
}
*/
}
protected
function
deleteUnusedMobs
()
{
/**
foreach
(
$this
->
feedback_types
as
$type
)
{
*
$oldMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
*/
$curMediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
protected
function
deleteUnusedMobs
()
foreach
(
$oldMediaObjects
as
$oldMob
)
{
{
$found
=
false
;
foreach
(
$this
->
feedback_types
as
$type
)
foreach
(
$curMediaObjects
as
$curMob
)
{
{
if
(
$oldMob
==
$curMob
)
{
// remove usage of deleted media objects
$found
=
true
;
include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php'
;
break
;
$oldMediaObjects
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
}
$curMediaObjects
=
ilRTE
::
_getMediaObjects
(
$this
->
form
->
getInput
(
$type
[
'post_var'
]),
0
);
}
foreach
(
$oldMediaObjects
as
$oldMob
)
if
(
!
$found
)
{
{
if
(
ilObjMediaObject
::
_exists
(
$oldMob
))
{
$found
=
false
;
ilObjMediaObject
::
_removeUsage
(
$oldMob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
foreach
(
$curMediaObjects
as
$curMob
)
$mob_obj
=
new
ilObjMediaObject
(
$oldMob
);
{
$mob_obj
->
delete
();
if
(
$oldMob
==
$curMob
)
}
{
}
$found
=
true
;
}
break
;
}
}
}
}
if
(
!
$found
)
/**
{
*
if
(
ilObjMediaObject
::
_exists
(
$oldMob
))
*/
{
protected
function
deleteTemporaryMobs
()
ilObjMediaObject
::
_removeUsage
(
$oldMob
,
'x_'
.
$type
[
'obj_type'
]
.
':html'
,
$this
->
model
->
getId
());
{
$mob_obj
=
new
ilObjMediaObject
(
$oldMob
);
global
$DIC
;
$mob_obj
->
delete
();
$ilUser
=
$DIC
->
user
();
}
}
try
{
}
foreach
(
$this
->
feedback_types
as
$type
)
{
}
$mobs
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
}
foreach
(
$mobs
as
$mob
)
{
if
(
ilObjMediaObject
::
_exists
(
$mob
))
{
/**
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
*
$mob_obj
=
new
ilObjMediaObject
(
$mob
);
*/
$mob_obj
->
delete
();
protected
function
deleteTemporaryMobs
()
}
{
}
global
$DIC
;
}
$ilUser
=
$DIC
->
user
();
}
catch
(
Exception
$e
)
{
}
try
}
{
include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php'
;
foreach
(
$this
->
feedback_types
as
$type
)
{
$mobs
=
ilObjMediaObject
::
_getMobsOfObject
(
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
foreach
(
$mobs
as
$mob
)
{
if
(
ilObjMediaObject
::
_exists
(
$mob
))
{
ilObjMediaObject
::
_removeUsage
(
$mob
,
'x_'
.
$type
[
'obj_type'
]
.
'~:html'
,
$ilUser
->
getId
());
$mob_obj
=
new
ilObjMediaObject
(
$mob
);
$mob_obj
->
delete
();
}
}
}
}
catch
(
Exception
$e
)
{
}
}
}
}
classes/controllers/class.ilQuestionSetPoolNodeGUI.php
View file @
381d5850
...
@@ -8,271 +8,253 @@ require_once "abstract.ilPluginControllerFormGUI.php";
...
@@ -8,271 +8,253 @@ require_once "abstract.ilPluginControllerFormGUI.php";
* Date: 21.11.13
* Date: 21.11.13
* Time: 14:15
* Time: 14:15
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolNodeGUI
extends
ilPluginControllerFormGUI
class
ilQuestionSetPoolNodeGUI
extends
ilPluginControllerFormGUI
{
{
protected
$redirectCmd
=
"ilQuestionSetPoolNodesGUI.listNodes"
;
protected
$redirectCmd
=
"ilQuestionSetPoolNodesGUI.listNodes"
;
public
function
edit
()
public
function
edit
()
{
{
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
redirectIfUnableToAddNewNode
(
$model
);
$this
->
redirectIfUnableToAddNewNode
(
$model
);
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
}
public
function
updateAndNew
()
public
function
updateAndNew
()
{
{
$this
->
redirectCmd
=
"ilQuestionSetPoolNodeGUI.edit"
;
$this
->
redirectCmd
=
"ilQuestionSetPoolNodeGUI.edit"
;
$this
->
update
();
$this
->
update
();
}
}
public
function
removeConfirmation
()
public
function
removeConfirmation
()
{
{
$model
=
$this
->
loadModel
();
require_once
"./Services/Utilities/classes/class.ilConfirmationGUI.php"
;
$model
->
read
();
$model
=
$this
->
loadModel
();
$model
->
read
();
if
(
!
$model
->
getId
()
||
$model
->
getPath
()
->
getSet
()
->
getContainerObjId
()
!=
$this
->
controller
->
object
->
getId
())
{
if
(
$model
->
getId
())
{
if
(
!
$model
->
getId
()
||
$model
->
getPath
()
->
getSet
()
->
getContainerObjId
()
!=
$this
->
controller
->
object
->
getId
())
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'nodes_del_perm_err_s'
),
implode
(
', '
,
array
(
$model
->
getIndex
()))),
true
);
{
}
if
(
$model
->
getId
())
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'path_id'
,
(
int
)
$_GET
[
'path_id'
]);
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'nodes_del_perm_err_s'
),
implode
(
', '
,
array
(
$model
->
getIndex
()))),
true
);
$this
->
ctrl
->
redirect
(
$this
->
controller
,
'ilQuestionSetPoolNodesGUI.listNodes'
);
}
return
;
$this
->
controller
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
}
$this
->
controller
->
ctrl
->
setParameter
(
$this
->
controller
,
'path_id'
,
(
int
)
$_GET
[
'path_id'
]);
$this
->
controller
->
ctrl
->
redirect
(
$this
->
controller
,
'ilQuestionSetPoolNodesGUI.listNodes'
);
$confirmation
=
new
ilConfirmationGUI
();
return
;
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"node_id"
,
$model
->
getId
());
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getPath
()
->
getSet
()
->
getId
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getPath
()
->
getId
());
$confirmation
=
new
ilConfirmationGUI
();
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
"ilQuestionSetPoolNodesGUI.listNodes"
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"node_id"
,
$model
->
getId
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"node_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
$model
->
getPath
()
->
getSet
()
->
getId
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
$model
->
getPath
()
->
getId
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
"ilQuestionSetPoolNodesGUI.listNodes"
));
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
"confirm_delete_node"
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"node_id"
,
""
);
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
"cancel"
),
"ilQuestionSetPoolNodesGUI.listNodes"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
"confirm"
),
"ilQuestionSetPoolNodeGUI.remove"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
"confirm_delete_node"
));
$confirmation
->
addItem
(
"id"
,
$model
->
getId
(),
"(Q"
.
$model
->
getQuestionIndex
()
.
") "
.
$model
->
getQuestion
()
->
getTitle
());
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
"cancel"
),
"ilQuestionSetPoolNodesGUI.listNodes"
);
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
"confirm"
),
"ilQuestionSetPoolNodeGUI.remove"
);
}
$confirmation
->
addItem
(
"id"
,
$model
->
getId
(),
"(Q"
.
$model
->
getQuestionIndex
()
.
") "
.
$model
->
getQuestion
()
->
getTitle
());
public
function
remove
()
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
{
}
$model
=
$this
->
loadModel
();
$model
->
read
();
public
function
remove
()
{
if
(
!
$model
->
getId
()
||
$model
->
getPath
()
->
getSet
()
->
getContainerObjId
()
!=
$this
->
controller
->
object
->
getId
())
{
$model
=
$this
->
loadModel
();
if
(
$model
->
getId
())
{
$model
->
read
();
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'nodes_del_perm_err_s'
),
implode
(
', '
,
array
(
$model
->
getIndex
()))),
true
);
}
if
(
!
$model
->
getId
()
||
$model
->
getPath
()
->
getSet
()
->
getContainerObjId
()
!=
$this
->
controller
->
object
->
getId
())
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'path_id'
,
(
int
)
$_GET
[
'path_id'
]);
if
(
$model
->
getId
())
$this
->
ctrl
->
redirect
(
$this
->
controller
,
'ilQuestionSetPoolNodesGUI.listNodes'
);
{
return
;
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'nodes_del_perm_err_s'
),
implode
(
', '
,
array
(
$model
->
getIndex
()))),
true
);
}
}
$this
->
controller
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
$data
=
$model
->
getPath
()
->
getNodes
()
->
getData
();
$this
->
controller
->
ctrl
->
setParameter
(
$this
->
controller
,
'path_id'
,
(
int
)
$_GET
[
'path_id'
]);
foreach
(
$data
as
$key
=>
$element
)
{
$this
->
controller
->
ctrl
->
redirect
(
$this
->
controller
,
'ilQuestionSetPoolNodesGUI.listNodes'
);
if
(
$element
[
"id"
]
==
$model
->
getId
())
{
return
;
unset
(
$data
[
$key
]);
}
}
}
$data
=
$model
->
getPath
()
->
getNodes
()
->
getData
();
foreach
(
$data
as
$key
=>
$element
)
if
(
$model
->
getIndex
()
==
1
)
{
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"cant_delete_first_node"
),
true
);
if
(
$element
[
"id"
]
==
$model
->
getId
())
{
$this
->
redirect
(
unset
(
$data
[
$key
]);
"ilQuestionSetPoolNodesGUI.listNodes"
,
}
$this
->
getAfterUpdateRedirectParams
(
$model
)
}
);
}
if
(
$model
->
getIndex
()
==
1
)
{
$canBeDeleted
=
true
;
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"cant_delete_first_node"
),
true
);
foreach
(
$data
as
$node
)
{
$node
=
new
ilQuestionSetPoolNode
(
$node
[
"id"
]);
$this
->
redirect
(
$node
->
read
();
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
getAfterUpdateRedirectParams
(
$model
)
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$node
->
getInitialCondition
(),
$node
,
$data
,
$this
->
plugin
))
{
);
$canBeDeleted
=
false
;
}
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_used_in_initial_condition"
),
true
);
}
$canBeDeleted
=
true
;
foreach
(
$data
as
$node
)
$conditions
=
$node
->
getJumpConditionList
()
->
getData
();
{
foreach
(
$conditions
as
$condition
)
{
$node
=
new
ilQuestionSetPoolNode
(
$node
[
"id"
]);
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$condition
[
"jump_condition"
],
$node
,
$data
,
$this
->
plugin
))
{
$node
->
read
();
$canBeDeleted
=
false
;
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_used_in_jump_condition"
),
true
);
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$node
->
getInitialCondition
(),
$node
,
$data
,
$this
->
plugin
))
}
{
$canBeDeleted
=
false
;
if
(
$condition
[
"question_fi"
]
==
$model
->
getQuestion
()
->
getId
()
&&
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_used_in_initial_condition"
),
true
);
$condition
[
"node_fi"
]
!=
$model
->
getId
()
}
)
{
$canBeDeleted
=
false
;
$conditions
=
$node
->
getJumpConditionList
()
->
getData
();
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_is_used_as_target"
),
true
);
foreach
(
$conditions
as
$condition
)
}
{
}
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$condition
[
"jump_condition"
],
$node
,
$data
,
$this
->
plugin
))
}
{
$canBeDeleted
=
false
;
if
(
$canBeDeleted
)
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_used_in_jump_condition"
),
true
);
$model
->
remove
();
}
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"node_deleted"
),
true
);
}
if
(
$condition
[
"question_fi"
]
==
$model
->
getQuestion
()
->
getId
()
&&
$condition
[
"node_fi"
]
!=
$model
->
getId
()
$this
->
redirect
(
)
"ilQuestionSetPoolNodesGUI.listNodes"
,
{
$this
->
getAfterUpdateRedirectParams
(
$model
)
$canBeDeleted
=
false
;
);
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"node_is_used_as_target"
),
true
);
}
}
}
/**
}
* Loads and returns the Model for the controller gui
* @return ilQuestionSetPoolNode
if
(
$canBeDeleted
)
*/
{
protected
function
loadModel
()
$model
->
remove
();
{
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"node_deleted"
),
true
);
$id
=
(
isset
(
$_GET
[
'node_id'
]))
?
(
int
)
$_GET
[
'node_id'
]
:
(
int
)
$_POST
[
'id'
];
}
$model
=
new
ilQuestionSetPoolNode
(
$id
);
$model
->
read
();
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
return
$model
;
$this
->
getAfterUpdateRedirectParams
(
$model
)
}
);
}
/**
* Initialize the PropertyFormGUI for this controller
/**
*
* Loads and returns the Model for the controller gui
* @param $model
* @return ilQuestionSetPoolNode
*/
*/
protected
function
initForm
(
$model
)
protected
function
loadModel
()
{
{
$this
->
form
=
new
ilPropertyFormGUI
();
$id
=
(
isset
(
$_GET
[
'node_id'
]))
?
(
int
)
$_GET
[
'node_id'
]
:
(
int
)
$_POST
[
'id'
];
$this
->
form
->
setTitle
(
sprintf
(
$model
=
new
ilQuestionSetPoolNode
(
$id
);
$this
->
plugin
->
txt
(
"set_node_title"
),
$model
->
read
();
$model
->
getPath
()
->
getSet
()
->
getTitle
(),
$model
->
getPath
()
->
getTitle
()
return
$model
;
));
}
$question
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
'question'
),
"question_fi"
);
/**
$question
->
setRequired
(
true
);
* Initialize the PropertyFormGUI for this controller
$question
->
setOptions
(
$this
->
getQuestionOptions
(
$model
));
*
* @param $model
$this
->
form
->
addItem
(
$question
);
*/
protected
function
initForm
(
$model
)
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
(
int
)
$_GET
[
'path_id'
]);
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$this
->
form
=
new
ilPropertyFormGUI
();
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
form
->
setTitle
(
sprintf
(
$this
->
plugin
->
txt
(
"set_node_title"
),
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodeGUI.updateAndNew"
,
$this
->
plugin
->
txt
(
"save_and_new"
));
$model
->
getPath
()
->
getSet
()
->
getTitle
(),
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodeGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
$model
->
getPath
()
->
getTitle
()
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
));
}
$question
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
'question'
),
"question_fi"
);
/**
$question
->
setRequired
(
true
);
* Get the redirect action after an update was successful
$question
->
setOptions
(
$this
->
getQuestionOptions
(
$model
));
* @return string
*/
$this
->
form
->
addItem
(
$question
);
protected
function
getAfterUpdateRedirectCmd
()
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
(
int
)
$_GET
[
'path_id'
]);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_node_created"
),
true
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
return
$this
->
redirectCmd
;
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
/**
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodeGUI.updateAndNew"
,
$this
->
plugin
->
txt
(
"save_and_new"
));
* @param $model
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodeGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
*
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
$this
->
plugin
->
txt
(
"cancel"
));
* @return array
}
*/
protected
function
getAfterUpdateRedirectParams
(
$model
)
/**
{
* Get the redirect action after an update was successful
return
array
(
* @return string
"path_id"
=>
$model
->
getPath
()
->
getId
(),
*/
"set_id"
=>
$model
->
getPath
()
->
getSet
()
->
getId
()
protected
function
getAfterUpdateRedirectCmd
()
);
{
}
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_node_created"
),
true
);
return
$this
->
redirectCmd
;
/**
}
* Returns the current tab name
* return string
/**
*/
* @param $model
protected
function
getCurrentTab
()
*
{
* @return array
return
"content"
;
*/
}
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
/**
return
array
(
* @return array
"path_id"
=>
$model
->
getPath
()
->
getId
(),
*/
"set_id"
=>
$model
->
getPath
()
->
getSet
()
->
getId
()
protected
function
getRequirements
()
);
{
}
return
array
(
"models/class.ilQuestionSetPoolNode.php"
,
/**
"models/class.ilQuestionSetPoolPath.php"
,
* Returns the current tab name
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
* return string
);
*/
}
protected
function
getCurrentTab
()
{
/**
return
"content"
;
* @param ilQuestionSetPoolNode $model
}
*
* @return array
/**
*/
* @return array
protected
function
getQuestionOptions
(
$model
)
*/
{
protected
function
getRequirements
()
$path
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
{
$path
->
read
();
return
array
(
$nodes
=
$path
->
getNodes
()
->
getData
();
"models/class.ilQuestionSetPoolNode.php"
,
$questions
=
$model
->
getPath
()
->
getSet
()
->
getQuestionList
()
->
getData
();
"models/class.ilQuestionSetPoolPath.php"
,
$options
=
array
();
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
);
foreach
(
$questions
as
$question
)
{
}
$options
[
$question
[
'question_id'
]]
=
$question
[
'title'
];
}
/**
* @param ilQuestionSetPoolNode $model
foreach
(
$nodes
as
$node
)
{
*
if
(
array_key_exists
(
$node
[
"question_fi"
],
$options
))
{
* @return array
unset
(
$options
[
$node
[
"question_fi"
]]);
*/
}
protected
function
getQuestionOptions
(
$model
)
}
{
$path
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
return
$options
;
$path
->
read
();
}
$nodes
=
$path
->
getNodes
()
->
getData
();
$questions
=
$model
->
getPath
()
->
getSet
()
->
getQuestionList
()
->
getData
();
/**
$options
=
array
();
* @param $model
*/
foreach
(
$questions
as
$question
)
protected
function
redirectIfUnableToAddNewNode
(
$model
)
{
{
$options
[
$question
[
'question_id'
]]
=
$question
[
'title'
];
if
(
is_array
(
$this
->
getQuestionOptions
(
$model
))
&&
count
(
$this
->
getQuestionOptions
(
$model
))
==
0
)
{
}
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"unable_to_add_new_node"
),
true
);
$this
->
redirect
(
foreach
(
$nodes
as
$node
)
"ilQuestionSetPoolNodesGUI.listNodes"
,
{
array
(
if
(
array_key_exists
(
$node
[
"question_fi"
],
$options
)){
"path_id"
=>
(
int
)
$_GET
[
"path_id"
],
unset
(
$options
[
$node
[
"question_fi"
]]);
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
}
)
}
);
}
return
$options
;
}
}
/**
* @param $model
*/
protected
function
redirectIfUnableToAddNewNode
(
$model
)
{
if
(
is_array
(
$this
->
getQuestionOptions
(
$model
))
&&
count
(
$this
->
getQuestionOptions
(
$model
))
==
0
)
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"unable_to_add_new_node"
),
true
);
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
"path_id"
=>
(
int
)
$_GET
[
"path_id"
],
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
)
);
}
}
}
}
classes/controllers/class.ilQuestionSetPoolNodesGUI.php
View file @
381d5850
...
@@ -8,235 +8,223 @@ require_once "abstract.ilPluginControllerTableGUI.php";
...
@@ -8,235 +8,223 @@ require_once "abstract.ilPluginControllerTableGUI.php";
* Date: 21.11.13
* Date: 21.11.13
* Time: 11:52
* Time: 11:52
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolNodesGUI
extends
ilPluginControllerTableGUI
class
ilQuestionSetPoolNodesGUI
extends
ilPluginControllerTableGUI
{
{
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
{
{
parent
::
__construct
(
$controller
);
parent
::
__construct
(
$controller
);
$this
->
addSubTabs
();
$this
->
addSubTabs
();
}
}
/**
/**
*
*
*/
*/
public
function
editQuestion
()
public
function
editQuestion
()
{
{
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
controller
->
ensurePermission
(
'write'
);
if
(
!
isset
(
$_GET
[
'q_id'
])
||
!
(
int
)
$_GET
[
'q_id'
])
{
if
(
!
isset
(
$_GET
[
'q_id'
])
||
!
(
int
)
$_GET
[
'q_id'
])
$this
->
listNodes
();
{
return
;
$this
->
listNodes
();
}
return
;
}
$params
=
array
(
'set_id'
=>
(
int
)
$_GET
[
'set_id'
],
$params
=
array
(
'path_id'
=>
(
int
)
$_GET
[
'path_id'
],
'set_id'
=>
(
int
)
$_GET
[
'set_id'
],
'cmd'
=>
__CLASS__
.
'.listNodes'
'path_id'
=>
(
int
)
$_GET
[
'path_id'
],
);
'cmd'
=>
__CLASS__
.
'.listNodes'
);
$question_id
=
(
int
)
$_GET
[
'q_id'
];
ilUtil
::
redirect
(
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_id
);
$question_id
=
(
int
)
$_GET
[
'q_id'
];
}
ilUtil
::
redirect
(
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_id
);
}
public
function
listNodes
()
{
public
function
listNodes
()
$this
->
addToolbarButton
(
"back_to_path_list"
,
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
{
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
$this
->
addToolbarButton
(
"back_to_path_list"
,
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
));
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
$this
->
addToolbarButton
(
"add_node"
,
"ilQuestionSetPoolNodeGUI.edit"
,
array
(
));
"path_id"
=>
(
int
)
$_GET
[
'path_id'
],
$this
->
addToolbarButton
(
"add_node"
,
"ilQuestionSetPoolNodeGUI.edit"
,
array
(
"set_id"
=>
(
int
)
$_GET
[
'set_id'
],
"path_id"
=>
(
int
)
$_GET
[
'path_id'
],
));
"set_id"
=>
(
int
)
$_GET
[
'set_id'
],
));
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
$model
->
read
();
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
$model
->
read
();
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
"set_id"
]);
$table
=
new
ilQuestionSetPoolNodeTableGUI
(
$this
->
controller
,
$this
->
plugin
,
(
int
)
$_GET
[
'path_id'
]);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
"set_id"
]);
$table
->
setModelList
(
$model
->
getNodes
());
$table
=
new
ilQuestionSetPoolNodeTableGUI
(
$this
->
controller
,
$this
->
plugin
,
(
int
)
$_GET
[
'path_id'
]);
$table
->
setTitle
(
$table
->
setModelList
(
$model
->
getNodes
());
$model
->
getSet
()
->
getTitle
()
.
" - "
.
$table
->
setTitle
(
$model
->
getTitle
()
.
" - "
.
$model
->
getSet
()
->
getTitle
()
.
" - "
.
$this
->
plugin
->
txt
(
'nodes'
)
$model
->
getTitle
()
.
" - "
.
);
$this
->
plugin
->
txt
(
'nodes'
));
$table
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.saveSorting"
,
$this
->
plugin
->
txt
(
"save_sorting"
));
$table
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.saveSorting"
,
$this
->
plugin
->
txt
(
"save_sorting"
));
$table
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.saveDominantScoring"
,
$this
->
plugin
->
txt
(
"save_dominant_scoring"
));
$table
->
addCommandButton
(
"ilQuestionSetPoolNodesGUI.saveDominantScoring"
,
$this
->
plugin
->
txt
(
"save_dominant_scoring"
));
$table
->
populate
();
$table
->
populate
();
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
}
public
function
saveSorting
()
public
function
saveSorting
()
{
{
$this
->
sortdata
();
$this
->
sortdata
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_sorting"
),
true
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_sorting"
),
true
);
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
"set_id"
=>
(
int
)
$_GET
[
"set_id"
],
"set_id"
=>
(
int
)
$_GET
[
"set_id"
],
"path_id"
=>
(
int
)
$_GET
[
"path_id"
]
"path_id"
=>
(
int
)
$_GET
[
"path_id"
]
));
));
}
}
public
function
saveDominantScoring
()
public
function
saveDominantScoring
()
{
{
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
"path_id"
]);
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
"path_id"
]);
$model
->
read
();
$model
->
read
();
$data
=
$model
->
getNodes
()
->
getData
();
$data
=
$model
->
getNodes
()
->
getData
();
foreach
(
$data
as
$element
)
{
foreach
(
$data
as
$element
)
$node
=
new
ilQuestionSetPoolNode
(
$element
[
"id"
]);
{
$node
->
read
();
$node
=
new
ilQuestionSetPoolNode
(
$element
[
"id"
]);
if
(
$_POST
[
"dominant_scoring"
][
$node
->
getId
()]
===
""
)
{
$node
->
read
();
$node
->
setDominantScoring
(
null
);
if
(
$_POST
[
"dominant_scoring"
][
$node
->
getId
()]
===
""
)
}
else
{
{
$node
->
setDominantScoring
((
int
)
$_POST
[
"dominant_scoring"
][
$node
->
getId
()]);
$node
->
setDominantScoring
(
null
);
}
}
$node
->
update
();
else
}
{
$node
->
setDominantScoring
((
int
)
$_POST
[
"dominant_scoring"
][
$node
->
getId
()]);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_dominant_scoring"
),
true
);
}
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
$node
->
update
();
"set_id"
=>
$model
->
getSet
()
->
getId
(),
}
"path_id"
=>
$model
->
getId
()
));
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_dominant_scoring"
),
true
);
}
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
"set_id"
=>
$model
->
getSet
()
->
getId
(),
protected
function
sortdata
()
"path_id"
=>
$model
->
getId
()
{
));
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
}
$model
->
read
();
$data
=
$model
->
getNodes
()
->
getData
();
protected
function
sortdata
()
{
foreach
(
$data
as
$key
=>
$element
)
{
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
'path_id'
]);
if
(
$element
[
"node_index"
]
!=
1
)
{
$model
->
read
();
$minimumTwo
=
(
int
)
$_POST
[
"sorting"
][
$element
[
"id"
]];
$data
=
$model
->
getNodes
()
->
getData
();
$data
[
$key
][
"node_index"
]
=
$minimumTwo
>
1
?
$minimumTwo
:
2
;
}
foreach
(
$data
as
$key
=>
$element
)
}
{
if
(
$element
[
"node_index"
]
!=
1
)
usort
(
$data
,
function
(
$a
,
$b
)
{
{
return
$a
[
"node_index"
]
-
$b
[
"node_index"
];
$minimumTwo
=
(
int
)
$_POST
[
"sorting"
][
$element
[
"id"
]];
});
$data
[
$key
][
"node_index"
]
=
$minimumTwo
>
1
?
$minimumTwo
:
2
;
}
if
(
!
$this
->
conditionsAreValid
(
$data
))
{
}
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"sorting_error_jmp_conditions"
),
true
);
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
usort
(
$data
,
function
(
$a
,
$b
){
"set_id"
=>
(
int
)
$_GET
[
"set_id"
],
return
$a
[
"node_index"
]
-
$b
[
"node_index"
];
"path_id"
=>
(
int
)
$_GET
[
"path_id"
]
});
));
}
if
(
!
$this
->
conditionsAreValid
(
$data
))
{
if
(
is_array
(
$data
))
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"sorting_error_jmp_conditions"
),
true
);
for
(
$i
=
0
;
$i
<
count
(
$data
);
$i
++
)
{
$this
->
redirect
(
"ilQuestionSetPoolNodesGUI.listNodes"
,
array
(
$data
[
$i
][
"node_index"
]
=
(
$i
+
1
);
"set_id"
=>
(
int
)
$_GET
[
"set_id"
],
$model
->
getNodes
()
->
update
(
$data
[
$i
]);
"path_id"
=>
(
int
)
$_GET
[
"path_id"
]
}
));
}
}
return
$data
;
}
if
(
is_array
(
$data
))
{
/**
for
(
$i
=
0
;
$i
<
count
(
$data
);
$i
++
)
* Returns the current tab name
{
* return string
$data
[
$i
][
"node_index"
]
=
(
$i
+
1
);
*/
$model
->
getNodes
()
->
update
(
$data
[
$i
]);
protected
function
getCurrentTab
()
}
{
}
return
"content"
;
return
$data
;
}
}
/**
/**
* @return array
* Returns the current tab name
*/
* return string
protected
function
getRequirements
()
*/
{
protected
function
getCurrentTab
()
return
array
(
{
"models/class.ilQuestionSetPoolPath.php"
,
return
"content"
;
"tables/class.ilQuestionSetPoolNodeTableGUI.php"
,
}
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
);
/**
}
* @return array
*/
private
function
addSubTabs
()
protected
function
getRequirements
()
{
{
global
$DIC
;
return
array
(
$ilTabs
=
$DIC
->
tabs
();
"models/class.ilQuestionSetPoolPath.php"
,
"tables/class.ilQuestionSetPoolNodeTableGUI.php"
,
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
"utils/abstract.ilQuestionSetPoolConditionValidator.php"
);
$ilTabs
->
addSubTab
(
}
"set_questions"
,
$this
->
plugin
->
txt
(
"questions"
),
private
function
addSubTabs
()
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
)
{
);
global
$DIC
;
$ilTabs
=
$DIC
->
tabs
();
$ilTabs
->
addSubTab
(
"paths"
,
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
plugin
->
txt
(
"paths"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
)
$ilTabs
->
addSubTab
(
"set_questions"
,
$this
->
plugin
->
txt
(
"questions"
),
);
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
));
$ilTabs
->
addSubTab
(
$ilTabs
->
addSubTab
(
"paths"
,
$this
->
plugin
->
txt
(
"paths"
),
"path_overview"
,
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
));
$this
->
plugin
->
txt
(
"path_overview"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
)
$ilTabs
->
addSubTab
(
"path_overview"
,
$this
->
plugin
->
txt
(
"path_overview"
),
);
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
));
$ilTabs
->
activateSubTab
(
"paths"
);
$ilTabs
->
activateSubTab
(
"paths"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
}
}
/**
/**
* @param $data
* @param $data
*
*
* @return bool
* @return bool
*/
*/
protected
function
conditionsAreValid
(
$data
)
protected
function
conditionsAreValid
(
$data
)
{
{
if
(
is_array
(
$data
))
{
if
(
is_array
(
$data
))
for
(
$index
=
1
;
$index
<
count
(
$data
);
$index
++
)
{
{
$node
=
new
ilQuestionSetPoolNode
(
$data
[
$index
][
"id"
]);
for
(
$index
=
1
;
$index
<
count
(
$data
);
$index
++
)
$node
->
read
();
{
$node
->
setIndex
(
$data
[
$index
][
"node_index"
]);
$node
=
new
ilQuestionSetPoolNode
(
$data
[
$index
][
"id"
]);
$node
->
read
();
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$node
->
getInitialCondition
(),
$node
,
$data
,
$this
->
plugin
))
{
$node
->
setIndex
(
$data
[
$index
][
"node_index"
]);
return
false
;
}
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$node
->
getInitialCondition
(),
$node
,
$data
,
$this
->
plugin
))
{
foreach
(
$data
[
$index
][
"jump_conditions"
]
as
$jump_condition
)
{
return
false
;
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$jump_condition
[
"jump_condition"
],
$node
,
$data
,
$this
->
plugin
))
{
}
return
false
;
}
foreach
(
$data
[
$index
][
"jump_conditions"
]
as
$jump_condition
)
{
$error
=
false
;
if
(
!
ilQuestionSetPoolConditionValidator
::
isValid
(
$jump_condition
[
"jump_condition"
],
$node
,
$data
,
$this
->
plugin
))
for
(
$inner_index
=
0
;
$inner_index
<=
$index
;
$inner_index
++
)
{
{
if
(
$data
[
$inner_index
][
"question_fi"
]
==
$jump_condition
[
"question_fi"
]
||
$jump_condition
[
"question_fi"
]
==
null
)
{
return
false
;
$error
=
false
;
}
break
;
}
else
{
$error
=
false
;
$error
=
true
;
for
(
$inner_index
=
0
;
$inner_index
<=
$index
;
$inner_index
++
)
}
{
}
if
(
$data
[
$inner_index
][
"question_fi"
]
==
$jump_condition
[
"question_fi"
]
||
$jump_condition
[
"question_fi"
]
==
null
)
if
(
$error
)
{
{
return
false
;
$error
=
false
;
}
break
;
}
}
}
else
}
{
return
true
;
$error
=
true
;
}
}
}
if
(
$error
)
{
return
false
;
}
}
}
}
return
true
;
}
}
}
\ No newline at end of file
classes/controllers/class.ilQuestionSetPoolPathGUI.php
View file @
381d5850
...
@@ -8,223 +8,214 @@ require_once "abstract.ilPluginControllerFormGUI.php";
...
@@ -8,223 +8,214 @@ require_once "abstract.ilPluginControllerFormGUI.php";
* Date: 21.11.13
* Date: 21.11.13
* Time: 10:22
* Time: 10:22
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolPathGUI
extends
ilPluginControllerFormGUI
class
ilQuestionSetPoolPathGUI
extends
ilPluginControllerFormGUI
{
{
protected
$redirectCmd
=
"ilQuestionSetPoolNodesGUI.listNodes"
;
protected
$redirectCmd
=
"ilQuestionSetPoolNodesGUI.listNodes"
;
public
function
edit
()
public
function
edit
()
{
{
$this
->
redirectIfNoQuestionsInSet
();
$this
->
redirectIfNoQuestionsInSet
();
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
bindModelToForm
(
$model
);
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
}
public
function
update
()
public
function
update
()
{
{
$this
->
redirectIfNoQuestionsInSet
();
$this
->
redirectIfNoQuestionsInSet
();
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
if
(
$this
->
form
->
checkInput
())
{
if
(
$this
->
form
->
checkInput
())
$model
->
bindForm
(
$this
->
form
);
{
$model
->
update
();
$model
->
bindForm
(
$this
->
form
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_path_modified"
),
true
);
$model
->
update
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_path_modified"
),
true
);
$this
->
redirect
(
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
redirect
(
$this
->
getAfterUpdateRedirectParams
(
$model
)
$this
->
getAfterUpdateRedirectCmd
(),
);
$this
->
getAfterUpdateRedirectParams
(
$model
)
}
);
}
$this
->
form
->
setValuesByPost
();
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
$this
->
form
->
setValuesByPost
();
}
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
public
function
updateAndNewNode
()
{
public
function
updateAndNewNode
()
$this
->
redirectCmd
=
"ilQuestionSetPoolNodeGUI.edit"
;
{
$this
->
update
();
$this
->
redirectCmd
=
"ilQuestionSetPoolNodeGUI.edit"
;
}
$this
->
update
();
}
/**
* Loads and returns the Model for the controller gui
/**
* @return ilPluginModel
* Loads and returns the Model for the controller gui
*/
* @return ilPluginModel
protected
function
loadModel
()
*/
{
protected
function
loadModel
()
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
"path_id"
]);
{
$model
->
read
();
$model
=
new
ilQuestionSetPoolPath
((
int
)
$_GET
[
"path_id"
]);
$model
->
read
();
return
$model
;
}
return
$model
;
}
/**
* Initialize the PropertyFormGUI for this controller
/**
*
* Initialize the PropertyFormGUI for this controller
* @param ilQuestionSetPoolPath $model
*
*/
* @param ilQuestionSetPoolPath $model
protected
function
initForm
(
$model
)
*/
{
protected
function
initForm
(
$model
)
$this
->
form
=
new
ilPropertyFormGUI
();
{
$this
->
form
->
setTitle
(
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
sprintf
(
$this
->
form
=
new
ilPropertyFormGUI
();
$this
->
plugin
->
txt
(
"path_title"
),
$this
->
form
->
setTitle
(
$model
->
getSet
()
->
getTitle
()
sprintf
(
)
$this
->
plugin
->
txt
(
"path_title"
),
);
$model
->
getSet
()
->
getTitle
()
)
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"title"
),
"title"
);
);
$title
->
setRequired
(
true
);
$this
->
form
->
addItem
(
$title
);
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"title"
),
"title"
);
$title
->
setRequired
(
true
);
if
(
$model
->
getId
()
<=
0
)
{
$this
->
form
->
addItem
(
$title
);
$start_question
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
'start_question'
),
"start_question"
);
$start_question
->
setRequired
(
true
);
if
(
$model
->
getId
()
<=
0
)
$start_question
->
setOptions
(
$this
->
getStartQuestionOptions
(
$model
));
{
$this
->
form
->
addItem
(
$start_question
);
$start_question
=
new
ilSelectInputGUI
(
$this
->
plugin
->
txt
(
'start_question'
),
"start_question"
);
}
$start_question
->
setRequired
(
true
);
$start_question
->
setOptions
(
$this
->
getStartQuestionOptions
(
$model
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
(
int
)
$model
->
getId
());
$this
->
form
->
addItem
(
$start_question
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
}
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
(
int
)
$model
->
getId
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathGUI.updateAndNewNode"
,
$this
->
plugin
->
txt
(
"save_and_node"
));
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
$this
->
plugin
->
txt
(
"cancel"
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"path_id"
,
""
);
}
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathGUI.updateAndNewNode"
,
$this
->
plugin
->
txt
(
"save_and_node"
));
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
/**
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
$this
->
plugin
->
txt
(
"cancel"
));
* @param ilQuestionSetPoolPath $model
}
*
* @return array
/**
*/
* @param ilQuestionSetPoolPath $model
protected
function
getStartQuestionOptions
(
$model
)
*
{
* @return array
$options
=
array
();
*/
$questions
=
$this
->
getExistingStartQuestion
(
$model
);
protected
function
getStartQuestionOptions
(
$model
)
{
if
(
$questions
==
null
)
{
$options
=
array
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
$questions
=
$this
->
getExistingStartQuestion
(
$model
);
$set
->
read
();
$questions
=
$set
->
getQuestionList
()
->
getData
();
if
(
$questions
==
null
)
}
else
{
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"start_question_defined"
),
false
);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
}
$set
->
read
();
$questions
=
$set
->
getQuestionList
()
->
getData
();
foreach
(
$questions
as
$question
)
{
}
else
{
$options
[
$question
[
'question_id'
]]
=
$question
[
'title'
];
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"start_question_defined"
),
false
);
}
}
return
$options
;
foreach
(
$questions
as
$question
)
}
{
$options
[
$question
[
'question_id'
]]
=
$question
[
'title'
];
/**
}
* @param ilQuestionSetPoolPath $model
*
return
$options
;
* @return array|null
}
*/
public
function
getExistingStartQuestion
(
$model
)
/**
{
* @param ilQuestionSetPoolPath $model
global
$DIC
;
*
$ilDB
=
$DIC
->
database
();
* @return array|null
*/
$ilDB
->
setLimit
(
1
,
0
);
public
function
getExistingStartQuestion
(
$model
)
$result
=
$ilDB
->
queryF
(
{
"SELECT q.question_id, q.title
global
$DIC
;
$ilDB
=
$DIC
->
database
();
$ilDB
->
setLimit
(
1
,
0
);
$result
=
$ilDB
->
queryF
(
"SELECT q.question_id, q.title
FROM qpl_questions q
FROM qpl_questions q
INNER JOIN rep_robj_xqsp_node n ON n.question_fi = q.question_id
INNER JOIN rep_robj_xqsp_node n ON n.question_fi = q.question_id
INNER JOIN rep_robj_xqsp_qs_qst qst ON qst.question_fi = q.question_id
INNER JOIN rep_robj_xqsp_qs_qst qst ON qst.question_fi = q.question_id
WHERE n.node_index = %s AND qst.questionset_fi = %s"
,
WHERE n.node_index = %s AND qst.questionset_fi = %s"
,
array
(
"integer"
,
"integer"
),
array
(
"integer"
,
"integer"
),
array
(
1
,
$model
->
getSet
()
->
getId
())
array
(
1
,
$model
->
getSet
()
->
getId
())
);
);
$data
=
$ilDB
->
fetchAssoc
(
$result
);
$data
=
$ilDB
->
fetchAssoc
(
$result
);
if
(
$data
!=
null
)
if
(
$data
!=
null
)
{
{
$data
=
array
(
$data
);
$data
=
array
(
$data
);
}
}
return
$data
;
return
$data
;
}
}
/**
/**
* @param ilQuestionSetPoolSet $set
* @param ilQuestionSetPoolSet $set
* @return bool
* @return bool
*/
*/
protected
function
doesSetHaveQuestions
(
$set
)
protected
function
doesSetHaveQuestions
(
$set
)
{
{
return
is_array
(
$set
->
getQuestionList
()
->
getData
())
?
count
(
$set
->
getQuestionList
()
->
getData
())
>
0
:
0
;
return
is_array
(
$set
->
getQuestionList
()
->
getData
())
?
count
(
$set
->
getQuestionList
()
->
getData
())
>
0
:
0
;
}
}
/**
/**
* Returns the current tab name
* Returns the current tab name
* return string
* return string
*/
*/
protected
function
getCurrentTab
()
protected
function
getCurrentTab
()
{
{
return
"content"
;
return
"content"
;
}
}
/**
/**
* @return array
* @return array
*/
*/
protected
function
getRequirements
()
protected
function
getRequirements
()
{
{
return
array
(
return
array
(
'models/class.ilQuestionSetPoolPath.php'
,
'models/class.ilQuestionSetPoolPath.php'
,
"models/class.ilQuestionSetPoolSet.php"
"models/class.ilQuestionSetPoolSet.php"
);
);
}
}
/**
/**
* Get the redirect action after an update was successful
* Get the redirect action after an update was successful
* @return string
* @return string
*/
*/
protected
function
getAfterUpdateRedirectCmd
()
protected
function
getAfterUpdateRedirectCmd
()
{
{
return
$this
->
redirectCmd
;
return
$this
->
redirectCmd
;
}
}
/**
/**
* @param ilQuestionSetPoolPath $model
* @param ilQuestionSetPoolPath $model
*
*
* @return array
* @return array
*/
*/
protected
function
getAfterUpdateRedirectParams
(
$model
=
null
)
protected
function
getAfterUpdateRedirectParams
(
$model
=
NULL
)
{
{
return
array
(
return
array
(
"set_id"
=>
(
int
)
$_GET
[
'set_id'
],
"set_id"
=>
(
int
)
$_GET
[
'set_id'
],
"path_id"
=>
(
$model
==
null
?
null
:
(
int
)
$model
->
getId
())
"path_id"
=>
(
$model
==
NULL
?
NULL
:
(
int
)
$model
->
getId
())
);
);
}
}
protected
function
redirectIfNoQuestionsInSet
()
protected
function
redirectIfNoQuestionsInSet
()
{
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
$set
->
read
();
$set
->
read
();
if
(
!
$this
->
doesSetHaveQuestions
(
$set
))
{
if
(
!
$this
->
doesSetHaveQuestions
(
$set
))
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"no_questions_in_set"
),
true
);
{
$this
->
redirect
(
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"no_questions_in_set"
),
true
);
$this
->
getAfterUpdateRedirectCmd
(),
$this
->
redirect
(
$this
->
getAfterUpdateRedirectParams
(
null
)
$this
->
getAfterUpdateRedirectCmd
(),
);
$this
->
getAfterUpdateRedirectParams
(
null
)
}
);
}
}
}
}
}
\ No newline at end of file
classes/controllers/class.ilQuestionSetPoolPathGraphGUI.php
View file @
381d5850
...
@@ -4,243 +4,234 @@ require_once dirname(__FILE__) . '/../../vendor/autoload.php';
...
@@ -4,243 +4,234 @@ require_once dirname(__FILE__) . '/../../vendor/autoload.php';
/**
/**
* Class ilQuestionSetPoolPathGraphGUI
* Class ilQuestionSetPoolPathGraphGUI
*/
*/
class
ilQuestionSetPoolPathGraphGUI
extends
ilPluginControllerGUI
class
ilQuestionSetPoolPathGraphGUI
extends
ilPluginControllerGUI
{
{
/**
/**
* @param ilObjQuestionSetPoolGUI $controller
* @param ilObjQuestionSetPoolGUI $controller
*/
*/
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
{
{
parent
::
__construct
(
$controller
);
parent
::
__construct
(
$controller
);
$this
->
addSubTabs
();
$this
->
addSubTabs
();
}
}
/**
/**
*
*
*/
*/
public
function
showPathOverview
()
public
function
showPathOverview
()
{
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
->
read
();
$set
->
read
();
$template
=
new
ilTemplate
(
'tpl.il_xqsp_path_overview.html'
,
true
,
true
,
'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
);
$template
=
new
ilTemplate
(
'tpl.il_xqsp_path_overview.html'
,
true
,
true
,
'Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool'
);
$this
->
renderPathTable
(
$set
,
$template
);
$this
->
renderPathTable
(
$set
,
$template
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
$template
->
setVariable
(
'SET_TITLE'
,
$set
->
getTitle
());
$template
->
setVariable
(
'SET_TITLE'
,
$set
->
getTitle
());
$template
->
setVariable
(
'GRAPH_TITLE'
,
$this
->
plugin
->
txt
(
"graph_viz_title"
));
$template
->
setVariable
(
'GRAPH_TITLE'
,
$this
->
plugin
->
txt
(
"graph_viz_title"
));
$template
->
setVariable
(
'PATH_GRAPH_SRC'
,
$this
->
renderPathGraph
());
$components
=
[];
$this
->
tpl
->
setContent
(
$template
->
get
());
try
{
}
$template
->
setVariable
(
'PATH_GRAPH_SRC'
,
$this
->
renderPathGraph
());
$components
[]
=
$this
->
uiFactory
->
legacy
(
$template
->
get
());
/**
}
catch
(
Exception
$e
)
{
*
$components
[]
=
$this
->
uiFactory
->
legacy
(
$template
->
get
());
*/
$components
[]
=
$this
->
uiFactory
->
messageBox
()
->
failure
(
'Could not display graph: '
.
$e
->
getMessage
());
public
function
renderPathGraph
()
}
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$this
->
tpl
->
setContent
(
$this
->
uiRenderer
->
render
(
$components
));
$set
->
read
();
}
$graph
=
new
Fhaculty\Graph\Graph
();
/**
*
$pathes
=
$set
->
getPathList
()
->
getData
();
*/
foreach
(
$pathes
as
$path
)
public
function
renderPathGraph
()
{
{
$model
=
new
ilQuestionSetPoolPath
(
$path
[
'id'
]);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$model
->
read
();
$set
->
read
();
$nodes
=
$model
->
getNodes
()
->
getData
();
$graph
=
new
Fhaculty\Graph\Graph
();
$num_nodes
=
is_array
(
$nodes
)
?
count
(
$nodes
)
:
0
;
for
(
$i
=
0
;
$i
<
$num_nodes
;
$i
++
)
$pathes
=
$set
->
getPathList
()
->
getData
();
{
foreach
(
$pathes
as
$path
)
{
$nodeId
=
'Q'
.
$nodes
[
$i
][
'question_index'
];
$model
=
new
ilQuestionSetPoolPath
(
$path
[
'id'
]);
try
{
$model
->
read
();
$graph
->
getVertex
(
$nodeId
);
$nodes
=
$model
->
getNodes
()
->
getData
();
}
catch
(
Exception
$exception
)
{
$vertex
=
$graph
->
createVertex
(
$nodeId
);
$num_nodes
=
is_array
(
$nodes
)
?
count
(
$nodes
)
:
0
;
$vertex
->
setAttribute
(
'graphviz.shape'
,
'box'
);
for
(
$i
=
0
;
$i
<
$num_nodes
;
$i
++
)
{
}
$nodeId
=
'Q'
.
$nodes
[
$i
][
'question_index'
];
}
try
{
}
$graph
->
getVertex
(
$nodeId
);
$vertex
=
$graph
->
createVertex
(
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
));
}
catch
(
Exception
$exception
)
{
$vertex
->
setAttribute
(
'graphviz.shape'
,
'box'
);
$vertex
=
$graph
->
createVertex
(
$nodeId
);
$vertex
->
setAttribute
(
'graphviz.shape'
,
'box'
);
$edges
=
array
();
}
}
foreach
(
$pathes
as
$path
)
}
{
$vertex
=
$graph
->
createVertex
(
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
));
$model
=
new
ilQuestionSetPoolPath
(
$path
[
'id'
]);
$vertex
->
setAttribute
(
'graphviz.shape'
,
'box'
);
$model
->
read
();
$nodes
=
$model
->
getNodes
()
->
getData
();
$edges
=
array
();
$num_nodes
=
is_array
(
$nodes
)
?
count
(
$nodes
)
:
0
;
for
(
$i
=
0
;
$i
<
$num_nodes
;
$i
++
)
foreach
(
$pathes
as
$path
)
{
{
$model
=
new
ilQuestionSetPoolPath
(
$path
[
'id'
]);
if
(
isset
(
$nodes
[
$i
+
1
]))
$model
->
read
();
{
$nodes
=
$model
->
getNodes
()
->
getData
();
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
"Q"
.
$nodes
[
$i
+
1
][
'question_index'
]][
'initial'
][
trim
(
$nodes
[
$i
][
'initial_condition'
])]
=
$nodes
[
$i
][
'initial_condition'
];
$num_nodes
=
is_array
(
$nodes
)
?
count
(
$nodes
)
:
0
;
}
for
(
$i
=
0
;
$i
<
$num_nodes
;
$i
++
)
{
else
if
(
isset
(
$nodes
[
$i
+
1
]))
{
{
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
"Q"
.
$nodes
[
$i
+
1
][
'question_index'
]][
'initial'
][
trim
(
$nodes
[
$i
][
'initial_condition'
])]
=
$nodes
[
$i
][
'initial_condition'
];
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
)][
'initial'
][
trim
(
$nodes
[
$i
][
'initial_condition'
])]
=
$nodes
[
$i
][
'initial_condition'
];
}
else
{
}
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
)][
'initial'
][
trim
(
$nodes
[
$i
][
'initial_condition'
])]
=
$nodes
[
$i
][
'initial_condition'
];
}
foreach
((
array
)
$nodes
[
$i
][
'jump_conditions'
]
as
$condition
)
{
foreach
((
array
)
$nodes
[
$i
][
'jump_conditions'
]
as
$condition
)
{
if
(
$condition
[
'question_index'
])
if
(
$condition
[
'question_index'
])
{
{
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
"Q"
.
$condition
[
'question_index'
]][
'jump'
][
trim
(
$condition
[
'jump_condition'
])]
=
$condition
[
'jump_condition'
];
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
"Q"
.
$condition
[
'question_index'
]][
'jump'
][
trim
(
$condition
[
'jump_condition'
])]
=
$condition
[
'jump_condition'
];
}
else
{
}
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
)][
'end'
][
trim
(
$condition
[
'jump_condition'
])]
=
$condition
[
'jump_condition'
];
else
}
{
}
$edges
[
"Q"
.
$nodes
[
$i
][
'question_index'
]][
$this
->
controller
->
plugin
->
txt
(
'end_of_set'
)][
'end'
][
trim
(
$condition
[
'jump_condition'
])]
=
$condition
[
'jump_condition'
];
}
}
}
}
}
foreach
(
$edges
as
$node_source
=>
$data_target
)
{
}
foreach
(
$data_target
as
$node_target
=>
$data_conditions
)
{
if
(
is_array
(
$data_conditions
[
'initial'
])
&&
count
(
$data_conditions
[
'initial'
])
>
0
)
{
foreach
(
$edges
as
$node_source
=>
$data_target
)
$initial
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'initial'
]));
{
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
foreach
(
$data_target
as
$node_target
=>
$data_conditions
)
$edge
->
setAttribute
(
'graphviz.color'
,
'darkgreen'
);
{
$edge
->
setAttribute
(
'graphviz.label'
,
$initial
);
if
(
is_array
(
$data_conditions
[
'initial'
])
&&
count
(
$data_conditions
[
'initial'
])
>
0
)
}
{
if
(
is_array
(
$data_conditions
[
'jump'
])
&&
count
(
$data_conditions
[
'jump'
])
>
0
)
{
$initial
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'initial'
]));
$jump
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'jump'
]));
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
$edge
->
setAttribute
(
'graphviz.color'
,
'darkgreen'
);
$edge
->
setAttribute
(
'graphviz.color'
,
'blue'
);
$edge
->
setAttribute
(
'graphviz.label'
,
$initial
);
$edge
->
setAttribute
(
'graphviz.label'
,
$jump
);
}
}
if
(
is_array
(
$data_conditions
[
'jump'
])
&&
count
(
$data_conditions
[
'jump'
])
>
0
)
if
(
is_array
(
$data_conditions
[
'end'
])
&&
count
(
$data_conditions
[
'end'
])
>
0
)
{
{
$end
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'end'
]));
$jump
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'jump'
]));
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
$edge
->
setAttribute
(
'graphviz.color'
,
'red'
);
$edge
->
setAttribute
(
'graphviz.color'
,
'blue'
);
$edge
->
setAttribute
(
'graphviz.label'
,
$end
);
$edge
->
setAttribute
(
'graphviz.label'
,
$jump
);
}
}
}
if
(
is_array
(
$data_conditions
[
'end'
])
&&
count
(
$data_conditions
[
'end'
])
>
0
)
}
{
$end
=
join
(
"
\n
"
,
array_filter
(
$data_conditions
[
'end'
]));
$graphviz
=
new
Graphp\GraphViz\GraphViz
();
$edge
=
new
Fhaculty\Graph\Edge\Directed
(
$graph
->
getVertex
(
$node_source
),
$graph
->
getVertex
(
$node_target
));
$imageSrc
=
$graphviz
->
createImageSrc
(
$graph
);
$edge
->
setAttribute
(
'graphviz.color'
,
'red'
);
return
$imageSrc
;
$edge
->
setAttribute
(
'graphviz.label'
,
$end
);
}
}
}
/**
}
* Returns the current tab name
* return string
$graphviz
=
new
Graphp\GraphViz\GraphViz
();
*/
$imageSrc
=
$graphviz
->
createImageSrc
(
$graph
);
protected
function
getCurrentTab
()
return
$imageSrc
;
{
}
return
'content'
;
}
/**
* Returns the current tab name
/**
* return string
* @return array
*/
*/
protected
function
getCurrentTab
()
protected
function
getRequirements
()
{
{
return
'content'
;
return
array
(
}
'models/class.ilQuestionSetPoolSet.php'
,
'models/class.ilQuestionSetPoolPath.php'
/**
);
* @return array
}
*/
protected
function
getRequirements
()
private
function
addSubTabs
()
{
{
return
array
(
global
$DIC
;
'models/class.ilQuestionSetPoolSet.php'
,
$ilTabs
=
$DIC
->
tabs
();
'models/class.ilQuestionSetPoolPath.php'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
}
$ilTabs
->
addSubTab
(
private
function
addSubTabs
()
"set_questions"
,
{
$this
->
plugin
->
txt
(
"questions"
),
global
$DIC
;
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
)
$ilTabs
=
$DIC
->
tabs
();
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$ilTabs
->
addSubTab
(
"paths"
,
$ilTabs
->
addSubTab
(
"set_questions"
,
$this
->
plugin
->
txt
(
"questions"
),
$this
->
plugin
->
txt
(
"paths"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
));
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
)
);
$ilTabs
->
addSubTab
(
"paths"
,
$this
->
plugin
->
txt
(
"paths"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
));
$ilTabs
->
addSubTab
(
"path_overview"
,
$ilTabs
->
addSubTab
(
"path_overview"
,
$this
->
plugin
->
txt
(
"path_overview"
),
$this
->
plugin
->
txt
(
"path_overview"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
));
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
)
);
$ilTabs
->
activateSubTab
(
"path_overview"
);
$ilTabs
->
activateSubTab
(
"path_overview"
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
}
/**
* @param $set
/**
* @param $template
* @param $set
*/
* @param $template
protected
function
renderPathTable
(
$set
,
$template
)
*/
{
protected
function
renderPathTable
(
$set
,
$template
)
$pathes
=
$set
->
getPathList
()
->
getData
();
{
foreach
(
$pathes
as
$path_data
)
$pathes
=
$set
->
getPathList
()
->
getData
();
{
foreach
(
$pathes
as
$path_data
)
{
$path
=
new
ilQuestionSetPoolPath
(
$path_data
[
'id'
]);
$path
=
new
ilQuestionSetPoolPath
(
$path_data
[
'id'
]);
$path
->
read
();
$path
->
read
();
$nodes
=
$path
->
getNodes
()
->
getData
();
$nodes
=
$path
->
getNodes
()
->
getData
();
foreach
(
$nodes
as
$node
)
foreach
(
$nodes
as
$node
)
{
{
$template
->
setCurrentBlock
(
"initial_condition"
);
$template
->
setCurrentBlock
(
"initial_condition"
);
$condition
=
$node
[
"initial_condition"
];
$condition
=
$node
[
"initial_condition"
];
if
(
$condition
==
""
)
{
if
(
$condition
==
""
)
$condition
=
$this
->
plugin
->
txt
(
"empty_condition"
);
{
}
$condition
=
$this
->
plugin
->
txt
(
"empty_condition"
);
$template
->
setVariable
(
"INITIAL_CONDITION"
,
$condition
);
}
$template
->
parseCurrentBlock
();
$template
->
setVariable
(
"INITIAL_CONDITION"
,
$condition
);
$template
->
parseCurrentBlock
();
$template
->
setCurrentBlock
(
"question"
);
$template
->
setVariable
(
"QUESTION_INDEX"
,
$node
[
"question_index"
]);
$template
->
setCurrentBlock
(
"question"
);
$template
->
parseCurrentBlock
();
$template
->
setVariable
(
"QUESTION_INDEX"
,
$node
[
"question_index"
]);
$template
->
parseCurrentBlock
();
if
(
is_array
(
$node
[
"jump_conditions"
])
&&
count
(
$node
[
"jump_conditions"
])
>
0
)
{
foreach
(
$node
[
"jump_conditions"
]
as
$jump_condition
)
{
if
(
is_array
(
$node
[
"jump_conditions"
])
&&
count
(
$node
[
"jump_conditions"
])
>
0
)
$condition
=
""
;
{
foreach
(
$node
[
"jump_conditions"
]
as
$jump_condition
)
if
(
$jump_condition
[
"question_index"
]
!=
null
)
{
{
$condition
.
=
$this
->
plugin
->
txt
(
"target_question"
)
.
": "
;
$condition
=
""
;
$condition
.
=
"Q"
.
$jump_condition
[
"question_index"
];
}
else
{
if
(
$jump_condition
[
"question_index"
]
!=
null
)
$condition
.
=
$this
->
plugin
->
txt
(
"tst_termination"
);
{
}
$condition
.
=
$this
->
plugin
->
txt
(
"target_question"
)
.
": "
;
$template
->
setCurrentBlock
(
"jump_condition"
);
$condition
.
=
"Q"
.
$jump_condition
[
"question_index"
];
$template
->
setVariable
(
"JUMP_CONDITION"
,
$jump_condition
[
"jump_condition"
]);
}
$template
->
setVariable
(
"TARGET"
,
$condition
.
"<br />"
.
$this
->
plugin
->
txt
(
"repititions"
)
.
": "
.
$jump_condition
[
"repititions"
]);
else
$template
->
parseCurrentBlock
();
{
}
$condition
.
=
$this
->
plugin
->
txt
(
"tst_termination"
);
}
else
{
}
$template
->
setCurrentBlock
(
"jump_condition"
);
$template
->
setCurrentBlock
(
"jump_condition"
);
$template
->
setVariable
(
"JUMP_CONDITION"
,
" "
);
$template
->
setVariable
(
"JUMP_CONDITION"
,
$jump_condition
[
"jump_condition"
]);
$template
->
setVariable
(
"TARGET"
,
" "
);
$template
->
setVariable
(
"TARGET"
,
$condition
.
"<br />"
.
$this
->
plugin
->
txt
(
"repititions"
)
.
": "
.
$jump_condition
[
"repititions"
]);
$template
->
parseCurrentBlock
();
$template
->
parseCurrentBlock
();
}
}
$template
->
setCurrentBlock
(
"jump_conditions"
);
}
$template
->
parseCurrentBlock
();
else
}
{
$template
->
setCurrentBlock
(
"jump_condition"
);
$template
->
setCurrentBlock
(
"test_end"
);
$template
->
setVariable
(
"JUMP_CONDITION"
,
" "
);
$template
->
setVariable
(
"END_TEST"
,
$this
->
plugin
->
txt
(
'end_of_test'
));
$template
->
setVariable
(
"TARGET"
,
" "
);
$template
->
parseCurrentBlock
();
$template
->
parseCurrentBlock
();
}
$template
->
setCurrentBlock
(
"path"
);
$template
->
setCurrentBlock
(
"jump_conditions"
);
$template
->
setVariable
(
"PATH_TITLE"
,
$path
->
getTitle
());
$template
->
parseCurrentBlock
();
$template
->
parseCurrentBlock
();
}
}
}
$template
->
setCurrentBlock
(
"test_end"
);
$template
->
setVariable
(
"END_TEST"
,
$this
->
plugin
->
txt
(
'end_of_test'
));
$template
->
parseCurrentBlock
();
$template
->
setCurrentBlock
(
"path"
);
$template
->
setVariable
(
"PATH_TITLE"
,
$path
->
getTitle
());
$template
->
parseCurrentBlock
();
}
}
}
}
classes/controllers/class.ilQuestionSetPoolPathsGUI.php
View file @
381d5850
...
@@ -8,309 +8,281 @@ require_once "abstract.ilPluginControllerTableGUI.php";
...
@@ -8,309 +8,281 @@ require_once "abstract.ilPluginControllerTableGUI.php";
* Date: 08.10.13
* Date: 08.10.13
* Time: 11:11
* Time: 11:11
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolPathsGUI
extends
ilPluginControllerTableGUI
class
ilQuestionSetPoolPathsGUI
extends
ilPluginControllerTableGUI
{
{
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
{
{
parent
::
__construct
(
$controller
);
parent
::
__construct
(
$controller
);
$this
->
addSubTabs
();
$this
->
addSubTabs
();
}
}
public
function
listPaths
()
public
function
listPaths
()
{
{
if
(
$this
->
controller
->
object
instanceof
ilObjQuestionSetPool
)
{
if
(
$this
->
controller
->
object
instanceof
ilObjQuestionSetPool
)
$this
->
addToolbarButton
(
"back_to_set_list"
,
"ilQuestionSetPoolSetsGUI.show"
);
{
}
$this
->
addToolbarButton
(
"back_to_set_list"
,
"ilQuestionSetPoolSetsGUI.show"
);
}
$this
->
addToolbarButton
(
"add_path"
,
"ilQuestionSetPoolPathGUI.edit"
,
array
(
"set_id"
=>
(
int
)
$_GET
[
'set_id'
]
$this
->
addToolbarButton
(
"add_path"
,
"ilQuestionSetPoolPathGUI.edit"
,
array
(
));
"set_id"
=>
(
int
)
$_GET
[
'set_id'
]
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
$table
=
new
ilQuestionSetPoolPathTableGUI
(
$this
->
controller
,
$this
->
plugin
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
$table
=
new
ilQuestionSetPoolPathTableGUI
(
$this
->
controller
,
$this
->
plugin
,
(
int
)
$_GET
[
'set_id'
]);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
->
read
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
->
read
();
$table
->
setModelList
(
$set
->
getPathList
());
$table
->
setTitle
(
$set
->
getTitle
()
.
" - "
.
$this
->
plugin
->
txt
(
'paths'
));
$table
->
setModelList
(
$set
->
getPathList
());
$table
->
addCommandButton
(
"ilQuestionSetPoolPathsGUI.saveSorting"
,
$this
->
plugin
->
txt
(
"save_sorting"
));
$table
->
setTitle
(
$set
->
getTitle
()
.
" - "
.
$this
->
plugin
->
txt
(
'paths'
));
$table
->
populate
();
$table
->
addCommandButton
(
"ilQuestionSetPoolPathsGUI.saveSorting"
,
$this
->
plugin
->
txt
(
"save_sorting"
));
$table
->
populate
();
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
public
function
saveSorting
()
{
public
function
saveSorting
()
$this
->
doSorting
();
{
$this
->
doSorting
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_sorting"
),
true
);
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"saved_sorting"
),
true
);
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
));
"set_id"
=>
(
int
)
$_GET
[
"set_id"
]
}
));
}
public
function
copy
()
{
public
function
copy
()
if
(
$this
->
dataSelected
(
"path_id"
))
{
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
if
(
$this
->
dataSelected
(
"path_id"
))
$set
->
read
();
{
$path_titles
=
$set
->
getPathTitles
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
foreach
(
$_POST
[
"path_id"
]
as
$path_id
)
{
$set
->
read
();
$path
=
new
ilQuestionSetPoolPath
(
$path_id
);
$path_titles
=
$set
->
getPathTitles
();
$path
->
read
();
foreach
(
$_POST
[
"path_id"
]
as
$path_id
)
{
$data
=
$path
->
getSet
()
->
getQuestionList
()
->
getData
();
$path
=
new
ilQuestionSetPoolPath
(
$path_id
);
$question_ids
=
array
();
$path
->
read
();
foreach
(
$data
as
$element
)
{
$question_ids
[
$element
[
"question_id"
]]
=
$element
[
"question_id"
];
$data
=
$path
->
getSet
()
->
getQuestionList
()
->
getData
();
}
$question_ids
=
array
();
foreach
(
$data
as
$element
)
$title
=
$path
->
getTitle
();
{
$i
=
2
;
$question_ids
[
$element
[
"question_id"
]]
=
$element
[
"question_id"
];
while
(
in_array
(
$title
.
' ('
.
$i
.
')'
,
$path_titles
))
{
}
$i
++
;
}
$title
=
$path
->
getTitle
();
$i
=
2
;
$title
.
=
' ('
.
$i
.
')'
;
while
(
in_array
(
$title
.
' ('
.
$i
.
')'
,
$path_titles
))
{
$path_titles
[]
=
$title
;
$i
++
;
}
$path
->
duplicate
(
$question_ids
,
$title
);
}
$title
.
=
' ('
.
$i
.
')'
;
//$this->doSorting();
$path_titles
[]
=
$title
;
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'success_path_copy'
));
$path
->
duplicate
(
$question_ids
,
$title
);
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
}
"set_id"
=>
$_GET
[
"set_id"
]
));
//$this->doSorting();
}
else
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'success_path_copy'
));
$this
->
listPaths
();
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
return
;
"set_id"
=>
$_GET
[
"set_id"
]
};
));
}
}
else
/**
{
* Called if a single path should be deleted, calls \ilQuestionSetPoolPathsGUI::removeMultipleConfirmation do show the confirmation screen
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
*/
$this
->
listPaths
();
public
function
removeConfirmation
()
return
;
{
};
if
(
!
isset
(
$_GET
[
'path_id'
]))
{
}
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
$this
->
listPaths
();
/**
return
;
* Called if a single path should be deleted, calls \ilQuestionSetPoolPathsGUI::removeMultipleConfirmation do show the confirmation screen
}
*/
public
function
removeConfirmation
()
$_POST
[
'path_id'
]
=
array
((
int
)
$_GET
[
'path_id'
]);
{
$this
->
removeMultipleConfirmation
();
if
(
!
isset
(
$_GET
[
'path_id'
]))
}
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
/**
$this
->
listPaths
();
* Shows an confirmation screen for the selected paths
return
;
*/
}
public
function
removeMultipleConfirmation
()
{
$_POST
[
'path_id'
]
=
array
((
int
)
$_GET
[
'path_id'
]);
if
(
!
isset
(
$_POST
[
'path_id'
])
||
!
is_array
(
$_POST
[
'path_id'
]))
{
$this
->
removeMultipleConfirmation
();
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
}
$this
->
listPaths
();
return
;
/**
}
* Shows an confirmation screen for the selected paths
*/
$this
->
tabs
->
activateSubTab
(
'paths'
);
public
function
removeMultipleConfirmation
()
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
if
(
!
isset
(
$_POST
[
'path_id'
])
||
!
is_array
(
$_POST
[
'path_id'
]))
$set
->
read
();
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
$confirmation
=
new
ilConfirmationGUI
();
$this
->
listPaths
();
return
;
$num_items
=
0
;
}
$missing_perm_path_titles
=
array
();
foreach
(
$_POST
[
'path_id'
]
as
$path_id
)
{
$this
->
tabs
->
activateSubTab
(
'paths'
);
$path
=
new
ilQuestionSetPoolPath
((
int
)
$path_id
);
$path
->
read
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
if
(
$path
->
getSet
()
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
{
$set
->
read
();
$confirmation
->
addItem
(
'path_id[]'
,
$path
->
getId
(),
$path
->
getTitle
());
++
$num_items
;
require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php'
;
}
else
{
$confirmation
=
new
ilConfirmationGUI
();
$missing_perm_path_titles
[]
=
$path
->
getTitle
();
}
$num_items
=
0
;
}
$missing_perm_path_titles
=
array
();
foreach
(
$_POST
[
'path_id'
]
as
$path_id
)
if
(
1
==
$num_items
)
{
{
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_paths_s'
));
$path
=
new
ilQuestionSetPoolPath
((
int
)
$path_id
);
}
elseif
(
$num_items
>
1
)
{
$path
->
read
();
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_paths_p'
));
if
(
$path
->
getSet
()
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
}
{
$confirmation
->
addItem
(
'path_id[]'
,
$path
->
getId
(),
$path
->
getTitle
());
$missing_perm_path_titles
=
array_filter
(
$missing_perm_path_titles
);
++
$num_items
;
if
(
is_array
(
$missing_perm_path_titles
))
{
}
if
(
1
==
count
(
$missing_perm_path_titles
))
{
else
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_path_titles
)));
{
}
elseif
(
count
(
$missing_perm_path_titles
)
>
1
)
{
$missing_perm_path_titles
[]
=
$path
->
getTitle
();
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_path_titles
)));
}
}
}
}
if
(
!
$num_items
)
{
if
(
1
==
$num_items
)
$this
->
listPaths
();
{
return
;
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_paths_s'
));
}
}
else
if
(
$num_items
>
1
)
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
$set
->
getId
());
{
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.listPaths'
));
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_paths_p'
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
''
);
}
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
'cancel'
),
__CLASS__
.
'.listPaths'
);
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
'confirm'
),
__CLASS__
.
'.remove'
);
$missing_perm_path_titles
=
array_filter
(
$missing_perm_path_titles
);
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
if
(
is_array
(
$missing_perm_path_titles
))
}
{
if
(
1
==
count
(
$missing_perm_path_titles
))
/**
{
* Finally deletes (cascading) the selected paths
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_path_titles
)));
*/
}
public
function
remove
()
else
if
(
count
(
$missing_perm_path_titles
)
>
1
)
{
{
if
(
!
isset
(
$_POST
[
'path_id'
])
||
!
is_array
(
$_POST
[
'path_id'
]))
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_path_titles
)));
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
}
$this
->
listPaths
();
}
return
;
if
(
!
$num_items
)
}
{
$this
->
listPaths
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
return
;
$set
->
read
();
}
$num_items
=
0
;
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
$set
->
getId
());
$missing_perm_path_titles
=
array
();
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.listPaths'
));
foreach
(
$_POST
[
'path_id'
]
as
$path_id
)
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
''
);
$path
=
new
ilQuestionSetPoolPath
((
int
)
$path_id
);
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
'cancel'
),
__CLASS__
.
'.listPaths'
);
$path
->
read
();
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
'confirm'
),
__CLASS__
.
'.remove'
);
if
(
$path
->
getSet
()
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
{
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
++
$num_items
;
}
$path
->
remove
();
}
else
{
/**
$missing_perm_path_titles
[]
=
$path
->
getTitle
();
* Finally deletes (cascading) the selected paths
}
*/
}
public
function
remove
()
{
if
(
1
==
$num_items
)
{
if
(
!
isset
(
$_POST
[
'path_id'
])
||
!
is_array
(
$_POST
[
'path_id'
]))
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_paths_s'
),
true
);
{
}
elseif
(
$num_items
>
1
)
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_path_selected'
));
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_paths_p'
),
true
);
$this
->
listPaths
();
}
return
;
}
$missing_perm_path_titles
=
array_filter
(
$missing_perm_path_titles
);
if
(
is_array
(
$missing_perm_path_titles
))
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
if
(
1
==
count
(
$missing_perm_path_titles
))
{
$set
->
read
();
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_path_titles
)));
}
elseif
(
count
(
$missing_perm_path_titles
)
>
1
)
{
$num_items
=
0
;
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_path_titles
)));
$missing_perm_path_titles
=
array
();
}
foreach
(
$_POST
[
'path_id'
]
as
$path_id
)
}
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
$set
->
getId
());
$path
=
new
ilQuestionSetPoolPath
((
int
)
$path_id
);
$this
->
redirect
(
__CLASS__
.
'.listPaths'
);
$path
->
read
();
}
if
(
$path
->
getSet
()
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
{
/**
++
$num_items
;
* Returns the current tab name
$path
->
remove
();
* return string
}
*/
else
protected
function
getCurrentTab
()
{
{
$missing_perm_path_titles
[]
=
$path
->
getTitle
();
return
"content"
;
}
}
}
/**
if
(
1
==
$num_items
)
* @return array
{
*/
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_paths_s'
),
true
);
protected
function
getRequirements
()
}
{
else
if
(
$num_items
>
1
)
return
array
(
{
"tables/class.ilQuestionSetPoolPathTableGUI.php"
,
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_paths_p'
),
true
);
"models/class.ilQuestionSetPoolPath.php"
,
}
"models/class.ilQuestionSetPoolSet.php"
);
$missing_perm_path_titles
=
array_filter
(
$missing_perm_path_titles
);
}
if
(
is_array
(
$missing_perm_path_titles
))
{
private
function
addSubTabs
()
if
(
1
==
count
(
$missing_perm_path_titles
))
{
{
global
$DIC
;
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_path_titles
)));
$ilTabs
=
$DIC
->
tabs
();
}
else
if
(
count
(
$missing_perm_path_titles
)
>
1
)
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'paths_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_path_titles
)));
$ilTabs
->
addSubTab
(
}
"set_questions"
,
}
$this
->
plugin
->
txt
(
"questions"
),
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
$set
->
getId
());
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
)
$this
->
redirect
(
__CLASS__
.
'.listPaths'
);
);
}
$ilTabs
->
addSubTab
(
/**
"paths"
,
* Returns the current tab name
$this
->
plugin
->
txt
(
"paths"
),
* return string
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
)
*/
);
protected
function
getCurrentTab
()
{
$ilTabs
->
addSubTab
(
return
"content"
;
"path_overview"
,
}
$this
->
plugin
->
txt
(
"path_overview"
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
)
/**
);
* @return array
*/
$ilTabs
->
activateSubTab
(
"paths"
);
protected
function
getRequirements
()
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
return
array
(
}
"tables/class.ilQuestionSetPoolPathTableGUI.php"
,
"models/class.ilQuestionSetPoolPath.php"
,
protected
function
doSorting
()
"models/class.ilQuestionSetPoolSet.php"
{
);
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
}
$model
->
read
();
$data
=
$model
->
getPathList
()
->
getData
();
private
function
addSubTabs
()
{
foreach
(
$data
as
$key
=>
$element
)
{
global
$DIC
;
$data
[
$key
][
"path_index"
]
=
(
int
)
$_POST
[
"sorting"
][
$element
[
"id"
]];
$ilTabs
=
$DIC
->
tabs
();
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
usort
(
$data
,
$ilTabs
->
addSubTab
(
"set_questions"
,
$this
->
plugin
->
txt
(
"questions"
),
function
(
$a
,
$b
)
{
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
));
return
$a
[
"path_index"
]
-
$b
[
"path_index"
];
}
$ilTabs
->
addSubTab
(
"paths"
,
$this
->
plugin
->
txt
(
"paths"
),
);
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
));
if
(
is_array
(
$data
))
{
for
(
$i
=
0
;
$i
<
count
(
$data
);
$i
++
)
{
$ilTabs
->
addSubTab
(
"path_overview"
,
$this
->
plugin
->
txt
(
"path_overview"
),
$data
[
$i
][
"path_index"
]
=
(
$i
+
1
);
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
));
$model
->
getPathList
()
->
update
(
$data
[
$i
]);
}
$ilTabs
->
activateSubTab
(
"paths"
);
}
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
}
}
protected
function
doSorting
()
{
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$model
->
read
();
$data
=
$model
->
getPathList
()
->
getData
();
foreach
(
$data
as
$key
=>
$element
)
{
$data
[
$key
][
"path_index"
]
=
(
int
)
$_POST
[
"sorting"
][
$element
[
"id"
]];
}
usort
(
$data
,
function
(
$a
,
$b
)
{
return
$a
[
"path_index"
]
-
$b
[
"path_index"
];
}
);
if
(
is_array
(
$data
))
{
for
(
$i
=
0
;
$i
<
count
(
$data
);
$i
++
)
{
$data
[
$i
][
"path_index"
]
=
(
$i
+
1
);
$model
->
getPathList
()
->
update
(
$data
[
$i
]);
}
}
}
}
\ No newline at end of file
classes/controllers/class.ilQuestionSetPoolPropertiesGUI.php
View file @
381d5850
...
@@ -8,101 +8,95 @@ require_once "abstract.ilPluginControllerFormGUI.php";
...
@@ -8,101 +8,95 @@ require_once "abstract.ilPluginControllerFormGUI.php";
* Date: 01.10.13
* Date: 01.10.13
* Time: 09:56
* Time: 09:56
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolPropertiesGUI
extends
ilPluginControllerFormGUI
class
ilQuestionSetPoolPropertiesGUI
extends
ilPluginControllerFormGUI
{
{
protected
function
initForm
(
$model
)
{
$this
->
form
=
new
ilPropertyFormGUI
();
protected
function
initForm
(
$model
)
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"title"
),
"title"
);
{
$title
->
setRequired
(
true
);
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
$this
->
form
=
new
ilPropertyFormGUI
();
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"
title"
),
"title
"
);
$description
=
new
ilText
Area
InputGUI
(
$this
->
plugin
->
txt
(
"
description"
),
"description
"
);
$title
->
setRequired
(
tru
e
);
$description
->
setRequired
(
fals
e
);
$description
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
"description"
),
"description"
);
$online
=
new
ilCheckboxInputGUI
(
$this
->
plugin
->
txt
(
"online"
),
"online"
);
$description
->
setRequired
(
false
);
$online
=
new
ilCheckboxInputGUI
(
$this
->
plugin
->
txt
(
"online"
),
"online"
);
$skill_service
=
new
ilCheckboxInputGUI
(
$this
->
plugin
->
txt
(
"skill_service_setting"
),
"skill_service"
);
$skill_service
->
setRequired
(
false
);
$skill_service
->
setInfo
(
$this
->
plugin
->
txt
(
'adm_enable_skmg_first'
));
global
$DIC
;
$ilSetting
=
$DIC
->
settings
();
$skill_setting_enabled
=
$ilSetting
->
_lookupValue
(
'skmg'
,
'enable_skmg'
);
if
(
$skill_setting_enabled
==
false
)
{
$skill_service
->
setChecked
(
$skill_setting_enabled
);
$skill_service
->
setValue
(
0
);
$skill_service
->
setDisabled
(
true
);
}
else
{
$skill_service
->
setValue
(
1
);
}
$skill_service
=
new
ilCheckboxInputGUI
(
$this
->
plugin
->
txt
(
"skill_service_setting"
),
"skill_service"
);
$this
->
form
->
addItem
(
$title
);
$skill_service
->
setRequired
(
false
);
$this
->
form
->
addItem
(
$description
);
$skill_service
->
setInfo
(
$this
->
plugin
->
txt
(
'adm_enable_skmg_first'
));
$this
->
form
->
addItem
(
$online
);
global
$DIC
;
$this
->
form
->
addItem
(
$skill_service
);
$ilSetting
=
$DIC
->
settings
();
$this
->
form
->
setTitle
(
$this
->
plugin
->
txt
(
"edit_properties"
));
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$skill_setting_enabled
=
$ilSetting
->
_lookupValue
(
'skmg'
,
'enable_skmg'
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPropertiesGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
if
(
$skill_setting_enabled
==
false
)
}
{
$skill_service
->
setChecked
(
$skill_setting_enabled
);
$skill_service
->
setValue
(
0
);
$skill_service
->
setDisabled
(
true
);
}
else
{
$skill_service
->
setValue
(
1
);
}
$this
->
form
->
addItem
(
$title
);
/**
$this
->
form
->
addItem
(
$description
);
* Returns the current tab name
$this
->
form
->
addItem
(
$online
);
* return string
$this
->
form
->
addItem
(
$skill_service
);
*/
$this
->
form
->
setTitle
(
$this
->
plugin
->
txt
(
"edit_properties"
));
protected
function
getCurrentTab
()
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
{
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolPropertiesGUI.update"
,
$this
->
plugin
->
txt
(
"save"
))
;
return
"properties"
;
}
}
/**
/**
* Returns the current tab name
* @return array
* return string
*/
*/
protected
function
getRequirements
()
protected
function
getCurrentTab
()
{
{
array
();
return
"properties"
;
}
}
/**
/**
* @return array
* Loads and returns the Model for the controller gui
*/
* @return ilPluginModelInterface
protected
function
getRequirements
()
*/
{
protected
function
loadModel
()
array
();
{
}
return
$this
->
controller
->
object
;
}
/**
/**
* Loads and returns the Model for the controller gui
* Get the redirect action after an update was successful
* @return ilPluginModelInterface
* @return string
*/
*/
protected
function
loadModel
()
protected
function
getRedirectAfterUpdate
()
{
{
return
$this
->
controller
->
object
;
}
}
/**
/**
* Get the redirect action after an update was successful
* Get the redirect action after an update was successful
* @return string
* @return string
*/
*/
protected
function
getRedirectAfterUpdate
()
protected
function
getAfterUpdateRedirectCmd
()
{
{
return
"ilQuestionSetPoolPropertiesGUI.edit"
;
}
}
/**
* @param $model
/**
*
* Get the redirect action after an update was successful
* @return array
* @return string
*/
*/
protected
function
getAfterUpdateRedirectParams
(
$model
)
protected
function
getAfterUpdateRedirectCmd
()
{
{
return
array
();
return
"ilQuestionSetPoolPropertiesGUI.edit"
;
}
}
/**
* @param $model
*
* @return array
*/
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
return
array
();
}
}
}
classes/controllers/class.ilQuestionSetPoolSetGUI.php
View file @
381d5850
...
@@ -8,116 +8,109 @@ require_once "abstract.ilPluginControllerFormGUI.php";
...
@@ -8,116 +8,109 @@ require_once "abstract.ilPluginControllerFormGUI.php";
* Date: 02.10.13
* Date: 02.10.13
* Time: 10:01
* Time: 10:01
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolSetGUI
extends
ilPluginControllerFormGUI
class
ilQuestionSetPoolSetGUI
extends
ilPluginControllerFormGUI
{
{
public
function
update
()
public
function
update
()
{
{
$model
=
$this
->
loadModel
();
$model
=
$this
->
loadModel
();
$this
->
initForm
(
$model
);
$this
->
initForm
(
$model
);
if
(
$this
->
form
->
checkInput
())
{
if
(
$this
->
form
->
checkInput
())
$model
->
bindForm
(
$this
->
form
);
{
$model
->
bindForm
(
$this
->
form
);
if
(
$model
->
isTitleUnique
())
{
$model
->
update
();
if
(
$model
->
isTitleUnique
())
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
{
$this
->
redirect
(
$model
->
update
();
$this
->
getAfterUpdateRedirectCmd
(),
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"msg_obj_modified"
),
true
);
$this
->
getAfterUpdateRedirectParams
(
$model
)
$this
->
redirect
(
);
$this
->
getAfterUpdateRedirectCmd
(),
}
else
{
$this
->
getAfterUpdateRedirectParams
(
$model
)
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"set_title_not_unique"
),
true
);
);
}
}
}
else
{
$this
->
form
->
setValuesByPost
();
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"set_title_not_unique"
),
true
);
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
}
}
}
/**
$this
->
form
->
setValuesByPost
();
* Returns the current tab name
$this
->
tpl
->
setContent
(
$this
->
form
->
getHTML
());
* return string
}
*/
protected
function
getCurrentTab
()
/**
{
* Returns the current tab name
return
"content"
;
* return string
}
*/
protected
function
getCurrentTab
()
/**
{
* @return array
return
"content"
;
*/
}
protected
function
getRequirements
()
{
/**
return
array
(
* @return array
"models/class.ilQuestionSetPoolSet.php"
*/
);
protected
function
getRequirements
()
}
{
return
array
(
protected
function
initForm
(
$model
)
"models/class.ilQuestionSetPoolSet.php"
{
);
$this
->
form
=
new
ilPropertyFormGUI
();
}
$this
->
form
->
setTitle
(
sprintf
(
$this
->
plugin
->
txt
(
"question_set_title"
),
protected
function
initForm
(
$model
)
$this
->
controller
->
object
->
getTitle
()
{
));
require_once
"./Services/Form/classes/class.ilPropertyFormGUI.php"
;
$id
=
new
ilHiddenInputGUI
(
"id"
);
$this
->
form
=
new
ilPropertyFormGUI
();
$this
->
form
->
setTitle
(
sprintf
(
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"title"
),
"title"
);
$this
->
plugin
->
txt
(
"question_set_title"
),
$title
->
setRequired
(
true
);
$this
->
controller
->
object
->
getTitle
()
));
$description
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
"description"
),
"description"
);
$description
->
setRequired
(
false
);
$id
=
new
ilHiddenInputGUI
(
"id"
);
$this
->
form
->
addItem
(
$id
);
$title
=
new
ilTextInputGUI
(
$this
->
plugin
->
txt
(
"title"
),
"title"
);
$this
->
form
->
addItem
(
$title
);
$title
->
setRequired
(
true
);
$this
->
form
->
addItem
(
$description
);
$description
=
new
ilTextAreaInputGUI
(
$this
->
plugin
->
txt
(
"description"
),
"description"
);
$description
->
setRequired
(
false
);
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
$this
->
form
->
addItem
(
$id
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolSetGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
$this
->
form
->
addItem
(
$title
);
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolSetsGUI.show"
,
$this
->
plugin
->
txt
(
"cancel"
));
$this
->
form
->
addItem
(
$description
);
}
/**
$this
->
form
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
));
* Loads and returns the Model for the controller gui
*
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolSetGUI.update"
,
$this
->
plugin
->
txt
(
"save"
));
* @return ilPluginModelInterface
$this
->
form
->
addCommandButton
(
"ilQuestionSetPoolSetsGUI.show"
,
$this
->
plugin
->
txt
(
"cancel"
));
*/
}
protected
function
loadModel
()
{
/**
$id
=
isset
(
$_GET
[
"set_id"
])
?
(
int
)
$_GET
[
'set_id'
]
:
(
int
)
$_POST
[
"id"
];
* Loads and returns the Model for the controller gui
$model
=
new
ilQuestionSetPoolSet
(
$id
);
*
$model
->
setContainerObjId
(
$this
->
controller
->
object
->
getId
());
* @return ilPluginModelInterface
$model
->
read
();
*/
protected
function
loadModel
()
return
$model
;
{
}
$id
=
isset
(
$_GET
[
"set_id"
])
?
(
int
)
$_GET
[
'set_id'
]
:
(
int
)
$_POST
[
"id"
];
$model
=
new
ilQuestionSetPoolSet
(
$id
);
/**
$model
->
setContainerObjId
(
$this
->
controller
->
object
->
getId
());
* Get the redirect action after an update was successful
$model
->
read
();
* @return string
*/
return
$model
;
protected
function
getAfterUpdateRedirectCmd
()
}
{
return
"ilQuestionSetPoolSetsGUI.show"
;
/**
}
* Get the redirect action after an update was successful
* @return string
/**
*/
* @param $model
protected
function
getAfterUpdateRedirectCmd
()
*
{
* @return array
return
"ilQuestionSetPoolSetsGUI.show"
;
*/
}
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
/**
return
array
();
* @param $model
}
*
* @return array
*/
protected
function
getAfterUpdateRedirectParams
(
$model
)
{
return
array
();
}
}
}
classes/controllers/class.ilQuestionSetPoolSetQuestionsGUI.php
View file @
381d5850
...
@@ -8,374 +8,354 @@ require_once "abstract.ilPluginControllerTableGUI.php";
...
@@ -8,374 +8,354 @@ require_once "abstract.ilPluginControllerTableGUI.php";
* Date: 08.10.13
* Date: 08.10.13
* Time: 11:11
* Time: 11:11
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolSetQuestionsGUI
extends
ilPluginControllerTableGUI
class
ilQuestionSetPoolSetQuestionsGUI
extends
ilPluginControllerTableGUI
{
{
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
{
{
parent
::
__construct
(
$controller
);
parent
::
__construct
(
$controller
);
$this
->
addSubTabs
();
$this
->
addSubTabs
();
}
}
/**
/**
*
*
*/
*/
public
function
listQuestions
()
public
function
listQuestions
()
{
{
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
controller
->
ensurePermission
(
'write'
);
if
(
$this
->
controller
->
object
instanceof
ilObjQuestionSetPool
)
if
(
$this
->
controller
->
object
instanceof
ilObjQuestionSetPool
)
{
{
$this
->
addToolbarButton
(
"back_to_set_list"
,
"ilQuestionSetPoolSetsGUI.show"
);
$this
->
addToolbarButton
(
"back_to_set_list"
,
"ilQuestionSetPoolSetsGUI.show"
);
}
}
$this
->
addToolbarButton
(
"browse_for_questions"
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
$this
->
addToolbarButton
(
"browse_for_questions"
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
"set_id"
=>
(
int
)
$_GET
[
'set_id'
]
"set_id"
=>
(
int
)
$_GET
[
'set_id'
]
));
));
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$set
->
read
();
$set
->
read
();
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
"set_id"
]);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
"set_id"
]);
$table
=
new
ilQuestionSetPoolSetQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
ilQuestionSetPoolSetQuestionsTableGUI
::
CONTEXT_LIST_SET_QST
,
(
int
)
$_GET
[
'set_id'
]);
$table
=
new
ilQuestionSetPoolSetQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
ilQuestionSetPoolSetQuestionsTableGUI
::
CONTEXT_LIST_SET_QST
,
(
int
)
$_GET
[
'set_id'
]);
$table
->
setModelList
(
$set
->
getQuestionList
());
$table
->
setModelList
(
$set
->
getQuestionList
());
$table
->
setTitle
(
$table
->
setTitle
(
$set
->
getTitle
()
.
" - "
.
$set
->
getTitle
()
.
" - "
.
$this
->
plugin
->
txt
(
"questions"
)
$this
->
plugin
->
txt
(
"questions"
)
);
);
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.removeMultipleConfirmation"
,
$this
->
controller
->
lng
->
txt
(
"remove"
));
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.removeMultipleConfirmation"
,
$this
->
controller
->
lng
->
txt
(
"remove"
));
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.copyQuestion"
,
$this
->
controller
->
lng
->
txt
(
"duplicate"
));
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.copyQuestion"
,
$this
->
controller
->
lng
->
txt
(
"duplicate"
));
$table
->
populate
();
$table
->
populate
();
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
}
/**
/**
*
*
*/
*/
public
function
browseForQuestions
()
public
function
browseForQuestions
()
{
{
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
addToolbarButton
(
"back_to_qst_list"
,
__CLASS__
.
".listQuestions"
);
$this
->
addToolbarButton
(
"back_to_qst_list"
,
__CLASS__
.
".listQuestions"
);
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
$table
->
initFilter
();
$table
->
initFilter
();
$modellist
=
new
ilQuestionPoolQuestionList
();
$modellist
=
new
ilQuestionPoolQuestionList
();
$modellist
->
setQuestionSetPool
(
$this
->
controller
->
object
);
$modellist
->
setQuestionSetPool
(
$this
->
controller
->
object
);
$table
->
setModelList
(
$modellist
);
$table
->
setModelList
(
$modellist
);
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.insertQuestions"
,
$this
->
controller
->
lng
->
txt
(
"insert"
));
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetQuestionsGUI.insertQuestions"
,
$this
->
controller
->
lng
->
txt
(
"insert"
));
$table
->
populate
();
$table
->
populate
();
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"qs_question_info"
),
true
);
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"qs_question_info"
),
true
);
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
}
/**
/**
*
*
*/
*/
public
function
insertQuestions
()
public
function
insertQuestions
()
{
{
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
controller
->
ensurePermission
(
'write'
);
if
(
!
$this
->
dataSelected
(
"q_id"
))
{
if
(
!
$this
->
dataSelected
(
"q_id"
))
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"no_questions_selected"
),
true
);
{
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
"no_questions_selected"
),
true
);
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
));
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
}
));
}
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
$set
->
read
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
$success
=
$set
->
getQuestionList
()
->
insert
(
$_POST
[
'q_id'
],
$this
->
controller
->
object
);
$set
->
read
();
$success
=
$set
->
getQuestionList
()
->
insert
(
$_POST
[
'q_id'
],
$this
->
controller
->
object
);
if
(
!
$success
)
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"questions_added_error"
),
true
);
if
(
!
$success
)
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
{
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
"questions_added_error"
),
true
);
));
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
array
(
}
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
));
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"questions_added"
),
true
);
}
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
array
(
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"questions_added"
),
true
);
));
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
array
(
}
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
));
/**
}
* Called if a single set should be deleted, calls \\ilQuestionSetPoolSetQuestionsGUI::removeMultipleConfirmation do show the confirmation screen
*/
/**
public
function
removeConfirmation
()
* Called if a single set should be deleted, calls \\ilQuestionSetPoolSetQuestionsGUI::removeMultipleConfirmation do show the confirmation screen
{
*/
if
(
!
isset
(
$_GET
[
'q_id'
]))
{
public
function
removeConfirmation
()
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
));
{
$this
->
listQuestions
();
if
(
!
isset
(
$_GET
[
'q_id'
]))
return
;
{
}
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
));
$this
->
listQuestions
();
$_POST
[
'q_id'
]
=
array
((
int
)
$_GET
[
'q_id'
]);
return
;
$this
->
removeMultipleConfirmation
();
}
}
$_POST
[
'q_id'
]
=
array
((
int
)
$_GET
[
'q_id'
]);
/**
$this
->
removeMultipleConfirmation
();
*
}
*/
public
function
copyQuestion
()
/**
{
*
$this
->
controller
->
ensurePermission
(
'write'
);
*/
public
function
copyQuestion
()
if
(
!
isset
(
$_POST
[
'q_id'
])
||
!
is_array
(
$_POST
[
'q_id'
])
||
!
count
(
$_POST
[
'q_id'
]))
{
{
ilUtil
::
sendFailure
(
$this
->
lng
->
txt
(
'copy_no_questions_selected'
));
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
listQuestions
();
}
if
(
!
isset
(
$_POST
[
'q_id'
])
||
!
is_array
(
$_POST
[
'q_id'
])
||
!
count
(
$_POST
[
'q_id'
]))
{
$question_ids
=
array_filter
((
array
)
$_POST
[
'q_id'
]);
ilUtil
::
sendFailure
(
$this
->
lng
->
txt
(
'copy_no_questions_selected'
));
$this
->
listQuestions
();
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
}
$set
->
read
();
$set
->
getQuestionList
()
->
insert
(
$question_ids
,
$this
->
controller
->
object
);
$question_ids
=
array_filter
((
array
)
$_POST
[
'q_id'
]);
if
(
is_array
(
$question_ids
))
{
if
(
1
==
count
(
$question_ids
))
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'copy_questions_success_s'
),
true
);
$set
->
read
();
}
else
{
$set
->
getQuestionList
()
->
insert
(
$question_ids
,
$this
->
controller
->
object
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'copy_questions_success_p'
),
true
);
if
(
is_array
(
$question_ids
))
}
{
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
array
(
if
(
1
==
count
(
$question_ids
))
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
{
));
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'copy_questions_success_s'
),
true
);
}
}
}
else
{
/**
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'copy_questions_success_p'
),
true
);
*
}
*/
$this
->
redirect
(
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
,
array
(
public
function
removeMultipleConfirmation
()
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
{
));
$this
->
controller
->
ensurePermission
(
'write'
);
}
}
if
(
!
$this
->
dataSelected
(
'q_id'
))
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
));
/**
$this
->
listQuestions
();
*
return
;
*/
}
public
function
removeMultipleConfirmation
()
{
$this
->
redirectIfQuestionIsUsedInPath
();
$this
->
controller
->
ensurePermission
(
'write'
);
$confirmation
=
new
ilConfirmationGUI
();
if
(
!
$this
->
dataSelected
(
'q_id'
))
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
{
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.listQuestions'
));
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
));
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
''
);
$this
->
listQuestions
();
$confirmation
->
setCancel
(
$this
->
lng
->
txt
(
'cancel'
),
__CLASS__
.
'.listQuestions'
);
return
;
$confirmation
->
setConfirm
(
$this
->
lng
->
txt
(
'confirm'
),
__CLASS__
.
'.removeQuestions'
);
}
$num_items
=
0
;
$this
->
redirectIfQuestionIsUsedInPath
();
foreach
(
$_POST
[
'q_id'
]
as
$question_id
)
{
$question
=
assQuestion
::
_instanciateQuestion
(
$question_id
);
$confirmation
=
new
ilConfirmationGUI
();
$confirmation
->
addItem
(
'q_id[]'
,
$question_id
,
$question
->
getTitle
());
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
(
int
)
$_GET
[
'set_id'
]);
++
$num_items
;
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.listQuestions'
));
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
'set_id'
,
''
);
$confirmation
->
setCancel
(
$this
->
lng
->
txt
(
'cancel'
),
__CLASS__
.
'.listQuestions'
);
if
(
1
==
$num_items
)
{
$confirmation
->
setConfirm
(
$this
->
lng
->
txt
(
'confirm'
),
__CLASS__
.
'.removeQuestions'
);
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'remove_selected_questions_s'
));
}
else
{
$num_items
=
0
;
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'remove_selected_questions_p'
));
require_once
'Modules/TestQuestionPool/classes/class.assQuestion.php'
;
}
foreach
(
$_POST
[
'q_id'
]
as
$question_id
)
{
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
$question
=
assQuestion
::
_instanciateQuestion
(
$question_id
);
}
$confirmation
->
addItem
(
'q_id[]'
,
$question_id
,
$question
->
getTitle
());
++
$num_items
;
public
function
removeQuestions
()
}
{
$this
->
controller
->
ensurePermission
(
'write'
);
if
(
1
==
$num_items
)
{
if
(
!
$this
->
dataSelected
(
'q_id'
))
{
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'remove_selected_questions_s'
));
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
),
true
);
}
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
array
(
else
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
{
));
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'remove_selected_questions_p'
));
}
}
$this
->
redirectIfQuestionIsUsedInPath
();
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
}
$questions_to_delete
=
(
array
)
$_POST
[
'q_id'
];
public
function
removeQuestions
()
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
{
$model
->
read
();
$this
->
controller
->
ensurePermission
(
'write'
);
$model
->
getQuestionList
()
->
remove
(
$questions_to_delete
);
if
(
!
$this
->
dataSelected
(
'q_id'
))
if
(
is_array
(
$questions_to_delete
)
&&
count
(
$questions_to_delete
)
==
1
)
{
{
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_selected_questions_s'
),
true
);
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_questions_selected_to_delete'
),
true
);
}
else
{
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
array
(
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_selected_questions_p'
),
true
);
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
}
));
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
array
(
}
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
));
$this
->
redirectIfQuestionIsUsedInPath
();
}
$questions_to_delete
=
(
array
)
$_POST
[
'q_id'
];
/**
*
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
*/
$model
->
read
();
public
function
showQuestionPreview
()
$model
->
getQuestionList
()
->
remove
(
$questions_to_delete
);
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
if
(
is_array
(
$questions_to_delete
)
&&
count
(
$questions_to_delete
)
==
1
)
if
(
isset
(
$_GET
[
'referer'
])
&&
'browse'
==
$_GET
[
'referer'
])
{
{
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
'back_to_qst_list'
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
__CLASS__
.
'.browseForQuestions'
));
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_selected_questions_s'
),
true
);
}
else
{
}
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
'back_to_qst_list'
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
__CLASS__
.
'.listQuestions'
));
else
}
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_selected_questions_p'
),
true
);
}
$this
->
controller
->
populateContentStyleBlock
();
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
array
(
$this
->
controller
->
populateSyntaxStyleBlock
();
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
));
$gui
=
assQuestion
::
instantiateQuestionGUI
((
int
)
$_GET
[
'q_id'
]);
}
$gui
->
setTargetGuiClass
(
'ilObjQuestionSetPoolGUI'
);
$preview
=
$gui
->
getPreview
();
/**
$this
->
tpl
->
setContent
(
$preview
);
*
}
*/
public
function
showQuestionPreview
()
public
function
applyAvailableFilter
()
{
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
if
(
isset
(
$_GET
[
'referer'
])
&&
'browse'
==
$_GET
[
'referer'
])
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
{
$table
->
initFilter
();
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
'back_to_qst_list'
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
__CLASS__
.
'.browseForQuestions'
));
$table
->
resetOffset
();
}
$table
->
writeFilterToSession
();
else
{
$this
->
browseForQuestions
();
$this
->
toolbar
->
addButton
(
$this
->
plugin
->
txt
(
'back_to_qst_list'
),
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
__CLASS__
.
'.listQuestions'
));
}
}
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
public
function
resetAvailableFilter
()
{
$this
->
controller
->
populateContentStyleBlock
();
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
$this
->
controller
->
populateSyntaxStyleBlock
();
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
$table
->
initFilter
();
require_once
'Modules/TestQuestionPool/classes/class.assQuestion.php'
;
$table
->
resetOffset
();
$gui
=
assQuestion
::
instantiateQuestionGUI
((
int
)
$_GET
[
'q_id'
]);
$table
->
resetFilter
();
$gui
->
setTargetGuiClass
(
'ilObjQuestionSetPoolGUI'
);
$preview
=
$gui
->
getPreview
();
$this
->
browseForQuestions
();
$this
->
tpl
->
setContent
(
$preview
);
}
}
/**
public
function
applyAvailableFilter
()
* Returns the current tab name
{
* return string
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
*/
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
protected
function
getCurrentTab
()
$table
->
initFilter
();
{
$table
->
resetOffset
();
return
"content"
;
$table
->
writeFilterToSession
();
}
$this
->
browseForQuestions
();
/**
}
* @return array
*/
public
function
resetAvailableFilter
()
protected
function
getRequirements
()
{
{
$table
=
new
ilQuestionSetPoolQuestionsTableGUI
(
$this
->
controller
,
$this
->
plugin
,
"ilQuestionSetPoolSetQuestionsGUI.browseForQuestions"
,
ilQuestionSetPoolQuestionsTableGUI
::
CONTEXT_LIST_LINKED_QST_IN_SET
,
(
int
)
$_GET
[
'set_id'
]);
return
array
(
$table
->
setGuiClassName
(
"ilQuestionSetPoolSetQuestionsGUI"
);
"tables/class.ilQuestionSetPoolQuestionsTableGUI.php"
,
$table
->
initFilter
();
"tables/class.ilQuestionSetPoolSetQuestionsTableGUI.php"
,
$table
->
resetOffset
();
"models/class.ilQuestionSetPoolSet.php"
,
$table
->
resetFilter
();
"models/class.ilQuestionSetPoolPath.php"
,
"models/class.ilQuestionPoolQuestionList.php"
,
$this
->
browseForQuestions
();
}
);
}
/**
* Returns the current tab name
/**
* return string
*
*/
*/
protected
function
getCurrentTab
()
public
function
editQuestion
()
{
{
return
"content"
;
$this
->
controller
->
ensurePermission
(
'write'
);
}
if
(
!
isset
(
$_GET
[
'q_id'
])
||
!
(
int
)
$_GET
[
'q_id'
])
{
/**
$this
->
listQuestions
();
* @return array
return
;
*/
}
protected
function
getRequirements
()
{
$params
=
array
(
require_once
"Services/Utilities/classes/class.ilConfirmationGUI.php"
;
'set_id'
=>
(
int
)
$_GET
[
'set_id'
],
require_once
"Modules/Test/classes/class.ilObjAssessmentFolder.php"
;
'cmd'
=>
__CLASS__
.
'.listQuestions'
);
return
array
(
"tables/class.ilQuestionSetPoolQuestionsTableGUI.php"
,
$question_id
=
(
int
)
$_GET
[
'q_id'
];
"tables/class.ilQuestionSetPoolSetQuestionsTableGUI.php"
,
ilUtil
::
redirect
(
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_id
);
"models/class.ilQuestionSetPoolSet.php"
,
}
"models/class.ilQuestionSetPoolPath.php"
,
"models/class.ilQuestionPoolQuestionList.php"
,
private
function
addSubTabs
()
{
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
}
$this
->
tabs
->
addSubTab
(
/**
"set_questions"
,
*
$this
->
plugin
->
txt
(
"questions"
),
*/
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
)
public
function
editQuestion
()
);
{
$this
->
controller
->
ensurePermission
(
'write'
);
$this
->
tabs
->
addSubTab
(
"paths"
,
if
(
!
isset
(
$_GET
[
'q_id'
])
||
!
(
int
)
$_GET
[
'q_id'
])
$this
->
plugin
->
txt
(
"paths"
),
{
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
)
$this
->
listQuestions
();
);
return
;
}
$this
->
tabs
->
addSubTab
(
"path_overview"
,
$params
=
array
(
$this
->
plugin
->
txt
(
"path_overview"
),
'set_id'
=>
(
int
)
$_GET
[
'set_id'
],
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
)
'cmd'
=>
__CLASS__
.
'.listQuestions'
);
);
$this
->
tabs
->
activateSubTab
(
"set_questions"
);
$question_id
=
(
int
)
$_GET
[
'q_id'
];
ilUtil
::
redirect
(
'ilias.php?consumer_context='
.
base64_encode
(
json_encode
(
$params
))
.
'&baseClass=ilObjQuestionPoolGUI&ref_id='
.
$this
->
controller
->
object
->
getRefId
()
.
'&cmd=editQuestionForTest&calling_consumer='
.
$this
->
controller
->
object
->
getRefId
()
.
'&q_id='
.
$question_id
);
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
}
}
private
function
addSubTabs
()
/**
{
*
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
(
int
)
$_GET
[
'set_id'
]);
*/
protected
function
redirectIfQuestionIsUsedInPath
()
$this
->
tabs
->
addSubTab
(
"set_questions"
,
$this
->
plugin
->
txt
(
"questions"
),
{
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolSetQuestionsGUI.listQuestions"
));
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
$model
->
read
();
$this
->
tabs
->
addSubTab
(
"paths"
,
$this
->
plugin
->
txt
(
"paths"
),
$paths
=
$model
->
getPathList
()
->
getData
();
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathsGUI.listPaths"
));
foreach
((
array
)
$_POST
[
'q_id'
]
as
$question_id
)
{
$this
->
tabs
->
addSubTab
(
"path_overview"
,
$this
->
plugin
->
txt
(
"path_overview"
),
foreach
(
$paths
as
$path_data
)
{
$this
->
ctrl
->
getLinkTarget
(
$this
->
controller
,
"ilQuestionSetPoolPathGraphGUI.showPathOverview"
));
$path
=
new
ilQuestionSetPoolPath
(
$path_data
[
'id'
]);
$path
->
read
();
$this
->
tabs
->
activateSubTab
(
"set_questions"
);
if
(
$path
->
isQuestionInPath
(
$question_id
))
{
$this
->
ctrl
->
setParameter
(
$this
->
controller
,
"set_id"
,
""
);
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
'questions_used_in_path'
),
true
);
}
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
/**
array
(
*
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
*/
)
protected
function
redirectIfQuestionIsUsedInPath
()
);
{
}
$model
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
'set_id'
]);
}
$model
->
read
();
}
$paths
=
$model
->
getPathList
()
->
getData
();
}
foreach
((
array
)
$_POST
[
'q_id'
]
as
$question_id
)
{
foreach
(
$paths
as
$path_data
)
{
$path
=
new
ilQuestionSetPoolPath
(
$path_data
[
'id'
]);
$path
->
read
();
if
(
$path
->
isQuestionInPath
(
$question_id
))
{
ilUtil
::
sendFailure
(
$this
->
plugin
->
txt
(
'questions_used_in_path'
),
true
);
$this
->
redirect
(
'ilQuestionSetPoolSetQuestionsGUI.listQuestions'
,
array
(
'set_id'
=>
(
int
)
$_GET
[
'set_id'
]
)
);
}
}
}
}
}
}
classes/controllers/class.ilQuestionSetPoolSetsGUI.php
View file @
381d5850
...
@@ -8,222 +8,191 @@ require_once "abstract.ilPluginControllerTableGUI.php";
...
@@ -8,222 +8,191 @@ require_once "abstract.ilPluginControllerTableGUI.php";
* Date: 02.10.13
* Date: 02.10.13
* Time: 09:33
* Time: 09:33
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilQuestionSetPoolSetsGUI
extends
ilPluginControllerTableGUI
class
ilQuestionSetPoolSetsGUI
extends
ilPluginControllerTableGUI
{
{
public
function
show
()
public
function
show
()
{
{
$this
->
addToolbarButton
(
"add_set"
,
"ilQuestionSetPoolSetGUI.edit"
);
$this
->
addToolbarButton
(
"add_set"
,
"ilQuestionSetPoolSetGUI.edit"
);
$table
=
new
ilQuestionSetPoolSetsTableGUI
(
$this
->
controller
,
$this
->
plugin
);
$table
=
new
ilQuestionSetPoolSetsTableGUI
(
$this
->
controller
,
$this
->
plugin
);
$tmp
=
$this
->
controller
->
object
->
getSetList
();
$tmp
=
$this
->
controller
->
object
->
getSetList
();
$table
->
setModelList
(
$this
->
controller
->
object
->
getSetList
());
$table
->
setModelList
(
$this
->
controller
->
object
->
getSetList
());
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetsGUI.duplicate"
,
$this
->
lng
->
txt
(
"copy"
));
$table
->
addMultiCommand
(
"ilQuestionSetPoolSetsGUI.duplicate"
,
$this
->
lng
->
txt
(
"copy"
));
$table
->
populate
();
$table
->
populate
();
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
$this
->
tpl
->
setContent
(
$table
->
getHTML
());
}
}
/**
/**
* Called if a single set should be deleted, calls \ilQuestionSetPoolSetsGUI::removeMultipleConfirmation do show the confirmation screen
* Called if a single set should be deleted, calls \ilQuestionSetPoolSetsGUI::removeMultipleConfirmation do show the confirmation screen
*/
*/
public
function
removeConfirmation
()
public
function
removeConfirmation
()
{
{
if
(
!
isset
(
$_GET
[
'set_id'
]))
{
if
(
!
isset
(
$_GET
[
'set_id'
]))
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
{
$this
->
show
();
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
return
;
$this
->
show
();
}
return
;
}
$_POST
[
'set_id'
]
=
array
((
int
)
$_GET
[
'set_id'
]);
$this
->
removeMultipleConfirmation
();
$_POST
[
'set_id'
]
=
array
((
int
)
$_GET
[
'set_id'
]);
}
$this
->
removeMultipleConfirmation
();
}
/**
* Shows an confirmation screen for the selected sets
/**
*/
* Shows an confirmation screen for the selected sets
public
function
removeMultipleConfirmation
()
*/
{
public
function
removeMultipleConfirmation
()
if
(
!
isset
(
$_POST
[
'set_id'
])
||
!
is_array
(
$_POST
[
'set_id'
]))
{
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
if
(
!
isset
(
$_POST
[
'set_id'
])
||
!
is_array
(
$_POST
[
'set_id'
]))
$this
->
show
();
{
return
;
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
}
$this
->
show
();
return
;
$this
->
tabs
->
activateSubTab
(
'paths'
);
}
$confirmation
=
new
ilConfirmationGUI
();
$this
->
tabs
->
activateSubTab
(
'paths'
);
$num_items
=
0
;
require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php'
;
$missing_perm_nodes_titles
=
array
();
$confirmation
=
new
ilConfirmationGUI
();
foreach
(
$_POST
[
'set_id'
]
as
$set_id
)
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
$num_items
=
0
;
$set
->
read
();
$missing_perm_nodes_titles
=
array
();
if
(
$set
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
{
foreach
(
$_POST
[
'set_id'
]
as
$set_id
)
$confirmation
->
addItem
(
'set_id[]'
,
$set
->
getId
(),
$set
->
getTitle
());
{
++
$num_items
;
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
}
else
{
$set
->
read
();
$missing_perm_nodes_titles
[]
=
$set
->
getTitle
();
if
(
$set
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
}
{
}
$confirmation
->
addItem
(
'set_id[]'
,
$set
->
getId
(),
$set
->
getTitle
());
++
$num_items
;
if
(
1
==
$num_items
)
{
}
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_sets_s'
));
else
}
else
{
{
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_sets_p'
));
$missing_perm_nodes_titles
[]
=
$set
->
getTitle
();
}
}
}
$missing_perm_nodes_titles
=
array_filter
(
$missing_perm_nodes_titles
);
if
(
is_array
(
$missing_perm_nodes_titles
))
{
if
(
1
==
$num_items
)
if
(
1
==
count
(
$missing_perm_nodes_titles
))
{
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_sets_s'
));
}
elseif
(
count
(
$missing_perm_nodes_titles
)
>
1
)
{
}
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
else
}
{
}
$confirmation
->
setHeaderText
(
$this
->
plugin
->
txt
(
'confirm_delete_sets_p'
));
if
(
!
$num_items
)
{
}
$this
->
show
();
return
;
$missing_perm_nodes_titles
=
array_filter
(
$missing_perm_nodes_titles
);
}
if
(
is_array
(
$missing_perm_nodes_titles
))
{
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.show'
));
if
(
1
==
count
(
$missing_perm_nodes_titles
))
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
'cancel'
),
__CLASS__
.
'.show'
);
{
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
'confirm'
),
__CLASS__
.
'.remove'
);
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
}
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
else
if
(
count
(
$missing_perm_nodes_titles
)
>
1
)
}
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
/**
}
* Finally deletes (cascading) the selected sets
}
*/
if
(
!
$num_items
)
public
function
remove
()
{
{
$this
->
show
();
if
(
!
isset
(
$_POST
[
'set_id'
])
||
!
is_array
(
$_POST
[
'set_id'
]))
{
return
;
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
}
$this
->
show
();
return
;
$confirmation
->
setFormAction
(
$this
->
ctrl
->
getFormAction
(
$this
->
controller
,
__CLASS__
.
'.show'
));
}
$confirmation
->
setCancel
(
$this
->
plugin
->
txt
(
'cancel'
),
__CLASS__
.
'.show'
);
$confirmation
->
setConfirm
(
$this
->
plugin
->
txt
(
'confirm'
),
__CLASS__
.
'.remove'
);
$num_items
=
0
;
$missing_perm_nodes_titles
=
array
();
$this
->
tpl
->
setContent
(
$confirmation
->
getHTML
());
foreach
(
$_POST
[
'set_id'
]
as
$set_id
)
{
}
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
$set
->
read
();
/**
if
(
$set
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
{
* Finally deletes (cascading) the selected sets
$set
->
remove
();
*/
++
$num_items
;
public
function
remove
()
}
else
{
{
$missing_perm_nodes_titles
[]
=
$set
->
getTitle
();
if
(
!
isset
(
$_POST
[
'set_id'
])
||
!
is_array
(
$_POST
[
'set_id'
]))
}
{
}
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
$this
->
show
();
if
(
1
==
$num_items
)
{
return
;
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_sets_s'
),
true
);
}
}
elseif
(
$num_items
>
1
)
{
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_sets_p'
),
true
);
$num_items
=
0
;
}
$missing_perm_nodes_titles
=
array
();
foreach
(
$_POST
[
'set_id'
]
as
$set_id
)
$missing_perm_nodes_titles
=
array_filter
(
$missing_perm_nodes_titles
);
{
if
(
is_array
(
$missing_perm_nodes_titles
))
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
if
(
1
==
count
(
$missing_perm_nodes_titles
))
{
$set
->
read
();
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
if
(
$set
->
getContainerObjId
()
==
$this
->
controller
->
object
->
getId
())
}
elseif
(
count
(
$missing_perm_nodes_titles
)
>
1
)
{
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
$set
->
remove
();
}
++
$num_items
;
}
}
$this
->
redirect
(
__CLASS__
.
'.show'
);
else
}
{
$missing_perm_nodes_titles
[]
=
$set
->
getTitle
();
public
function
duplicate
()
}
{
}
if
(
!
$this
->
dataSelected
(
"set_id"
))
{
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
if
(
1
==
$num_items
)
$this
->
redirect
(
"ilQuestionSetPoolSetsGUI.show"
);
{
}
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_sets_s'
),
true
);
}
foreach
(
$_POST
[
"set_id"
]
as
$set_id
)
{
else
if
(
$num_items
>
1
)
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
{
$set
->
read
();
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
'deleted_sets_p'
),
true
);
$set
->
duplicate
(
$this
->
controller
->
object
->
getId
());
}
}
$missing_perm_nodes_titles
=
array_filter
(
$missing_perm_nodes_titles
);
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"sets_duplicated"
),
true
);
if
(
is_array
(
$missing_perm_nodes_titles
))
$this
->
redirect
(
"ilQuestionSetPoolSetsGUI.show"
);
{
}
if
(
1
==
count
(
$missing_perm_nodes_titles
))
{
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_s'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
public
function
synchronize
()
}
{
else
if
(
count
(
$missing_perm_nodes_titles
)
>
1
)
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
{
$set
->
read
();
ilUtil
::
sendFailure
(
sprintf
(
$this
->
plugin
->
txt
(
'sets_del_perm_err_p'
),
implode
(
', '
,
$missing_perm_nodes_titles
)));
}
if
(
ilObjQuestionSetPool
::
canSynchronizeSet
(
$set
->
getOriginalId
()))
{
}
$original
=
new
ilQuestionSetPoolSet
(
$set
->
getOriginalId
());
$this
->
redirect
(
__CLASS__
.
'.show'
);
$original
->
read
();
}
$old_questions
=
$original
->
getQuestionList
()
->
getData
();
$original
->
remove
();
public
function
duplicate
()
{
$clone
=
$set
->
synchronize
(
$original
->
getContainerObjId
(),
$old_questions
);
if
(
!
$this
->
dataSelected
(
"set_id"
))
//$clone = $set->duplicate($original->getContainerObjId());
{
$clone
->
setOriginalId
(
null
);
ilUtil
::
sendInfo
(
$this
->
plugin
->
txt
(
'no_set_selected'
));
$clone
->
update
();
$this
->
redirect
(
"ilQuestionSetPoolSetsGUI.show"
);
}
ilQuestionSetPoolSet
::
updateOriginalId
(
$set
->
getOriginalId
(),
$clone
->
getId
());
foreach
(
$_POST
[
"set_id"
]
as
$set_id
)
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"sets_synchronize_success"
),
true
);
{
}
$set
=
new
ilQuestionSetPoolSet
((
int
)
$set_id
);
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
"set_id"
=>
$_GET
[
"set_id"
]));
$set
->
read
();
}
$set
->
duplicate
(
$this
->
controller
->
object
->
getId
());
}
/**
* Returns the current tab name
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"sets_duplicated"
),
true
);
* return string
$this
->
redirect
(
"ilQuestionSetPoolSetsGUI.show"
);
*/
}
protected
function
getCurrentTab
()
{
return
"content"
;
public
function
synchronize
()
}
{
$set
=
new
ilQuestionSetPoolSet
((
int
)
$_GET
[
"set_id"
]);
/**
$set
->
read
();
* @return array
*/
if
(
ilObjQuestionSetPool
::
canSynchronizeSet
(
$set
->
getOriginalId
()))
protected
function
getRequirements
()
{
{
$original
=
new
ilQuestionSetPoolSet
(
$set
->
getOriginalId
());
return
array
(
$original
->
read
();
"tables/class.ilQuestionSetPoolSetsTableGUI.php"
,
$old_questions
=
$original
->
getQuestionList
()
->
getData
();
"providers/class.ilQuestionSetPoolSetsProvider.php"
,
$original
->
remove
();
"models/class.ilQuestionSetPoolSet.php"
);
$clone
=
$set
->
synchronize
(
$original
->
getContainerObjId
(),
$old_questions
);
}
//$clone = $set->duplicate($original->getContainerObjId());
$clone
->
setOriginalId
(
null
);
$clone
->
update
();
ilQuestionSetPoolSet
::
updateOriginalId
(
$set
->
getOriginalId
(),
$clone
->
getId
());
ilUtil
::
sendSuccess
(
$this
->
plugin
->
txt
(
"sets_synchronize_success"
),
true
);
}
$this
->
redirect
(
"ilQuestionSetPoolPathsGUI.listPaths"
,
array
(
"set_id"
=>
$_GET
[
"set_id"
]));
}
/**
* Returns the current tab name
* return string
*/
protected
function
getCurrentTab
()
{
return
"content"
;
}
/**
* @return array
*/
protected
function
getRequirements
()
{
return
array
(
"tables/class.ilQuestionSetPoolSetsTableGUI.php"
,
"providers/class.ilQuestionSetPoolSetsProvider.php"
,
"models/class.ilQuestionSetPoolSet.php"
);
}
}
}
classes/controllers/class.ilQuestionSetPoolSkillAdministrationGUI.php
View file @
381d5850
<?php
<?php
require_once
'abstract.ilPluginControllerGUI.php'
;
require_once
'abstract.ilPluginControllerGUI.php'
;
require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php'
;
require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillUsagesTableGUI.php'
;
require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php'
;
/**
/**
...
@@ -18,125 +15,126 @@ require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
...
@@ -18,125 +15,126 @@ require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
class
ilQuestionSetPoolSkillAdministrationGUI
extends
ilPLuginControllerGUI
class
ilQuestionSetPoolSkillAdministrationGUI
extends
ilPLuginControllerGUI
{
{
/**
/**
* @var ilObjQuestionSetPool
* @var ilObjQuestionSetPool
*/
*/
protected
$object
;
protected
$object
;
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
public
function
__construct
(
ilObjQuestionSetPoolGUI
$controller
)
{
{
$this
->
object
=
$controller
->
object
;
$this
->
object
=
$controller
->
object
;
parent
::
__construct
(
$controller
);
parent
::
__construct
(
$controller
);
}
}
public
function
executeCommand
()
public
function
executeCommand
()
{
{
global
$DIC
;
global
$DIC
;
$ilDB
=
$DIC
->
database
();
$ilDB
=
$DIC
->
database
();
$ilPluginAdmin
=
$DIC
[
'ilPluginAdmin'
];
$ilPluginAdmin
=
$DIC
[
'ilPluginAdmin'
];
$ilAccess
=
$DIC
->
access
();
$ilAccess
=
$DIC
->
access
();
if
(
$this
->
isAccessDenied
()
)
if
(
$this
->
isAccessDenied
())
{
{
$this
->
ilias
->
raiseError
(
$this
->
lng
->
txt
(
"permission_denied"
),
$this
->
ilias
->
error_obj
->
MESSAGE
);
$this
->
ilias
->
raiseError
(
$this
->
lng
->
txt
(
"permission_denied"
),
$this
->
ilias
->
error_obj
->
MESSAGE
);
}
}
$nextClass
=
$this
->
ctrl
->
getNextClass
();
$nextClass
=
$this
->
ctrl
->
getNextClass
();
$this
->
setSubTabs
(
$nextClass
);
$this
->
setSubTabs
(
$nextClass
);
$questionContainerId
=
$this
->
object
->
getId
();
$questionContainerId
=
$this
->
object
->
getId
();
switch
(
$nextClass
)
{
switch
(
$nextClass
)
case
'ilassquestionskillassignmentsgui'
:
{
$provider
=
new
ilQuestionSetPoolSkillQuestionListProvider
();
case
'ilassquestionskillassignmentsgui'
:
$provider
=
new
ilQuestionSetPoolSkillQuestionListProvider
();
$questionList
=
new
ilQuestionSetPoolSkillAssQuestionList
(
$ilDB
,
$this
->
lng
,
$ilPluginAdmin
);
$questionList
->
setQuestionInstanceTypeFilter
(
$this
->
getRequiredQuestionInstanceTypeFilter
());
$questionList
=
new
ilQuestionSetPoolSkillAssQuestionList
(
$ilDB
,
$this
->
lng
,
$ilPluginAdmin
);
$questionList
->
setParentObjId
(
$questionContainerId
);
$questionList
->
setQuestionInstanceTypeFilter
(
$this
->
getRequiredQuestionInstanceTypeFilter
());
$questionList
->
setProvider
(
$provider
);
$questionList
->
setParentObjId
(
$questionContainerId
);
$questionList
->
load
();
$questionList
->
setProvider
(
$provider
);
$questionList
->
load
();
$gui
=
new
ilAssQuestionSkillAssignmentsGUI
(
$this
->
ctrl
,
$ilAccess
,
$this
->
tpl
,
$this
->
lng
,
$ilDB
);
$gui
->
setAssignmentEditingEnabled
(
$this
->
isAssignmentEditingRequired
());
$gui
=
new
ilAssQuestionSkillAssignmentsGUI
(
$this
->
ctrl
,
$ilAccess
,
$this
->
tpl
,
$this
->
lng
,
$ilDB
);
$gui
->
setQuestionContainerId
(
$questionContainerId
);
$gui
->
setAssignmentEditingEnabled
(
$this
->
isAssignmentEditingRequired
());
$gui
->
setQuestionList
(
$questionList
);
$gui
->
setQuestionContainerId
(
$questionContainerId
);
$gui
->
setQuestionOrderSequence
(
$questionList
->
getOrderSequence
());
$gui
->
setQuestionList
(
$questionList
);
$this
->
ctrl
->
forwardCommand
(
$gui
);
$gui
->
setQuestionOrderSequence
(
$questionList
->
getOrderSequence
());
$this
->
ctrl
->
forwardCommand
(
$gui
);
break
;
case
'ilassquestionskillusagestablegui'
:
break
;
$gui
=
new
ilAssQuestionSkillUsagesTableGUI
(
$this
->
ctrl
,
$this
->
tpl
,
$this
->
lng
,
$ilDB
,
$this
->
object
->
getId
());
case
'ilassquestionskillusagestablegui'
:
$gui
=
new
ilAssQuestionSkillUsagesTableGUI
(
$this
->
ctrl
,
$this
->
tpl
,
$this
->
lng
,
$ilDB
,
$this
->
object
->
getId
());
$this
->
ctrl
->
forwardCommand
(
$gui
);
$this
->
ctrl
->
forwardCommand
(
$gui
);
break
;
}
break
;
}
}
}
private
function
getRequiredQuestionInstanceTypeFilter
()
{
private
function
getRequiredQuestionInstanceTypeFilter
()
return
ilAssQuestionList
::
QUESTION_INSTANCE_TYPE_DUPLICATES
;
{
}
return
ilAssQuestionList
::
QUESTION_INSTANCE_TYPE_DUPLICATES
;
}
protected
function
isAssignmentEditingRequired
()
{
protected
function
isAssignmentEditingRequired
()
return
true
;
{
}
return
true
;
}
protected
function
isAccessDenied
()
{
protected
function
isAccessDenied
()
if
(
!
$this
->
object
->
isSkillServiceEnabled
())
{
{
return
true
;
if
(
!
$this
->
object
->
isSkillServiceEnabled
())
}
{
return
true
;
if
(
!
ilObjQuestionSetPool
::
isSkillManagementGloballyActivated
())
{
}
return
true
;
}
if
(
!
ilObjQuestionSetPool
::
isSkillManagementGloballyActivated
())
{
return
false
;
return
true
;
}
}
/**
return
false
;
* Returns the current tab name
}
* return string
*/
/**
protected
function
getCurrentTab
()
* Returns the current tab name
{
* return string
return
'tst_tab_competences'
;
*/
}
protected
function
getCurrentTab
()
{
private
function
setSubTabs
(
$controllerClass
)
return
'tst_tab_competences'
;
{
}
$link
=
$this
->
ctrl
->
getLinkTargetByClass
(
'ilAssQuestionSkillAssignmentsGUI'
,
private
function
setSubTabs
(
$controllerClass
)
ilAssQuestionSkillAssignmentsGUI
::
CMD_SHOW_SKILL_QUEST_ASSIGNS
{
);
$link
=
$this
->
ctrl
->
getLinkTargetByClass
(
$this
->
tabs
->
addSubTab
(
'ilAssQuestionSkillAssignmentsGUI'
,
ilAssQuestionSkillAssignmentsGUI
::
CMD_SHOW_SKILL_QUEST_ASSIGNS
'ilassquestionskillassignmentsgui'
,
);
$this
->
lng
->
txt
(
'qpl_skl_sub_tab_quest_assign'
),
$this
->
tabs
->
addSubTab
(
$link
'ilassquestionskillassignmentsgui'
,
$this
->
lng
->
txt
(
'qpl_skl_sub_tab_quest_assign'
),
$link
);
);
$link
=
$this
->
ctrl
->
getLinkTargetByClass
(
$link
=
$this
->
ctrl
->
getLinkTargetByClass
(
'ilAssQuestionSkillUsagesTableGUI'
,
'ilAssQuestionSkillUsagesTableGUI'
,
ilAssQuestionSkillUsagesTableGUI
::
CMD_SHOW
ilAssQuestionSkillUsagesTableGUI
::
CMD_SHOW
);
);
$this
->
tabs
->
addSubTab
(
$this
->
tabs
->
addSubTab
(
'ilassquestionskillusagestablegui'
,
$this
->
lng
->
txt
(
'qpl_skl_sub_tab_usages'
),
$link
'ilassquestionskillusagestablegui'
,
$this
->
lng
->
txt
(
'qpl_skl_sub_tab_usages'
),
);
$link
$this
->
tabs
->
activateSubTab
(
$controllerClass
);
);
}
$this
->
tabs
->
activateSubTab
(
$controllerClass
);
/**
}
* @return array
*/
/**
protected
function
getRequirements
()
* @return array
{
*/
return
array
(
protected
function
getRequirements
()
'utils/class.ilQuestionSetPoolSkillAssQuestionList.php'
,
{
'providers/class.ilQuestionSetPoolSkillQuestionListProvider.php'
return
array
(
);
'utils/class.ilQuestionSetPoolSkillAssQuestionList.php'
,
}
'providers/class.ilQuestionSetPoolSkillQuestionListProvider.php'
);
}
}
}
\ No newline at end of file
classes/dispatcher/class.ilPluginDispatcher.php
View file @
381d5850
...
@@ -6,116 +6,118 @@
...
@@ -6,116 +6,118 @@
* Date: 23.09.13
* Date: 23.09.13
* Time: 14:32
* Time: 14:32
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class
ilPluginDispatcher
{
class
ilPluginDispatcher
{
/**
* @var ilPluginDispatcher
/**
*/
* @var ilPluginDispatcher
private
static
$_instance
=
null
;
*/
private
static
$_instance
=
null
;
/**
* @param ilObjectPluginGUI $baseController
/**
*
* @param ilObjectPluginGUI $baseController
* @return ilPluginDispatcher
*
*/
* @return ilPluginDispatcher
public
static
function
getInstance
(
$baseController
)
*/
{
public
static
function
getInstance
(
$baseController
)
if
(
self
::
$_instance
==
null
)
{
{
if
(
self
::
$_instance
==
null
)
{
self
::
$_instance
=
new
ilPluginDispatcher
(
$baseController
);
self
::
$_instance
=
new
ilPluginDispatcher
(
$baseController
);
}
}
return
self
::
$_instance
;
return
self
::
$_instance
;
}
}
/**
/**
* @param string $cmd
* @param string $cmd
*
*
* @return mixed
* @return mixed
*/
*/
public
function
dispatch
(
$cmd
)
public
function
dispatch
(
$cmd
)
{
{
$controller
=
$this
->
getController
(
$cmd
);
$controller
=
$this
->
getController
(
$cmd
);
$command
=
$this
->
getCommand
(
$cmd
);
$command
=
$this
->
getCommand
(
$cmd
);
if
(
!
is_object
(
$controller
))
if
(
!
is_object
(
$controller
))
{
{
$controller
=
$this
->
instantiateController
(
$controller
);
$controller
=
$this
->
instantiateController
(
$controller
);
}
}
$controller
->
$command
();
$controller
->
$command
();
}
}
/**
/**
* @param string $cmd
* @param string $cmd
*
*
* @return string|ilPluginControllerGUI
* @return string|ilPluginControllerGUI
*/
*/
protected
function
getController
(
$cmd
)
protected
function
getController
(
$cmd
)
{
{
$controller
=
substr
(
$cmd
,
0
,
strpos
(
$cmd
,
"."
));
$controller
=
substr
(
$cmd
,
0
,
strpos
(
$cmd
,
"."
));
if
(
$controller
==
""
)
{
if
(
$controller
==
""
)
$controller
=
$this
->
baseController
;
{
}
$controller
=
$this
->
baseController
;
}
return
$controller
;
}
return
$controller
;
}
/**
* @param string $cmd
/**
*
* @param string $cmd
* @return string
*
*/
* @return string
protected
function
getCommand
(
$cmd
)
*/
{
protected
function
getCommand
(
$cmd
)
$pos
=
strpos
(
$cmd
,
"."
);
{
$pos
=
strpos
(
$cmd
,
"."
);
if
(
$pos
>
0
)
{
$cmd
=
substr
(
$cmd
,
$pos
+
1
);
if
(
$pos
>
0
)
}
{
$cmd
=
substr
(
$cmd
,
$pos
+
1
);
return
$cmd
;
}
}
return
$cmd
;
/**
}
* @param string $controller
*
/**
* @return ilPluginControllerGUI
* @param string $controller
*/
*
protected
function
instantiateController
(
$controller
)
* @return ilPluginControllerGUI
{
*/
$this
->
requireController
(
$controller
);
protected
function
instantiateController
(
$controller
)
{
return
new
$controller
(
$this
->
baseController
);
$this
->
requireController
(
$controller
);
}
return
new
$controller
(
$this
->
baseController
);
/**
}
* @return string
*/
/**
protected
function
getControllerPath
()
* @return string
{
*/
$path
=
$this
->
baseController
->
plugin
->
getDirectory
()
.
protected
function
getControllerPath
()
DIRECTORY_SEPARATOR
.
{
"classes"
.
$path
=
$this
->
baseController
->
plugin
->
getDirectory
()
.
DIRECTORY_SEPARATOR
.
DIRECTORY_SEPARATOR
.
"controllers"
.
"classes"
.
DIRECTORY_SEPARATOR
;
DIRECTORY_SEPARATOR
.
"controllers"
.
return
$path
;
DIRECTORY_SEPARATOR
;
}
return
$path
;
/**
}
* @param $controller
*/
/**
protected
function
requireController
(
$controller
)
* @param $controller
{
*/
require_once
$this
->
getControllerPath
()
.
"class.
$controller
.php"
;
protected
function
requireController
(
$controller
)
}
{
require_once
$this
->
getControllerPath
()
.
"class.
$controller
.php"
;
private
function
__construct
(
$baseController
)
}
{
$this
->
baseController
=
$baseController
;
private
function
__construct
(
$baseController
){
$this
->
baseController
=
$baseController
;}
}
private
function
__clone
(){}
private
function
__clone
()
{
}
}
}
classes/models/abstract.ilPluginModel.php
View file @
381d5850
...
@@ -8,52 +8,49 @@ require_once "interface.ilPluginModelInterface.php";
...
@@ -8,52 +8,49 @@ require_once "interface.ilPluginModelInterface.php";
* Date: 21.11.13
* Date: 21.11.13
* Time: 11:17
* Time: 11:17
* @author Thomas Joußen <tjoussen@databay.de>
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract
class
ilPluginModel
implements
ilPluginModelInterface
abstract
class
ilPluginModel
implements
ilPluginModelInterface
{
{
/**
/**
* @var int
* @var int
*/
*/
protected
$id
;
protected
$id
;
public
function
__construct
(
$id
=
0
)
public
function
__construct
(
$id
=
0
)
{
{
$this
->
id
=
$id
;
$this
->
id
=
$id
;
}
}
//abstract protected function create();
//abstract protected function create();
//abstract protected function update();
//abstract protected function update();
/**
/**
* @param int $id
* @param int $id
*/
*/
public
function
setId
(
$id
)
public
function
setId
(
$id
)
{
{
$this
->
id
=
$id
;
$this
->
id
=
$id
;
}
}
/**
/**
* @return int
* @return int
*/
*/
public
function
getId
()
public
function
getId
()
{
{
return
$this
->
id
;
return
$this
->
id
;
}
}
/**
/**
* @return array
* @return array
*/
*/
public
function
toArray
()
public
function
toArray
()
{
{
$result
=
array
();
$result
=
array
();
foreach
(
$this
as
$key
=>
$value
)
foreach
(
$this
as
$key
=>
$value
)
{
{
$result
[
$key
]
=
$value
;
$result
[
$key
]
=
$value
;
}
}
return
$result
;
return
$result
;
}
}
}
}
\ No newline at end of file
Prev
1
2
3
4
5
6
7
Next