$num = Database::get()->querySingle("SELECT COUNT(*) AS count\n                 FROM lp_rel_learnPath_module AS LPM,\n                      lp_module AS M,\n                      lp_asset AS A\n                WHERE M.module_id = LPM.module_id\n                  AND M.startAsset_id = A.asset_id\n                  AND A.path = ?s\n                  AND LPM.learnPath_id = ?d\n                  AND M.course_id = ?d", $insertedExercise, $_SESSION['path_id'], $course_id)->count;
            if ($num == 0) {
                // used in another LP but not in this one, so reuse the module id reference instead of creating a new one
                insertInLearningPath($thisExerciseModule->module_id, $order);
                $messBox .= "<tr>" . disp_message_box(q($exercise->title) . " : " . $langExInsertedAsModule . "<br>", "success") . "</td></tr>";
            } else {
                $messBox .= "<tr>" . disp_message_box(q($listex->title) . " : " . $langExAlreadyUsed . "<br>", "caution") . "</td></tr>";
            }
        }
    }
    // end if request
}
//end while
$tool_content .= "<table width='100%' class='tbl_alt'>";
$tool_content .= $messBox;
$tool_content .= "</table><br />";
//STEP ONE : display form to add an exercise
$tool_content .= display_my_exercises("", "");
//STEP TWO : display learning path content
//$tool_content .= disp_tool_title($langPathContentTitle);
//$tool_content .= '<a href="learningPathAdmin.php?course=$course_code">&lt;&lt;&nbsp;'.$langBackToLPAdmin.'</a>';
// display list of modules used by this learning path
//$tool_content .= display_path_content();
$tool_content .= action_bar(array(array('title' => $langBack, 'url' => "learningPathAdmin.php?course={$course_code}&amp;path_id=" . (int) $_SESSION['path_id'], 'icon' => 'fa-reply', 'level' => 'primary-label')));
draw($tool_content, 2, null, $head_content);
function insertInLearningPath($module_id, $rank)
{
    global $langDefaultModuleAddedComment;
    // finally : insert in learning path
    Database::get()->query("INSERT INTO lp_rel_learnPath_module\n        (learnPath_id, module_id, specificComment, `rank`, `lock`, `visible`)\n        VALUES (?d, ?d, ?s, ?d, ?s, ?d)", $_SESSION['path_id'], $module_id, $langDefaultModuleAddedComment, $rank, 'OPEN', 1);
}
Beispiel #2
0
            claro_sql_query($sql);
            $msgList['info'][] = get_lang("%moduleName has been added as module", array('%moduleName' => $exercise['title'])) . '<br />' . "\n";
        } else {
            // check if this is this LP that used this exercise as a module
            $sql = "SELECT COUNT(*)\n                      FROM `" . $TABLELEARNPATHMODULE . "` AS LPM,\n                           `" . $TABLEMODULE . "` AS M,\n                           `" . $TABLEASSET . "` AS A\n                     WHERE M.`module_id` =  LPM.`module_id`\n                       AND M.`startAsset_id` = A.`asset_id`\n                       AND A.`path` = " . (int) $exercise['id'] . "\n                       AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id'];
            $num = claro_sql_query_get_single_value($sql);
            if ($num == 0) {
                // determine the default order of this Learning path
                $sql = "SELECT MAX(`rank`)\n                        FROM `" . $TABLELEARNPATHMODULE . "`";
                $orderMax = claro_sql_query_get_single_value($sql);
                $order = $orderMax + 1;
                // finally : insert in learning path
                $sql = "INSERT INTO `" . $TABLELEARNPATHMODULE . "`\n                        (`learnPath_id`, `module_id`, `specificComment`, `rank`, `lock`)\n                        VALUES (" . (int) $_SESSION['path_id'] . ", " . (int) $existingModule['module_id'] . ",'" . claro_sql_escape(get_block('blockDefaultModuleAddedComment')) . "', " . $order . ", 'OPEN')";
                $query = claro_sql_query($sql);
                $msgList['info'][] = get_lang("%moduleName has been added as module", array('%moduleName' => $exercise['title'])) . '<br />' . "\n";
            } else {
                $msgList['info'][] = get_lang("%moduleName is already used as a module in this learning path", array('%moduleName' => $exercise['title'])) . '<br />' . "\n";
            }
        }
    }
}
//end while
//STEP ONE : display form to add an exercise
$out .= claro_html_msg_list($msgList);
$out .= display_my_exercises($dialogBox);
//STEP TWO : display learning path content
$out .= claro_html_tool_title(get_lang('Learning path content'));
// display list of modules used by this learning path
$out .= display_path_content();
$claroline->display->body->appendContent($out);
echo $claroline->display->render();