Esempio n. 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();
     }
 }
Esempio n. 2
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}());
     }
 }
Esempio n. 3
0
/**
 * Performs basic controls before entering this module
 */
$neededObjAr = array(AMA_TYPE_AUTHOR => array('layout', 'node', 'course', 'course_instance'));
require_once ROOT_DIR . '/include/module_init.inc.php';
//$self =  whoami();
$self = 'form';
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/management/managementTest.inc.php';
require_once MODULES_TEST_PATH . '/include/management/rootManagementTest.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']));
/*
 * Generazione dei form per l'inserimento dell'esercizio.
 * 
*/
require_once MODULES_TEST_PATH . '/include/management/questionManagementTest.inc.php';
$management = new QuestionManagementTest($_GET['action'], $_GET['id_question'], $_GET['id_test']);
$form_return = $management->run();
// 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);
$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 {
 /**
  * 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);
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
 * 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) {
            /**
Esempio n. 7
0
 function get_class_reportFN($id_course, $order = "", $index_att = "", $type = 'HTML')
 {
     $dh = $GLOBALS['dh'];
     $http_root_dir = $GLOBALS['http_root_dir'];
     $debug = isset($GLOBALS['debug']) ? $GLOBALS['debug'] : null;
     $npar = isset($GLOBALS['npar']) ? $GLOBALS['npar'] : null;
     $hpar = isset($GLOBALS['hpar']) ? $GLOBALS['hpar'] : null;
     $mpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $epar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     $bpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $cpar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     // default parameters for activity index are in configuration file
     if (empty($npar)) {
         $npar = NOTE_PAR;
     }
     // notes
     if (!isset($hpar)) {
         $hpar = HIST_PAR;
     }
     // history
     if (!isset($mpar)) {
         $mpar = MSG_PAR;
     }
     //messages
     if (!isset($epar)) {
         $epar = EXE_PAR;
     }
     // exercises
     if (!isset($bpar)) {
         $bpar = defined('BKM_PAR') ? BKM_PAR : null;
     }
     //bookmarks
     if (!isset($cpar)) {
         $cpar = defined('CHA_PAR') ? CHA_PAR : null;
     }
     // chat
     $student_list_ar = $this->student_list;
     $id_instance = $this->id;
     if ($student_list_ar != 0) {
         $info_course = $dh->get_course($id_course);
         // Get title course
         if (AMA_DataHandler::isError($info_course)) {
             $msg = $info_course->getMessage();
             return $msg;
         }
         $course_title = $info_course['titolo'];
         $instance_course_ha = $dh->course_instance_get($id_instance);
         // Get the instance courses data
         if (AMA_DataHandler::isError($instance_course_ha)) {
             $msg = $instance_course_ha->getMessage();
             return $msg;
         }
         $start_date = AMA_DataHandler::ts_to_date($instance_course_ha['data_inizio'], ADA_DATE_FORMAT);
         $num_student = -1;
         $tot_history_count = 0;
         $tot_exercises_score = 0;
         $tot_exercises_number = 0;
         $tot_added_notes = 0;
         $tot_read_notes = 0;
         $tot_message_count = 0;
         $tot_message_count_in = 0;
         $tot_message_count_out = 0;
         $tot_bookmarks_count = 0;
         $tot_chatlines_count_out = 0;
         $tot_index = 0;
         $tot_level = 0;
         /**
          * @author giorgio 27/ott/2014
          * 
          * change to:
          * $report_generation_TS = time();
          * 
          * to have full date & time generation of report
          * but be warned that table log_classi may grow A LOT!
          */
         $report_generation_TS = dt2tsFN(today_dateFN());
         if (MODULES_TEST) {
             $tot_exercises_score_test = 0;
             $tot_exercises_number_test = 0;
             $tot_exercises_score_survey = 0;
             $tot_exercises_number_survey = 0;
             $test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
             $test_score = $test_db->getStudentsScores($id_course, $id_instance);
         }
         foreach ($student_list_ar as $one_student) {
             $num_student++;
             //starts with 0
             $id_student = $one_student['id_utente_studente'];
             $student_level = $one_student['livello'];
             $status_student = $one_student['status'];
             $dati['id'] = $id_student;
             $dati['level'] = $student_level;
             $ymdhms = today_dateFN();
             $utime = dt2tsFN($ymdhms);
             $dati['date'] = $report_generation_TS;
             if (!empty($id_student) and ($status_student == ADA_STATUS_SUBSCRIBED or $status_student == ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED)) {
                 $studentObj = MultiPort::findUser($id_student);
                 //new Student($id_student,$id_instance);
                 if ($studentObj->full != 0) {
                     //==0) {
                     $err_msg = $studentObj->error_msg;
                 } else {
                     if ($studentObj instanceof ADAPractitioner) {
                         /**
                          * @author giorgio 14/apr/2015
                          * 
                          * If student is actually a tutor, build a new student
                          * object for history and evaluation purposes
                          */
                         $studentObj = $studentObj->toStudent();
                     }
                     $student_name = $studentObj->getFullname();
                     //$studentObj->nome." ".$studentObj->cognome;
                     // vito
                     $studentObj->set_course_instance_for_history($id_instance);
                     //$studentObj->history->setCourseInstance($id_instance);
                     $studentObj->history->setCourse($id_course);
                     $studentObj->get_exercise_dataFN($id_instance, $id_student);
                     $st_exercise_dataAr = $studentObj->user_ex_historyAr;
                     $st_score = 0;
                     $st_exer_number = 0;
                     if (is_array($st_exercise_dataAr)) {
                         foreach ($st_exercise_dataAr as $exercise) {
                             $st_score += $exercise[7];
                             $st_exer_number++;
                         }
                     }
                     $dati['exercises'] = $st_exer_number;
                     $dati['score'] = $st_score;
                     if (MODULES_TEST) {
                         $st_score_test = isset($test_score[$id_student]['score_test']) ? $test_score[$id_student]['score_test'] : 0;
                         $st_exer_number_test = isset($test_score[$id_student]['max_score_test']) ? $test_score[$id_student]['max_score_test'] : 0;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $dati['score_test'] = $st_score_test;
                         $st_score_survey = isset($test_score[$id_student]['score_survey']) ? $test_score[$id_student]['score_survey'] : 0;
                         $st_exer_number_survey = isset($test_score[$id_student]['max_score_survey']) ? $test_score[$id_student]['max_score_survey'] : 0;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                         $dati['score_survey'] = $st_score_survey;
                     }
                     $sub_courses = $dh->get_subscription($id_student, $id_instance);
                     if ($sub_courses['tipo'] == ADA_STATUS_SUBSCRIBED) {
                         $out_fields_ar = array('nome', 'titolo', 'id_istanza', 'data_creazione');
                         $clause = "tipo = '" . ADA_NOTE_TYPE . "' AND id_utente = '{$id_student}'";
                         $nodes = $dh->find_course_nodes_list($out_fields_ar, $clause, $id_course);
                         $added_nodes_count = count($nodes);
                         $added_nodes_count_norm = str_pad($added_nodes_count, 5, "0", STR_PAD_LEFT);
                         $added_notes = "<!-- {$added_nodes_count_norm} --><a href={$http_root_dir}/tutor/tutor.php?op=student_notes&id_instance={$id_instance}&id_student={$id_student}>" . $added_nodes_count . "</a>";
                         //$added_notes = $added_nodes_count;
                     } else {
                         $added_notes = "<!-- 0 -->-";
                     }
                     $read_notes_count = $studentObj->total_visited_notesFN($id_student, $id_course);
                     if ($read_notes_count > 0) {
                         $read_nodes_count_norm = str_pad($read_notes_count, 5, "0", STR_PAD_LEFT);
                         $read_notes = "<!-- {$read_nodes_count_norm} -->{$read_notes_count}";
                     } else {
                         $read_notes = "<!-- 0 -->-";
                     }
                     $st_history_count = "0";
                     $debug = 0;
                     $st_history_count = $studentObj->total_visited_nodesFN($id_student, ADA_LEAF_TYPE);
                     // vito, 11 mar 2009. Ottiene solo il numero di visite a nodi di tipo foglia.
                     // vogliamo anche il numero di visite a nodi di tipo gruppo.
                     $st_history_count += $studentObj->total_visited_nodesFN($id_student, ADA_GROUP_TYPE);
                     $dati['visits'] = $st_history_count;
                     $st_name = "<!-- {$student_name} --><a href=" . $http_root_dir . "/tutor/tutor.php?op=zoom_student&id_student=" . $id_student;
                     $st_name .= "&id_course=" . $id_course . "&id_instance=" . $id_instance . ">";
                     $st_name .= $student_name . "</a>";
                     $st_history_count_norm = str_pad($st_history_count, 5, "0", STR_PAD_LEFT);
                     $st_history = "<!-- {$st_history_count_norm} --><a href=" . $http_root_dir . "/tutor/tutor_history.php?id_student=" . $id_student;
                     $st_history .= "&id_course=" . $id_course . "&id_course_instance=" . $id_instance . ">";
                     $st_history .= $st_history_count . "</a>";
                     $st_history_last_access = $studentObj->get_last_accessFN($id_instance, "T");
                     //$dati['date'] = $st_history_last_access;
                     $st_score_norm = str_pad($st_score, 5, "0", STR_PAD_LEFT);
                     $st_exercises = "<!-- {$st_score_norm} --><a href=" . $http_root_dir . "/tutor/tutor_exercise.php?id_student=" . $id_student;
                     $st_exercises .= "&id_course_instance=" . $id_instance . " class='dontwrap'>";
                     $st_exercises .= $st_score . " " . translateFN("su") . " " . $st_exer_number * ADA_MAX_SCORE . "</a>";
                     if (MODULES_TEST) {
                         $st_score_norm_test = str_pad($st_score_test, 5, "0", STR_PAD_LEFT);
                         $st_exercises_test = '<!-- ' . $st_score_norm_test . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=test&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_test . ' ' . translateFN('su') . ' ' . $st_exer_number_test . '</a>';
                         $st_score_norm_survey = str_pad($st_score_survey, 5, "0", STR_PAD_LEFT);
                         $st_exercises_survey = '<!-- ' . $st_score_norm_survey . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=survey&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_survey . ' ' . translateFN('su') . ' ' . $st_exer_number_survey . '</a>';
                     }
                     // user data
                     $dati_stude[$num_student]['id'] = $id_student;
                     $dati_stude[$num_student]['student'] = $st_name;
                     // history
                     $dati_stude[$num_student]['history'] = $st_history;
                     $tot_history_count += $st_history_count;
                     if ($st_history_last_access != "-") {
                         $dati_stude[$num_student]['last_access'] = "<a href=\"{$http_root_dir}/tutor/tutor_history_details.php?period=1&id_student={$id_student}&id_course_instance={$id_instance}&id_course={$id_course}\">" . $st_history_last_access . "</a>";
                         $dati['last_access'] = $studentObj->get_last_accessFN($id_instance, 'UT');
                     } else {
                         $dati_stude[$num_student]['last_access'] = $st_history_last_access;
                         $dati['last_access'] = null;
                     }
                     // exercises
                     $tot_exercises_score += $st_score;
                     $tot_exercises_number += $st_exer_number;
                     $dati_stude[$num_student]['exercises'] = $st_exercises;
                     $dati['exercises'] = $st_exer_number;
                     if (MODULES_TEST) {
                         $tot_exercises_score_test += $st_score_test;
                         $tot_exercises_number_test += $st_exer_number_test;
                         $dati_stude[$num_student]['exercises_test'] = $st_exercises_test;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $tot_exercises_score_survey += $st_score_survey;
                         $tot_exercises_number_survey += $st_exer_number_survey;
                         $dati_stude[$num_student]['exercises_survey'] = $st_exercises_survey;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                     }
                     // forum notes written
                     $dati_stude[$num_student]['added_notes'] = $added_notes;
                     $tot_added_notes += $added_nodes_count;
                     $dati['added_notes'] = $added_nodes_count;
                     // forum notes read
                     $dati_stude[$num_student]['read_notes'] = $read_notes;
                     $tot_read_notes += $read_notes_count;
                     $dati['read_notes'] = $read_notes_count;
                     // messages
                     //$mh = new MessageHandler("%d/%m/%Y - %H:%M:%S");
                     $mh = MessageHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
                     $sort_field = "data_ora desc";
                     // messages received
                     $msgs_ha = $mh->get_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_in'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_in'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_in += $user_message_count;
                     $dati['msg_in'] = $user_message_count;
                     // messages sent
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_out'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_out'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_out += $user_message_count;
                     $dati['msg_out'] = $user_message_count;
                     //chat..
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_CHAT, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['chat'] = "-";
                     } else {
                         $chatlines_count_out = count($msgs_ha);
                         $dati_stude[$num_student]['chat'] = $chatlines_count_out;
                         $tot_chatlines_count_out += $chatlines_count_out;
                     }
                     $tot_chatlines_count_out += $chatlines_count_out;
                     $dati['chat'] = $chatlines_count_out;
                     //bookmarks..
                     include_once 'bookmark_class.inc.php';
                     $bookmarks_count = count(Bookmark::get_bookmarks($id_student));
                     $dati_stude[$num_student]['bookmarks'] = $bookmarks_count;
                     $tot_bookmarks_count += $bookmarks_count;
                     $dati['bookmarks'] = $bookmarks_count;
                     // activity index
                     if (empty($index_att)) {
                         // parametro passato alla funzione
                         if (empty($GLOBALS['index_activity_expression'])) {
                             //
                             if (!isset($bcount)) {
                                 $bcount = 1;
                             }
                             $index = $added_nodes_count * $npar + $st_history_count * $hpar + $user_message_count * $mpar + $st_exer_number * $epar + $bookmarks_count * $bcount + $chatlines_count_out * $cpar;
                         } else {
                             $index = eval($GLOBALS['index_activity_expression']);
                         }
                     } else {
                         $index = eval($index_att);
                     }
                     $dati_stude[$num_student]['index'] = $index;
                     //echo $index;
                     $tot_index += $index;
                     $dati['index'] = $index;
                     // level
                     $tot_level += $student_level;
                     $dati_stude[$num_student]['level'] = '<span id="studentLevel_' . $id_student . '">' . $student_level . '</span>';
                     $forceUpdate = false;
                     $linksHtml = $this->generateLevelButtons($id_student, $forceUpdate);
                     $dati_stude[$num_student]['level_plus'] = !is_null($linksHtml) ? $linksHtml : '-';
                     // inserting a row in table log_classi
                     $this->log_class_data($id_course, $id_instance, $dati);
                 }
             }
         }
         // average data
         $tot_students = $num_student + 1;
         $av_history = $tot_history_count / $tot_students;
         $av_exercises = $tot_exercises_score / $tot_students . " " . translateFN("su") . " " . floor($tot_exercises_number * ADA_MAX_SCORE / $tot_students);
         if (MODULES_TEST) {
             $av_exercises_test = round($tot_exercises_score_test / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_test / $tot_students);
             $av_exercises_survey = round($tot_exercises_score_survey / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_survey / $tot_students);
         }
         $av_added_notes = $tot_added_notes / $tot_students;
         $av_read_notes = $tot_read_notes / $tot_students;
         $av_message_count_in = $tot_message_count_in / $tot_students;
         $av_message_count_out = $tot_message_count_out / $tot_students;
         $av_chat_count_out = $tot_chatlines_count_out / $tot_students;
         $av_bookmarks_count = $tot_bookmarks_count / $tot_students;
         $av_index = $tot_index / $tot_students;
         $av_level = $tot_level / $tot_students;
         $av_student = $tot_students;
         $dati_stude[$av_student]['id'] = "-";
         $dati_stude[$av_student]['student'] = translateFN("Media");
         $dati_stude[$av_student]['history'] = round($av_history, 2);
         $dati_stude[$av_student]['last_access'] = "-";
         $dati_stude[$av_student]['exercises'] = '<span class="dontwrap">' . $av_exercises . '</span>';
         if (MODULES_TEST) {
             $dati_stude[$av_student]['exercises_test'] = '<span class="dontwrap">' . $av_exercises_test . '</span>';
             $dati_stude[$av_student]['exercises_survey'] = '<span class="dontwrap">' . $av_exercises_survey . '</span>';
         }
         $dati_stude[$av_student]['added_notes'] = round($av_added_notes, 2);
         $dati_stude[$av_student]['read_notes'] = round($av_read_notes, 2);
         $dati_stude[$av_student]['message_count_in'] = round($av_message_count_in, 2);
         $dati_stude[$av_student]['message_count_out'] = round($av_message_count_out, 2);
         $dati_stude[$av_student]['chat'] = round($av_chat_count_out, 2);
         $dati_stude[$av_student]['bookmarks'] = round($av_bookmarks_count, 2);
         $dati_stude[$av_student]['index'] = round($av_index, 2);
         $dati_stude[$av_student]['level'] = '<span id="averageLevel">' . round($av_level, 2) . '</span>';
         $dati_stude[$av_student]['level_plus'] = "-";
         // @author giorgio 16/mag/2013
         // was $dati_stude[$av_student]['level_minus'] = "-";
         // $dati_stude[$av_student]['level_less'] = "-";
         if (!empty($order)) {
             //var_dump($dati_stude);
             $dati_stude = masort($dati_stude, $order, 1, SORT_NUMERIC);
         }
         // TABLE LABELS
         $table_labels[0] = $this->generate_class_report_header();
         /**
          * @author giorgio 16/mag/2013
          * 
          * unset the unwanted columns data and labels. unwanted cols are defined in config/config_class_report.inc.php
          */
         $arrayToUse = 'report' . $type . 'ColArray';
         $this->clean_class_reportFN($arrayToUse, $table_labels, $dati_stude);
         return array('report_generation_date' => $report_generation_TS) + array_merge($table_labels, $dati_stude);
     } else {
         return null;
     }
 }
