예제 #1
0
 /**
  * Runs correct method using action attribute
  */
 public function run()
 {
     $dh = $GLOBALS['dh'];
     if (!is_null($this->id)) {
         $this->_r = $dh->test_getNode($this->id);
         $this->setTipo();
         if (empty($this->_r) || AMATestDataHandler::isError($this->_r)) {
             return array('path' => translateFN('Si è verificato un errore'), 'status' => translateFN('Si è verificato un errore'), 'html' => $this->what . ' ' . translateFN('non trovato'));
         }
     }
     if (method_exists($this, $this->action)) {
         $array = array('status' => $this->status());
         return array_merge($array, $this->{$this->action}());
     }
 }
 /**
  * deletes a record
  */
 public function del()
 {
     $dh = $GLOBALS['dh'];
     $question =& $this->_r;
     $nodo = new Node($this->test['id_nodo_riferimento']);
     if (!AMATestDataHandler::isError($nodo)) {
         $path = $nodo->findPathFN();
     }
     if (isset($_POST['delete'])) {
         if ($_POST['delete'] == 1) {
             if (AMATestDataHandler::isError($dh->test_deleteNodeTest($this->id))) {
                 $html = sprintf(translateFN('Errore durante la cancellazione della %s'), $this->what);
             } else {
                 $get_topic = isset($_GET['topic']) ? '&topic=' . $_GET['topic'] : '';
                 redirect(MODULES_TEST_HTTP . '/index.php?id_test=' . $question['id_nodo_radice'] . $get_topic);
             }
         } else {
             $get_topic = isset($_GET['topic']) ? '&topic=' . $_GET['topic'] : '';
             redirect(MODULES_TEST_HTTP . '/index.php?id_test=' . $question['id_nodo_radice'] . $get_topic);
         }
     } else {
         require_once MODULES_TEST_PATH . '/include/forms/deleteFormTest.inc.php';
         $titolo = $question['titolo'];
         if (empty($titolo)) {
             $titolo = $question['nome'];
         }
         $titolo = $this->what . ' "' . $titolo . '"';
         $message = sprintf(translateFN('Stai per cancellare la %s e tutti i dati contenuti. Continuare?'), $titolo);
         $form = new DeleteFormTest($message);
         $html = $form->getHtml();
     }
     return array('html' => $html, 'path' => $path);
 }
예제 #3
0
 /**
  * deletes a test / survey node
  *
  * @global db $dh
  *
  * @return array an array with 'html' and 'path' key
  */
 public function del()
 {
     $dh = $GLOBALS['dh'];
     $test =& $this->_r;
     $nodo = new Node($test['id_nodo_riferimento']);
     if (!AMATestDataHandler::isError($nodo)) {
         $path = $nodo->findPathFN();
     }
     if (isset($_POST['delete'])) {
         if ($_POST['delete'] == 1) {
             if ($this->mode == ADA_TYPE_SURVEY) {
                 $courseId = explode('_', $nodo->id);
                 $courseId = $courseId[0];
                 $res = $dh->test_removeCourseTest($courseId, $this->id);
             }
             if (AMATestDataHandler::isError($dh->test_deleteNodeTest($this->id))) {
                 $html = sprintf(translateFN('Errore durante la cancellazione del %s'), $this->what);
             } else {
                 redirect(HTTP_ROOT_DIR . '/browsing/view.php?id_node=' . $nodo->parent_id);
             }
         } else {
             redirect(MODULES_TEST_HTTP . '/index.php?id_test=' . $this->id);
         }
     } else {
         require_once MODULES_TEST_PATH . '/include/forms/deleteFormTest.inc.php';
         $titolo = $test['titolo'];
         if (empty($titolo)) {
             $titolo = $test['nome'];
         }
         $titolo = $this->what . ' "' . $titolo . '"';
         $message = sprintf(translateFN('Stai per cancellare il %s e tutti i dati contenuti. Continuare?'), $titolo);
         $form = new DeleteFormTest($message);
         $html = $form->getHtml();
     }
     return array('html' => $html, 'path' => $path);
 }
예제 #4
0
파일: index.php 프로젝트: eguicciardi/ada
 * Performs basic controls before entering this module
 */
/*if isset $_GET['unload'] means that the system is closing test, so there is no need to save 
  the page in NavigationHistory  */
