Ejemplo n.º 1
0
         $dataHa['exercise'] = $message->getHtml();
         // ottiene il prossimo esercizio da svolgere, se previsto.
         $next_exercise_id = ExerciseDAO::getNextExerciseId($exercise, $sess_id_user);
         if (AMA_DataHandler::isError($next_exercise_id)) {
             $errObj = new ADA_Error($next_exercise_id, translateFN('Errore nel caricamento del prossimo esercizio'));
         } else {
             if ($next_exercise_id) {
                 $dataHa['exercise'] .= "<a href=\"{$http_root_dir}/browsing/exercise.php?id_node={$next_exercise_id}\">";
                 $dataHa['exercise'] .= translateFN('Prossimo esercizio') . '</a>';
             }
         }
     }
     break;
 case 'view':
 default:
     $exercise = ExerciseDAO::getExercise($id_node);
     if ($user_level < $exercise->getExerciseLevel()) {
         $form = translateFN("Esercizio di livello superiore al tuo");
     } else {
         $viewer = ExerciseViewerFactory::create($exercise->getExerciseFamily());
         $action = 'exercise.php';
         $form = $viewer->getViewingForm($userObj, $exercise, $sess_id_course_instance, $action);
         // vito 26 gennaio 2009
         if (($id = ExerciseDAO::getNextExerciseId($exercise, $sess_id_user)) != NULL) {
             $next_exercise_menu_link = CDOMElement::create('a');
             $next_exercise_menu_link->setAttribute('href', "{$http_root_dir}/browsing/exercise.php?id_node={$id}");
             $next_exercise_menu_link->addCHild(new CText(translateFN('Prossimo esercizio')));
             $dataHa['go_back'] .= $next_exercise_menu_link->getHtml();
         }
     }
     $dataHa['exercise'] = $form;
Ejemplo n.º 2
0
 function get_exercisesFN($user_level)
 {
     //global $dh,$error;
     //global $sess_id_user, $sess_id_course_instance;
     $dh = isset($GLOBALS['dh']) ? $GLOBALS['dh'] : null;
     $error = isset($GLOBALS['error']) ? $GLOBALS['error'] : null;
     $debug = isset($GLOBALS['debug']) ? $GLOBALS['debug'] : null;
     $sess_id_course_instance = isset($_SESSION['sess_id_course_instance']) ? $_SESSION['sess_id_course_instance'] : null;
     $sess_id_user = isset($_SESSION['sess_id_user']) ? $_SESSION['sess_id_user'] : null;
     // filtering exercises:
     // have the exercises been already  executed?
     // HTML EMBEDDED VERSION
     if (!empty($this->children)) {
         $exerc_Ar = $this->children;
         // mydebug(__LINE__,__FILE__,$exerc_Ar);
         $dataAr = array();
         foreach ($exerc_Ar as $id_exerc) {
             $temp = $dh->get_node_info($id_exerc);
             $type = $temp['type'];
             $exercise_type_family = $type[0];
             // first char = family (3 multiple, 4 open manual 5 open automatic 6 cloze etc)
             /*
             switch (strlen($exercise_type)){
             case 1:
             default:
             $exercise_type_mode = 0;// single
             $exercise_type_interaction = 0; // r+feedback
             break;
             case 2:
             $exercise_type_mode = $exercise_type[1];// second char = mode (0 single, 1 sequence, 2 random)
             $exercise_type_interaction = 0; // r+feedback
             break;
             case 3:
             $exercise_type_mode = $exercise_type[1];// second char = mode (0 single, 1 sequence, 2 random)
             $exercise_type_interaction = $exercise_type[2]; // third char = interaction (0 r+feedback 1 feedback 2 blind)
             break;
             }
             */
             if ($this->isNodeExercise($exercise_type_family)) {
                 //      if ($exercise_type_family >= ADA_STANDARD_EXERCISE_TYPE) {
                 // versione che legge nel DB la storia dell'esercizio
                 /*
                  $exercise = $dh->get_node_info($id_exerc);
                 // mydebug(__LINE__,__FILE__,$exercObj);
                 $exerc_title = $exercise['name'];
                 $out_fields_ar = array('data_visita','ripetibile');
                 $history_exerc = $dh->find_ex_history_list($out_fields_ar,$sess_id_user, $sess_id_course_instance, $id_exerc);
                 if (is_array($history_exerc)){
                   $h_exerc = array_shift($history_exerc);
                   // global $debug; $debug = 1; mydebug(__LINE__,__FILE__,$h_exerc); $debug=0;
                   if (is_array($h_exerc))
                   $already_executed = !$h_exerc[2];
                   else
                   $already_executed = "";
                 } else {
                   $already_executed = "";
                 }
                 */
                 // versione che utilizza la classe apposita
                 $exercise = ExerciseDAO::getExercise($id_exerc);
                 $exerc_title = $exercise->getTitle();
                 $already_executed = !$exercise->getRepeatable();
                 if (!$already_executed) {
                     // not yet viewed  or repeatable
                     $alt = translateFN("Esercizio");
                     $icon = "_exer.png";
                     $ok = true;
                 } else {
                     $alt = translateFN("Esercizio gi&agrave; eseguito");
                     $icon = "_exerdis.png";
                     // _gruppodis.png
                     $ok = false;
                 }
                 if ($ok) {
                     $exerc_ok = array("<img name=gruppo alt=\"{$alt}\" src=\"img/{$icon}\"> <a href=exercise.php?id_node={$id_exerc}>{$exerc_title}</a>");
                 } else {
                     $exerc_ok = array("<img name=gruppo alt=\"{$alt}\" src=\"img/{$icon}\">{$exerc_title}");
                 }
                 array_push($dataAr, $exerc_ok);
             }
         }
         $dataAr = $this->_removeEmptyElements($dataAr);
         $rules = '';
         $style = 'table_link';
         $t = new Table();
         $t->initTable('0', 'center', '0', '0', '100%', '', '', '', '', '0', '0', $rules, $style);
         $t->setTable($dataAr, $caption = "", $summary = translateFN("Indice degli esercizi collegati"));
         return $t->getTable();
     } else {
         return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml() . "<p>";
     }
 }