Esempio n. 8
0
 /**
  * builds the xml object with the passed TEST node and all of its children
  *
  * @param int $course_id the id of the course to export
  * @param string $nodeId the id of the node to export, in ADA format (e.g. xxx_yyy)
  * @param DOMDocument $domtree the XML object to append nodes to
  * @param AMATestDataHandler $dh_test the dataHandler used to retreive datas
  * @param DOMElement $XMLElement the element to append nodes to
  *
  * @access public
  */
 public function exportTestNodeChildren($course_id, $nodeId, &$domtree, &$dh_test, $XMLElement = null)
 {
     static $count = 0;
     $nodeInfo = $dh_test->test_getNode($nodeId);
     if (!AMA_DB::isError($nodeInfo)) {
         if (function_exists('memory_get_usage')) {
             $mem = memory_get_usage();
         } else {
             $mem = 'N/A';
         }
         $this->_logMessage(__METHOD__ . ' Exporting ADA TEST Node num. ' . $count++ . ' nodeId=' . $nodeId . ' memory_get_usage()=' . $mem);
         // 			$XMLElement =& $XMLElement->appendChild(self::buildTestXML($domtree, $nodeInfo));
         if (is_null($XMLElement)) {
             $this->testNodeXMLElement->appendChild(self::buildTestXML($domtree, $nodeInfo));
         } else {
             $XMLElement = $XMLElement->appendChild(self::buildTestXML($domtree, $nodeInfo));
         }
         $childrenNodesArr = $dh_test->test_getNodesByParent($nodeId, null, array('id_istanza' => 0));
         foreach ($childrenNodesArr as $childNode) {
             $this->exportTestNodeChildren($course_id, $childNode['id_nodo'], $domtree, $dh_test);
         }
     }
 }
