Minor - format code

pull/3293/head
Julio Montoya 6 years ago
parent d857202234
commit 8b077e0ac1
  1. 2
      main/document/document.php
  2. 77
      main/exercise/exercise.class.php
  3. 26
      main/inc/lib/usermanager.lib.php
  4. 4
      main/survey/create_new_survey.php
  5. 20
      main/survey/survey_question.php

@ -1471,7 +1471,7 @@ if ($isAllowedToEdit ||
'post', 'post',
api_get_self()."?add_as_template=$document_id_for_template" api_get_self()."?add_as_template=$document_id_for_template"
); );
$frmAddTemplate ->addHeader(get_lang('AddAsTemplate')); $frmAddTemplate->addHeader(get_lang('AddAsTemplate'));
$frmAddTemplate->addText('template_title', get_lang('TemplateName'), true); $frmAddTemplate->addText('template_title', get_lang('TemplateName'), true);
$frmAddTemplate->addFile('template_image', get_lang('TemplateImage'), ['id' => 'template_image']); $frmAddTemplate->addFile('template_image', get_lang('TemplateImage'), ['id' => 'template_image']);
$frmAddTemplate->addButtonSave(get_lang('CreateTemplate'), 'create_template'); $frmAddTemplate->addButtonSave(get_lang('CreateTemplate'), 'create_template');

@ -9937,6 +9937,44 @@ class Exercise
return count($answers); return count($answers);
} }
public static function allowAction($action)
{
if (api_is_platform_admin()) {
return true;
}
$limitTeacherAccess = api_get_configuration_value('limit_exercise_teacher_access');
$disableClean = api_get_configuration_value('disable_clean_exercise_results_for_teachers');
switch ($action) {
case 'delete':
if (api_is_allowed_to_edit(null, true)) {
if ($limitTeacherAccess) {
return false;
}
return true;
}
break;
case 'clean_results':
if (api_is_allowed_to_edit(null, true)) {
if ($limitTeacherAccess) {
return false;
}
if ($disableClean) {
return false;
}
return true;
}
break;
}
return false;
}
/** /**
* Get number of questions in exercise by user attempt. * Get number of questions in exercise by user attempt.
* *
@ -10449,43 +10487,4 @@ class Exercise
return $group; return $group;
} }
public static function allowAction($action)
{
if (api_is_platform_admin()) {
return true;
}
$limitTeacherAccess = api_get_configuration_value('limit_exercise_teacher_access');
$disableClean = api_get_configuration_value('disable_clean_exercise_results_for_teachers');
switch ($action) {
case 'delete':
if (api_is_allowed_to_edit(null, true)) {
if ($limitTeacherAccess) {
return false;
}
return true;
}
break;
case 'clean_results':
if (api_is_allowed_to_edit(null, true)) {
if ($limitTeacherAccess) {
return false;
}
if ($disableClean) {
return false;
}
return true;
}
break;
}
return false;
}
} }

@ -7002,6 +7002,19 @@ SQL;
return Database::num_rows($result) > 0; return Database::num_rows($result) > 0;
} }
/**
* @param int $userInfo
*
* @throws Exception
*/
public static function deleteUserFiles($userId)
{
$path = self::getUserPathById($userId, 'system');
$fs = new Filesystem();
$fs->remove($path);
}
/** /**
* @return EncoderFactory * @return EncoderFactory
*/ */
@ -7095,17 +7108,4 @@ SQL;
return $url; return $url;
} }
/**
* @param int $userInfo
*
* @throws Exception
*/
public static function deleteUserFiles($userId)
{
$path = self::getUserPathById($userId, 'system');
$fs = new Filesystem();
$fs->remove($path);
}
} }

@ -267,7 +267,7 @@ if (Gradebook::is_active()) {
$surveytypes[0] = get_lang('Normal'); $surveytypes[0] = get_lang('Normal');
$surveytypes[1] = get_lang('Conditional'); $surveytypes[1] = get_lang('Conditional');
if ($action == 'add') { if ($action === 'add') {
$form->addElement('hidden', 'survey_type', 0); $form->addElement('hidden', 'survey_type', 0);
$survey_tree = new SurveyTree(); $survey_tree = new SurveyTree();
$list_surveys = $survey_tree->createList($survey_tree->surveylist); $list_surveys = $survey_tree->createList($survey_tree->surveylist);
@ -281,7 +281,7 @@ $form->addElement('checkbox', 'shuffle', null, get_lang('ActivateShuffle'));
$input_name_list = null; $input_name_list = null;
if ($action == 'edit' && !empty($survey_id)) { if ($action === 'edit' && !empty($survey_id)) {
if ($survey_data['anonymous'] == 0) { if ($survey_data['anonymous'] == 0) {
$form->addElement( $form->addElement(
'checkbox', 'checkbox',

@ -538,6 +538,7 @@ class survey_question
* Get the JS for questions that can depend on a previous question * Get the JS for questions that can depend on a previous question
* (and that hides those questions until something changes in the previous * (and that hides those questions until something changes in the previous
* question). * question).
*
* @return string HTML code * @return string HTML code
*/ */
public static function getJs() public static function getJs()
@ -555,12 +556,14 @@ class survey_question
} }
/** /**
* Get the question parents recursively, if any. This function depends on * Get the question parents recursively, if any. This function depends on
* the existence of a parent_id field, which depends on the * the existence of a parent_id field, which depends on the
* 'survey_question_dependency' setting and its corresponding SQL * 'survey_question_dependency' setting and its corresponding SQL
* requirements. * requirements.
* @param int $questionId The c_survey_question.question.id *
* @param array $list An array of parents to be extended by this method * @param int $questionId The c_survey_question.question.id
* @param array $list An array of parents to be extended by this method
*
* @return array The completed array of parents * @return array The completed array of parents
*/ */
public static function getParents($questionId, $list = []) public static function getParents($questionId, $list = [])
@ -587,7 +590,9 @@ class survey_question
/** /**
* Creates the JS code for the given parent question so that it shows * Creates the JS code for the given parent question so that it shows
* the children questions when a specific answer of the parent is selected. * the children questions when a specific answer of the parent is selected.
*
* @param array $question An array with the question details * @param array $question An array with the question details
*
* @return string JS code to add to the HTML survey question page * @return string JS code to add to the HTML survey question page
*/ */
public static function getQuestionJs($question) public static function getQuestionJs($question)
@ -628,8 +633,10 @@ class survey_question
} }
/** /**
* Returns the (children) questions that have the given question as parent * Returns the (children) questions that have the given question as parent.
*
* @param array $question An array describing the parent question * @param array $question An array describing the parent question
*
* @return array The questions that have the given question as parent * @return array The questions that have the given question as parent
*/ */
public static function getDependency($question) public static function getDependency($question)
@ -651,7 +658,8 @@ class survey_question
} }
/** /**
* This method is not implemented at this level (returns null) * This method is not implemented at this level (returns null).
*
* @param array $questionData * @param array $questionData
* @param array $answers * @param array $answers
*/ */

Loading…
Cancel
Save