本文整理汇总了PHP中Exercise::enable方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::enable方法的具体用法?PHP Exercise::enable怎么用?PHP Exercise::enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exercise
的用法示例。
在下文中一共展示了Exercise::enable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
switch ($choice) {
case 'delete':
// deletes an exercise
if ($exercise_action_locked == false) {
$objExerciseTmp->delete();
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 1, $exerciseId, api_get_session_id());
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_info['id']);
}
Display::display_confirmation_message(get_lang('ExerciseDeleted'));
}
break;
case 'enable':
// enables an exercise
$objExerciseTmp->enable();
$objExerciseTmp->save();
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'visible', api_get_user_id());
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
Display::display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable':
// disables an exercise
$objExerciseTmp->disable();
$objExerciseTmp->save();
api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'invisible', api_get_user_id());
Display::display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable_results':
//disable the results for the learners
$objExerciseTmp->disable_results();
示例2: api_set_default_visibility
/**
* @todo Fix tool_visible_by_default_at_creation labels
* @todo Add sessionId parameter to avoid using context
*
* @param int $item_id
* @param int $tool_id
* @param int $group_id
* @param array $courseInfo
*/
function api_set_default_visibility($item_id, $tool_id, $group_id = 0, $courseInfo = array())
{
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$courseId = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
$original_tool_id = $tool_id;
switch ($tool_id) {
case TOOL_LINK:
case TOOL_LINK_CATEGORY:
$tool_id = 'links';
break;
case TOOL_DOCUMENT:
$tool_id = 'documents';
break;
case TOOL_LEARNPATH:
$tool_id = 'learning';
break;
case TOOL_ANNOUNCEMENT:
$tool_id = 'announcements';
break;
case TOOL_FORUM:
case TOOL_FORUM_CATEGORY:
case TOOL_FORUM_THREAD:
$tool_id = 'forums';
break;
case TOOL_QUIZ:
$tool_id = 'quiz';
break;
}
$setting = api_get_setting('document.tool_visible_by_default_at_creation');
$visibility = 'invisible';
if (empty($group_id)) {
$group_id = api_get_group_id();
}
if (isset($setting[$tool_id])) {
if ($setting[$tool_id] == 'true') {
$visibility = 'visible';
}
}
// Read the portal and course default visibility
if ($tool_id == 'documents') {
$visibility = DocumentManager::getDocumentDefaultVisibility($courseCode);
}
api_item_property_update($courseInfo, $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id());
// Fixes default visibility for tests
switch ($original_tool_id) {
case TOOL_QUIZ:
$objExerciseTmp = new Exercise($courseId);
$objExerciseTmp->read($item_id);
if ($visibility == 'visible') {
$objExerciseTmp->enable();
$objExerciseTmp->save();
} else {
$objExerciseTmp->disable();
$objExerciseTmp->save();
}
break;
}
}
示例3: api_set_default_visibility
/**
* This function sets the default visibility for any given content, using the
* default visibility setting of the corresponding tool. For example, if we
* create a new quiz and call this function, if the quiz tool is
* invisible/disabled at course creation, the quiz itself will be set to
* invisible.
* @param array|\Entity\Course $course
* @param int The ID of the item in its own table
* @param string The string identifier of the tool
* @param int The group ID, in case we want to specify it
* @param int The integer course ID, in case we cannot get it from the context
* @todo Fix tool_visible_by_default_at_creation labels
*/
function api_set_default_visibility($course, $item_id, $tool_id, $group_id = null)
{
$original_tool_id = $tool_id;
switch ($tool_id) {
case TOOL_LINK:
$tool_id = 'links';
break;
case TOOL_DOCUMENT:
$tool_id = 'documents';
break;
case TOOL_LEARNPATH:
$tool_id = 'learning';
break;
case TOOL_ANNOUNCEMENT:
$tool_id = 'announcements';
break;
case TOOL_FORUM:
case TOOL_FORUM_CATEGORY:
case TOOL_FORUM_THREAD:
$tool_id = 'forums';
break;
case TOOL_QUIZ:
$tool_id = 'quiz';
break;
}
$setting = api_get_setting('tool_visible_by_default_at_creation');
if (is_array($course)) {
$courseId = $course['real_id'];
} else {
if ($course instanceof Course) {
$courseId = $course->getId();
}
}
if (isset($setting[$tool_id])) {
$visibility = 'invisible';
if ($setting[$tool_id] == 'true') {
$visibility = 'visible';
}
if (empty($group_id)) {
$group_id = api_get_group_id();
}
api_item_property_update($course, $original_tool_id, $item_id, $visibility, api_get_user_id(), $group_id, null, null, null, api_get_session_id());
// Fixes default visibility for tests
switch ($original_tool_id) {
case TOOL_QUIZ:
$objExerciseTmp = new Exercise($courseId);
$objExerciseTmp->read($item_id);
if ($visibility == 'visible') {
$objExerciseTmp->enable();
$objExerciseTmp->save();
} else {
$objExerciseTmp->disable();
$objExerciseTmp->save();
}
break;
}
}
}