Ejemplo n.º 3
0
     } else {
         /*
          * Update the session variable too.
          */
         $_SESSION['sess_edit_exercise']['exercise'] = serialize($exercise);
         header("Location: {$edit_form_base_action}");
         exit;
     }
 } else {
     if (isset($add_answer_to) && !empty($add_answer_to)) {
         $position = $_POST['position'] - 1;
         ExerciseDAO::addAnswer($exercise, $_POST);
         $id = $exercise->getId();
         unset($_SESSION['sess_edit_exercise']['exercise']);
         $exercise = NULL;
         $exercise = ExerciseDAO::getExercise($id);
         $_SESSION['sess_edit_exercise']['exercise'] = serialize($exercise);
         header("Location: {$edit_form_base_action}");
         exit;
     } else {
         if (isset($delete) && !empty($delete)) {
             $node_id = $delete;
             $exercise->deleteDataItem($node_id);
             if (!ExerciseDAO::save($exercise)) {
                 $errObj = new ADA_Error(NULL, translateFN("Errore nel salvataggio delle modifiche apportate all'esercizio"));
             } else {
                 /*
                  * Update the session variable too.
                  */
                 $_SESSION['sess_edit_exercise']['exercise'] = serialize($exercise);
                 header("Location: {$edit_form_base_action}");
Ejemplo n.º 4
0
if (!isset($op)) {
    $op = 'default';
}
switch ($op) {
    case 'exe':
        $user_answer = $dh->get_ex_history_info($id_exe);
        if (AMA_DataHandler::isError($user_answer)) {
            //print("errore");
            $errObj = new ADA_Error($user_answer, translateFN("Errore nell'ottenimento della risposta utente"));
        }
        $node = $user_answer['node_id'];
        //$student_id      = $user_answer['student_id'];
        //$course_instance = $user_answer['course_id'];
        $id_student = $user_answer['student_id'];
        $id_course_instance = $user_answer['course_id'];
        $exercise = ExerciseDAO::getExercise($node, $id_exe);
        $_SESSION['exercise_object'] = serialize($exercise);
        if (AMA_DataHandler::isError($exercise)) {
            //print("errore");
            $errObj = new ADA_Error($exercise, translateFN("Errore nella lettura dell'esercizio"));
        }
        $viewer = ExerciseViewerFactory::create($exercise->getExerciseFamily());
        $history = $viewer->getExerciseHtml($exercise);
        $status = translateFN('Esercizio dello studente');
        break;
    case 'list':
    case 'default':
        // lettura dei dati dal database
        // Seleziona gli esercizi dello studente selezionato nel corso selezionato
        $userObj->get_exercise_dataFN($id_course_instance, $userObj->getId());
        // Esercizi svolti e relativi punteggi