示例#1
0
 /**
  *
  * @param Node $n The node for which calculate the previous and next node link
  * @param array $params
  */
 public function __construct(Node $n, $params = array())
 {
     $this->_currentNode = $n->id;
     $prevId = DataValidator::validate_node_id($params['prevId']);
     if ($prevId !== false) {
         $this->_previousNode = $prevId;
     } else {
         $this->findPreviousNode($n, $params['userLevel']);
     }
     $nextId = DataValidator::validate_node_id($params['nextId']);
     if ($nextId !== false) {
         $this->_nextNode = $nextId;
     } else {
         $this->findNextNode($n, $params['userLevel']);
     }
     /**
      * @author giorgio 08/ott/2013
      * check if this is a node wich has been generated when creating a test.
      * If it is, next node is the first topic of the test.
      * BUT, I'll pass the computed $this->_nextNode to give a callBack point
      * to be used when user is in the last topic of the test.
      */
     if (MODULES_TEST && strpos($n->type, (string) constant('ADA_PERSONAL_EXERCISE_TYPE')) === 0) {
         if (isset($GLOBALS['dh'])) {
             $GLOBALS['dh']->disconnect();
         }
         $test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
         $res = $test_db->test_getNodes(array('id_nodo_riferimento' => $n->id));
         if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) {
             $node = array_shift($res);
             $this->_nextTestNode = $node['id_nodo'];
         }
         /**
          * @author giorgio 06/nov/2013
          * must check if computed $this->_previousNode points to a test
          * and get last topic if it does.
          */
         if (!is_null($this->_previousNode)) {
             $res = $test_db->test_getNodes(array('id_nodo_riferimento' => $this->_previousNode));
         } else {
             $res = array();
         }
         if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) {
             $node = array_shift($res);
             $test = NodeTest::readTest($node['id_nodo'], $test_db);
             $this->_prevTestTopic = count($test->_children);
             $this->_prevTestNode = $node['id_nodo'];
         }
         $test_db->disconnect();
     }
 }
示例#2
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) {
 /**
  * function that return a specific history test
  *
  * @global db $dh
  *
  * @return array an array composed of 'html', 'path' and 'title' keys
  */
 protected function view_history_tests()
 {
     $dh = $GLOBALS['dh'];
     $test = NodeTest::readTest($this->test['id_nodo']);
     if ($dh->isError($test)) {
         $html = sprintf(translateFN('%s non trovato'), $this->singolare);
     } else {
         $test->run($this->history_test['id_history_test'], true);
         $html = $test->render(true);
     }
     $path = '<a href="' . $this->filepath . '?op=' . $this->what . '&id_course_instance=' . $this->course_instanceObj->id . '&id_course=' . $this->courseObj->id . '">' . translateFN('Valutazione') . ' ' . ucfirst($this->plurale) . '</a> &gt; <a href="' . $this->filepath . '?op=' . $this->what . '&id_course_instance=' . $this->course_instanceObj->id . '&id_course=' . $this->courseObj->id . '&id_student=' . $this->history_test['id_utente'] . '">' . $this->student['cognome'] . ' ' . $this->student['nome'] . '</a> &gt; <a href="' . $this->filepath . '?op=' . $this->what . '&id_course_instance=' . $this->course_instanceObj->id . '&id_course=' . $this->courseObj->id . '&id_student=' . $this->history_test['id_utente'] . '&id_test=' . $this->test['id_nodo'] . '">' . $this->test['titolo'] . '</a> &gt; ' . translateFN('Tentativo') . ' #' . $this->history_test['id_history_test'];
     return array('html' => $html, 'path' => $path, 'title' => translateFN('Valutazione') . ' ' . ucfirst($this->plurale));
 }