if (isset($_GET['unload'])) {
    $trackPageToNavigationHistory = false;
}
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once MODULES_TEST_PATH . '/config/config.inc.php';
require_once MODULES_TEST_PATH . '/include/init.inc.php';
//needed to promote AMADataHandler to AMATestDataHandler. $sess_selected_tester is already present in session
$GLOBALS['dh'] = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
$self = whoami();
$test = NodeTest::readTest($_GET['id_test']);
if (!AMATestDataHandler::isError($test)) {
    /**
     * If user has completed or has a terminated status for the instance,
     * redirect to $test->id_nodo_riferimento or its parent depending on 
     * ADA_REDIRECT_TO_TEST being true or false
     */
    if ($userObj->getType() == AMA_TYPE_STUDENT && isset($sess_id_course_instance) && intval($sess_id_course_instance) > 0 && in_array($userObj->get_student_status($userObj->getId(), $sess_id_course_instance), array(ADA_STATUS_COMPLETED, ADA_STATUS_TERMINATED))) {
        /**
         * @author giorgio 07/apr/2015
         *
         * if user has the terminated status for the course instance, redirect to view
         */
        $id_node = $sess_id_course . '_0';
        // if nothing better is found, redirect to course root node
        if (!ADA_REDIRECT_TO_TEST) {
            /**
예제 #5
0
require_once ROOT_DIR . '/include/module_init.inc.php';
//$self =  whoami();
$self = 'answers';
require_once ROOT_DIR . '/services/include/author_functions.inc.php';
$layout_dataAr['node_type'] = $self;
$online_users_listing_mode = 2;
$online_users = ADAGenericUser::get_online_usersFN($id_course_instance, $online_users_listing_mode);
require_once MODULES_TEST_PATH . '/config/config.inc.php';
require_once MODULES_TEST_PATH . '/include/init.inc.php';
//needed to promote AMADataHandler to AMATestDataHandler. $sess_selected_tester is already present in session
$GLOBALS['dh'] = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
require_once MODULES_TEST_PATH . '/include/management/answersManagementTest.inc.php';
$question = $dh->test_getNode($_GET['id_question']);
$management = new AnswersManagementTest($_GET['id_question']);
$form_return = $management->run();
if (!AMATestDataHandler::isError($question) && !empty($question)) {
    $get_topic = isset($_GET['topic']) ? '&topic=' . $_GET['topic'] : '';
    /*template fields for new menu*/
    $edit_question = 'action=mod&id_question=' . $question['id_nodo'] . $get_topic;
    $delete_question = 'action=del&id_question=' . $question['id_nodo'] . $get_topic;
}
// per la visualizzazione del contenuto della pagina
$banner = (include $root_dir . '/include/banner.inc.php');
$content_dataAr = array('head' => $head_form, 'banner' => $banner, 'path' => $form_return['path'], 'form' => $form_return['html'], 'status' => $form_return['status'], 'user_name' => $user_name, 'user_type' => $user_type, 'messages' => $user_messages->getHtml(), 'agenda' => $user_agenda->getHtml(), 'title' => $node_title, 'course_title' => $course_title, 'back' => $back, 'edit_question' => $edit_question, 'delete_question' => $delete_question);
$content_dataAr['notes'] = $other_node_data['notes'];
$content_dataAr['personal'] = $other_node_data['private_notes'];
if ($reg_enabled) {
    $content_dataAr['add_bookmark'] = $add_bookmark;
} else {
    $content_dataAr['add_bookmark'] = "";
}
예제 #6
0
 /**
  * Function that executes answer logic (add / mod)
  *
  * @global db $dh
  * 
  * @return string
  */
 protected function action()
 {
     $dh = $GLOBALS['dh'];
     $tmp = $dh->test_getNodesByParent($this->question['id_nodo']);
     $risposte = array();
     if (!empty($tmp)) {
         foreach ($tmp as $k => $v) {
             $risposte[] = array('other_answer' => $v['tipo'][1], 'answer' => $v['testo'], 'value' => $v['correttezza'], 'case_sensitive' => $v['tipo'][2], 'record' => $v['id_nodo'], 'ordine' => $v['ordine']);
         }
     }
     $case_sensitive = false;
     $open_cloze = array(ADA_NORMAL_TEST_SIMPLICITY, ADA_MEDIUM_TEST_SIMPLICITY);
     if ($this->question['tipo'][1] == ADA_OPEN_AUTOMATIC_TEST_TYPE || $this->question['tipo'][1] == ADA_CLOZE_TEST_TYPE && in_array($this->question['tipo'][3], $open_cloze)) {
         $case_sensitive = true;
     }
     $open_answer = false;
     if (in_array($this->question['tipo'][1], array(ADA_STANDARD_TEST_TYPE, ADA_MULTIPLE_CHECK_TEST_TYPE))) {
         $open_answer = true;
     }
     $form = $this->instantiateObject($risposte, $this->question, $case_sensitive, $open_answer);
     if ($_POST) {
         //hack to capture ajax calls from ADA_CLOZE_TEST_TYPE -> ADA_MULTIPLE_TEST_SIMPLICITY
         if ($this->question['tipo'][3] == ADA_MULTIPLE_TEST_SIMPLICITY) {
             require_once MODULES_TEST_PATH . '/include/nodeTest.class.inc.php';
             $questionObj = nodeTest::readNode($this->question['id_nodo']);
             $questionObj->updateAnswerTable($_POST[QuestionMultipleClozeTest::postVariable]);
         }
         if ($form->isValid()) {
             //crea nuove risposte con i dati del form
             $post = array();
             foreach ($_POST['answer'] as $k => $v) {
                 $post[] = array('answer' => $_POST['answer'][$k], 'value' => intval($_POST['value'][$k]), 'case_sensitive' => $_POST['case_sensitive'][$k] == 1 ? true : false, 'other_answer' => $_POST['other_answer'][$k] == 1 ? true : false, 'record' => $_POST['record'][$k], 'ordine' => $_POST['ordine'][$k]);
             }
             $result = true;
             $tipo = ADA_LEAF_ANSWER . ADA_NO_OPEN_TEST_ANSWER . ADA_CASE_SENSITIVE_TEST . '000';
             foreach ($post as $k => $v) {
                 $t = $tipo;
                 $t[1] = $v['other_answer'] ? ADA_OPEN_TEST_ANSWER : ADA_NO_OPEN_TEST_ANSWER;
                 $t[2] = $v['case_sensitive'] ? ADA_CASE_INSENSITIVE_TEST : ADA_CASE_SENSITIVE_TEST;
                 $data = array('id_corso' => $this->test['id_corso'], 'id_utente' => $_SESSION['sess_id_user'], 'id_istanza' => $this->test['id_istanza'], 'nome' => $v['answer'], 'testo' => Node::prepareInternalLinkMediaForDatabase($v['answer']), 'correttezza' => $v['value'], 'tipo' => $t, 'id_nodo_parent' => $this->question['id_nodo'], 'id_nodo_radice' => $this->test['id_nodo'], 'ordine' => $v['ordine'] ? $v['ordine'] : $k + 1);
                 if (intval($v['record']) > 0) {
                     $res = $dh->test_updateNode(intval($v['record']), $data);
                 } else {
                     $res = $dh->test_addNode($data);
                 }
                 if (AMATestDataHandler::isError($res)) {
                     $result = false;
                     $html = translateFN('Errore durante la creazione delle risposte');
                     break;
                 }
                 unset($data);
             }
             if ($result) {
                 $get_topic = isset($_GET['topic']) ? '&topic=' . $_GET['topic'] : '';
                 if ($_POST['return'] == 'here') {
                     redirect(MODULES_TEST_HTTP . '/edit_answers.php?id_question=' . $this->question['id_nodo'] . $get_topic);
                 } else {
                     redirect(MODULES_TEST_HTTP . '/index.php?id_test=' . $this->test['id_nodo'] . $get_topic . '#liQuestion' . $this->question['id_nodo']);
                 }
             }
         }
     } else {
         $html = $form->getHtml();
         $div = CDOMElement::create('div', 'id:insertImage,class:hide');
         $div->setAttribute('title', translateFN('Inserisci Immagine'));
         $div->setAttribute('style', 'text-align:right;');
         $labelUrl = CDOMElement::create('label', 'for:inputUrl');
         $labelUrl->addChild(new CText(translateFN('Url') . ':'));
         $inputUrl = CDOMElement::create('text', 'id:inputUrl');
         $div->addChild($labelUrl);
         $div->addChild($inputUrl);
         $div->addChild(new CText('<br />'));
         $labelTitle = CDOMElement::create('label', 'for:inputTitle');
         $labelTitle->addChild(new CText(translateFN('Titolo') . ':'));
         $inputTitle = CDOMElement::create('text', 'id:inputTitle');
         $div->addChild($labelTitle);
         $div->addChild($inputTitle);
         $div->addChild(new CText('<br />'));
         $labelRadio = CDOMElement::create('label');
         $labelRadio->addChild(new CText(translateFN('Permetti zoom') . ':'));
         $labelYes = CDOMElement::create('label', 'for:radioPopupYes');
         $labelYes->addChild(new CText(translateFN('Si')));
         $labelNo = CDOMElement::create('label', 'for:radioPopupNo');
         $labelNo->addChild(new CText(translateFN('No')));
         $radioYes = CDOMElement::create('radio', 'id:radioPopupYes,name:radioPopup');
         $radioYes->setAttribute('checked', '');
         $radioNo = CDOMElement::create('radio', 'id:radioPopupNo,name:radioPopup');
         $div->addChild($labelRadio);
         $div->addChild($radioYes);
         $div->addChild($labelYes);
         $div->addChild($radioNo);
         $div->addChild($labelNo);
         $div->addChild(new CText('<br />'));
         $labelWidth = CDOMElement::create('label', 'for:inputWidth');
         $labelWidth->addChild(new CText(translateFN('Larghezza') . ':'));
         $inputWidth = CDOMElement::create('text', 'id:inputWidth,size:4,value:75');
         $labelHeight = CDOMElement::create('label', 'for:inputHeight');
         $labelHeight->addChild(new CText(translateFN('Altezza') . ':'));
         $inputHeight = CDOMElement::create('text', 'id:inputHeight,size:4,value:75');
         $div->addChild($labelWidth);
         $div->addChild($inputWidth);
         $div->addChild($labelHeight);
         $div->addChild($inputHeight);
         $html .= $div->getHtml();
     }
     return $html;
 }