Esempio n. 9
0
 /**
  * runs the actual import
  *
  * @return Ambigous AMA_Error on error |array recpArray on success
  *
  * @access public
  */
 public function runImport()
 {
     $count = 0;
     $zipFileName = ADA_UPLOAD_PATH . $this->_importFile;
     $zip = new ZipArchive();
     if ($zip->open($zipFileName)) {
         $XMLfile = $zip->getFromName(XML_EXPORT_FILENAME);
         $XMLObj = new SimpleXMLElement($XMLfile);
         $this->_progressResetValues(substr_count($XMLfile, '</nodo>') + substr_count($XMLfile, '<survey ') + substr_count($XMLfile, '</test>'));
         foreach ($XMLObj as $objName => $course) {
             // first level object must be 'modello_corso'
             if ($objName === 'modello_corso') {
                 $count++;
                 // get the attributes as local vars
                 // e.g. attributed exportedId=107 becomes
                 // a local var named $exportedId, initialized to 107 as a string
                 foreach ($course->attributes() as $name => $val) {
                     ${$name} = (string) $val;
                 }
                 // as a result of this foreach we have a php var for any XML object attribute
                 // var_dump ($exportedId); should neither raise an error nor dump a null value.
                 $this->_courseOldID = $exportedId;
                 /**
                  * sets the log file name that will be used from now on!
                  */
                 $this->_logFile = MODULES_IMPEXPORT_LOGDIR . "import-" . $this->_courseOldID . "_" . date('d-m-Y_His') . ".log";
                 $this->_logMessage('**** IMPORT STARTED at ' . date('d/m/Y H:i:s') . '(timestamp: ' . $this->_dh->date_to_ts('now') . ') ****');
                 $this->_progressSetTitle((string) $course->titolo);
                 /**
                  * ADDS THE COURSE TO THE APPROPIATE TABLES
                  */
                 if (!self::$_DEBUG) {
                     if (is_null($this->_selectedCourseID)) {
                         $courseNewID = $this->_add_course($course);
                         /**
                          * this is a new course you want, first node
                          * is going to be the root of the course (i.e. zero)
                          * Setting selectedNodeID will make the running code
                          * do the trick!
                          */
                         $this->_selectedNodeID = null;
                     } else {
                         $courseNewID = $this->_selectedCourseID;
                     }
                     if (AMA_DB::isError($courseNewID)) {
                         return $courseNewID;
                     }
                 } else {
                     $courseNewID = 123 * $count;
                 }
                 /**
                  * NOW ADD  NODES, TESTS AND SURVEYS
                  */
                 foreach ($this->_specialNodes as $groupName) {
                     $method = '_import' . ucfirst(strtolower($groupName));
                     $this->_logMessage(__METHOD__ . ' Saving ' . $groupName . ' by calling method: ' . $method);
                     if ($groupName === 'tests' || $groupName === 'surveys') {
                         // prepares the mapping array by emptying it
                         if ($groupName === 'tests') {
                             if (isset($this->_testNodeIDMapping)) {
                                 unset($this->_testNodeIDMapping);
                             }
                             $this->_testNodeIDMapping = array();
                         }
                         // prepares the test data handler
                         $this->_dh->disconnect();
                         $this->_dh = AMATestDataHandler::instance(MultiPort::getDSN($this->_selectedTester));
                     }
                     /**
                      * calls a method named _import<groupName> foreach special node.
                      * e.g. for nodes it will call _importNodi, for tests _importTests....
                      */
                     if (method_exists($this, $method) && !empty($course->{$groupName})) {
                         $specialVal = $this->{$method}($course->{$groupName}, $courseNewID);
                         // if it's an error return it right away
                         if (AMA_DB::isError($specialVal)) {
                             $this->_logMessage(__METHOD__ . ' Error saving ' . $groupName . '. DB returned the following:');
                             $this->_logMessage(print_r($specialVal, true));
                             return $specialVal;
                         } else {
                             $this->_logMessage(__METHOD__ . ' Saving ' . $groupName . ' successfully ended');
                             $this->_recapArray[$courseNewID][$groupName] = $specialVal;
                         }
                     }
                     if ($groupName === 'nodi') {
                         // save all the links and clean the array
                         $this->_saveLinks($courseNewID);
                         // after links have been saved, update inernal links pseudo html in proper nodes
                         $this->_updateInternalLinksInNodes($courseNewID);
                     } else {
                         if ($groupName === 'tests' || $groupName === 'surveys') {
                             // restores the import/export data handler
                             $this->_dh->disconnect();
                             $this->_dh = AMAImpExportDataHandler::instance(MultiPort::getDSN($this->_selectedTester));
                             if ($groupName === 'tests') {
                                 $this->_updateTestLinksInNodes($courseNewID);
                             }
                         }
                     }
                 }
                 // 					$this->_updateTestLinksInNodes ( $courseNewID );
             }
             // if ($objName === 'modello_corso')
             $this->_logMessage('**** IMPORT ENDED at ' . date('d/m/Y H:i:s') . '(timestamp: ' . $this->_dh->date_to_ts('now') . ') ****');
             $this->_logMessage('If there\'s no zip log below, this is a multi course import: pls find unzip log at the end of the last course log');
         }
         // foreach ($XMLObj as $objName=>$course)
         // extract the zip files to the appropriate media dir
         $this->_unzipToMedia($zip);
         $zip->close();
         if (!self::$_DEBUG) {
             unlink($zipFileName);
         }
     }
     $this->_progressDestroy();
     return $this->_recapArray;
 }
Esempio n. 10
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'] = "";
}
 /**
  * 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;
 }