diff --git a/relatorios/queries.php b/relatorios/queries.php index 2739cdc..c281ef7 100755 --- a/relatorios/queries.php +++ b/relatorios/queries.php @@ -29,8 +29,9 @@ function query_alunos_relationship() { $cohorts = report_unasus_int_array_to_sql($report->cohorts_selecionados); $polos = report_unasus_int_array_to_sql($report->polos_selecionados); - $query_cohort = " JOIN relationship_cohorts rlc + $query_cohort = " JOIN {relationship_cohorts} rlc ON (rlc.id = rm.relationshipcohortid) "; + if (!is_null($cohorts)) { $query_cohort = "{$query_cohort} AND rlc.cohortid IN ({$cohorts}) "; } @@ -99,9 +100,9 @@ function query_alunos_relationship_student() { $cohorts = report_unasus_int_array_to_sql($report->cohorts_selecionados); $polos = report_unasus_int_array_to_sql($report->polos_selecionados); - - $query_cohort = " JOIN relationship_cohorts rlc - ON (rlc.id = rm.relationshipcohortid) "; + + $query_cohort = " JOIN {relationship_cohorts} rlc + ON (rlc.id = rm.relationshipcohortid) "; if (!is_null($cohorts)) { $query_cohort = "{$query_cohort} AND rlc.cohortid IN ({$cohorts}) "; } diff --git a/tests/behat/behat_unasus.php b/tests/behat/behat_unasus.php new file mode 100644 index 0000000..53868fc --- /dev/null +++ b/tests/behat/behat_unasus.php @@ -0,0 +1,688 @@ + array( + 'datagenerator' => 'relationship', + 'required' => array('name') + ), + + 'relationship_groups' => array( + 'datagenerator' => 'relationship_groups', + 'required' => array('name') + ), + + 'relationship_members'=> array( + 'datagenerator' => 'relationship_members', + 'required' => array('user', 'group') + ), + 'assigns'=> array( + 'datagenerator' => 'assign', + 'required' => array('course', 'idnumber', 'name') + ) + + ); + + /** + * Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. + * + * @Given /^the following relationship "(?P(?:[^"]|\\")*)" exist:$/ + * + * @throws Exception + * @throws PendingException + * @param string $elementname The name of the entity to add + * @param TableNode $data + */ + + public function the_Following_Relationship_Exist($elementname, TableNode $data) + { + + $this->datagenerator = new behat_unasus; + + $elementdatagenerator = self::$elements[$elementname]['datagenerator']; + $requiredfields = self::$elements[$elementname]['required']; + if (!empty(self::$elements[$elementname]['switchids'])) { + $switchids = self::$elements[$elementname]['switchids']; + } + + foreach ($data->getHash() as $elementdata) { + + // Check if all the required fields are there. + foreach ($requiredfields as $requiredfield) { + if (!isset($elementdata[$requiredfield])) { + throw new Exception($elementname . ' requires the field ' . $requiredfield . ' to be specified'); + } + } + + // Switch from human-friendly references to ids. + if (isset($switchids)) { + foreach ($switchids as $element => $field) { + $methodname = 'get_' . $element . '_id'; + + // Not all the switch fields are required, default vars will be assigned by data generators. + if (isset($elementdata[$element])) { + // Temp $id var to avoid problems when $element == $field. + $id = $this->{$methodname}($elementdata[$element]); + unset($elementdata[$element]); + $elementdata[$field] = $id; + } + } + } + + // Preprocess the entities that requires a special treatment. + if (method_exists($this, 'preprocess_' . $elementdatagenerator)) { + $elementdata = $this->{'preprocess_' . $elementdatagenerator}($elementdata); + } + + // Creates element. + $methodname = 'create_' . $elementdatagenerator; + // if (method_exists($this->datagenerator, $methodname)) { + if(true){ + // Using data generators directly. + $this->datagenerator->{$methodname}($elementdata); + + } else if (method_exists($this, 'process_' . $elementdatagenerator)) { + // Using an alternative to the direct data generator call. + $this->{'process_' . $elementdatagenerator}($elementdata); + } else { + throw new PendingException($elementname . ' data generator is not implemented'); + } + } + + } + + /** + * Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. + * + * @Given /^the following relationship group "(?P(?:[^"]|\\")*)" exist:$/ + * + * @throws Exception + * @throws PendingException + * @param string $elementname The name of the entity to add + * @param TableNode $data + */ + public function the_Following_Relationship_Groups_Exist($elementname, TableNode $data) + { + + $this->datagenerator = new behat_unasus; + + $elementdatagenerator = self::$elements[$elementname]['datagenerator']; + $requiredfields = self::$elements[$elementname]['required']; + if (!empty(self::$elements[$elementname]['switchids'])) { + $switchids = self::$elements[$elementname]['switchids']; + } + + foreach ($data->getHash() as $elementdata) { + + // Check if all the required fields are there. + foreach ($requiredfields as $requiredfield) { + if (!isset($elementdata[$requiredfield])) { + throw new Exception($elementname . ' requires the field ' . $requiredfield . ' to be specified'); + } + } + + // Switch from human-friendly references to ids. + if (isset($switchids)) { + foreach ($switchids as $element => $field) { + $methodname = 'get_' . $element . '_id'; + + // Not all the switch fields are required, default vars will be assigned by data generators. + if (isset($elementdata[$element])) { + // Temp $id var to avoid problems when $element == $field. + $id = $this->{$methodname}($elementdata[$element]); + unset($elementdata[$element]); + $elementdata[$field] = $id; + } + } + } + + // Preprocess the entities that requires a special treatment. + if (method_exists($this, 'preprocess_' . $elementdatagenerator)) { + $elementdata = $this->{'preprocess_' . $elementdatagenerator}($elementdata); + } + + // Creates element. + $methodname = 'create_' . $elementdatagenerator; + // if (method_exists($this->datagenerator, $methodname)) { + if(true){ + // Using data generators directly. + $this->datagenerator->{$methodname}($elementdata); + + } else if (method_exists($this, 'process_' . $elementdatagenerator)) { + // Using an alternative to the direct data generator call. + $this->{'process_' . $elementdatagenerator}($elementdata); + } else { + throw new PendingException($elementname . ' data generator is not implemented'); + } + } + + } + + /** + * Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. + * + * @Given /^the following users belongs to the relationship group as "(?P(?:[^"]|\\")*)":$/ + * + * @throws Exception + * @throws PendingException + * @param string $elementname The name of the entity to add + * @param TableNode $data + */ + public function the_Following_Users_Belongs_Relationship_Members($elementname, TableNode $data) + { + + $this->datagenerator = new behat_unasus; + + $elementdatagenerator = self::$elements[$elementname]['datagenerator']; + $requiredfields = self::$elements[$elementname]['required']; + if (!empty(self::$elements[$elementname]['switchids'])) { + $switchids = self::$elements[$elementname]['switchids']; + } + + foreach ($data->getHash() as $elementdata) { + + // Check if all the required fields are there. + foreach ($requiredfields as $requiredfield) { + if (!isset($elementdata[$requiredfield])) { + throw new Exception($elementname . ' requires the field ' . $requiredfield . ' to be specified'); + } + } + + // Switch from human-friendly references to ids. + if (isset($switchids)) { + foreach ($switchids as $element => $field) { + $methodname = 'get_' . $element . '_id'; + + // Not all the switch fields are required, default vars will be assigned by data generators. + if (isset($elementdata[$element])) { + // Temp $id var to avoid problems when $element == $field. + $id = $this->{$methodname}($elementdata[$element]); + unset($elementdata[$element]); + $elementdata[$field] = $id; + } + } + } + + // Preprocess the entities that requires a special treatment. + if (method_exists($this, 'preprocess_' . $elementdatagenerator)) { + $elementdata = $this->{'preprocess_' . $elementdatagenerator}($elementdata); + } + + // Creates element. + $methodname = 'create_' . $elementdatagenerator; + // if (method_exists($this->datagenerator, $methodname)) { + if(true){ + // Using data generators directly. + $this->datagenerator->{$methodname}($elementdata); + + } else if (method_exists($this, 'process_' . $elementdatagenerator)) { + // Using an alternative to the direct data generator call. + $this->{'process_' . $elementdatagenerator}($elementdata); + } else { + throw new PendingException($elementname . ' data generator is not implemented'); + } + } + + } + + /** + * Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. + * + * @Given /^the following activity "(?P(?:[^"]|\\")*)" exist:$/ + * + * @throws Exception + * @throws PendingException + * @param string $elementname The name of the entity to add + * @param TableNode $data + */ + public function the_Following_Assign_Exist($elementname, TableNode $data) + { + + $this->datagenerator = new behat_unasus; + + $elementdatagenerator = self::$elements[$elementname]['datagenerator']; + $requiredfields = self::$elements[$elementname]['required']; + if (!empty(self::$elements[$elementname]['switchids'])) { + $switchids = self::$elements[$elementname]['switchids']; + } + + foreach ($data->getHash() as $elementdata) { + + // Check if all the required fields are there. + foreach ($requiredfields as $requiredfield) { + if (!isset($elementdata[$requiredfield])) { + throw new Exception($elementname . ' requires the field ' . $requiredfield . ' to be specified'); + } + } + + // Switch from human-friendly references to ids. + if (isset($switchids)) { + foreach ($switchids as $element => $field) { + $methodname = 'get_' . $element . '_id'; + + // Not all the switch fields are required, default vars will be assigned by data generators. + if (isset($elementdata[$element])) { + // Temp $id var to avoid problems when $element == $field. + $id = $this->{$methodname}($elementdata[$element]); + unset($elementdata[$element]); + $elementdata[$field] = $id; + } + } + } + + // Preprocess the entities that requires a special treatment. + if (method_exists($this, 'preprocess_' . $elementdatagenerator)) { + $elementdata = $this->{'preprocess_' . $elementdatagenerator}($elementdata); + } + + // Creates element. + $methodname = 'create_' . $elementdatagenerator; + // if (method_exists($this->datagenerator, $methodname)) { + if(true){ + // Using data generators directly. + $this->datagenerator->{$methodname}($elementdata); + + } else if (method_exists($this, 'process_' . $elementdatagenerator)) { + // Using an alternative to the direct data generator call. + $this->{'process_' . $elementdatagenerator}($elementdata); + } else { + throw new PendingException($elementname . ' data generator is not implemented'); + } + } + } + + + + /** + * Create a test relationship + * @param array|stdClass $record + * @param array $options with keys: + * 'createsections'=>bool precreate all sections + * @return stdClass relationship record + */ + public function create_relationship($record = null, array $options=null) { + global $DB, $CFG; + require_once("$CFG->dirroot/local/relationship/lib.php"); + + $this->relationshipcount++; + $i = $this->relationshipcount; + + $record = (array)$record; + + if (!isset($record['contextid'])) { + $record['contextid'] = context_system::instance()->id; + } + + if (!isset($record['name'])) { + $record['name'] = 'Relationship ' . $i; + } + + if (!isset($record['idnumber'])) { + $record['idnumber'] = ''; + } + + if (!isset($record['description'])) { + $record['description'] = "Test relationship $i\n$this->loremipsum"; + } + + if (!isset($record['descriptionformat'])) { + $record['descriptionformat'] = FORMAT_MOODLE; + } + + if (!isset($record['component'])) { + $record['component'] = ''; + } + + $id = relationship_add_relationship((object)$record); + + return $DB->get_record('relationship', array('id' => $id), '*', MUST_EXIST); + } + + /** + * Create a test relationship_groups + * @param array|stdClass $record + * @param array $options with keys: + * 'createsections'=>bool precreate all sections + * @return stdClass relationship_groups record + */ + public function create_relationship_groups($record = null, array $options=null) { + global $DB, $CFG; + require_once("$CFG->dirroot/local/relationship/lib.php"); + + $this->relationship_groupscount++; + $i = $this->relationship_groupscount; + + $record = (array)$record; + + if (!isset($record['relationshipid'])) { + $record['relationshipid'] = context_system::instance()->id; + } + + if (!isset($record['name'])) { + $record['name'] = 'Relationship_Group ' . $i; + } + + if (!isset($record['userlimit'])) { + $record['userlimit'] = 0; + } + + if (!isset($record['uniformdistribution'])) { + $record['uniformdistribution'] = 0; + } + + $id = relationship_add_group((object)$record); + + return $DB->get_record('relationship_groups', array('id' => $id), '*', MUST_EXIST); + } + + /** + * Create a test relationship_members + * @param array|stdClass $record + * @param array $options with keys: + * 'createsections'=>bool precreate all sections + * @return stdClass relationship_groups record + */ + public function create_relationship_members($record = null, array $options=null) { + global $DB, $CFG; + require_once("$CFG->dirroot/local/relationship/lib.php"); + + $this->relationship_memberscount++; + $i = $this->relationship_memberscount; + + $record = (array)$record; + + if (!isset($record['relationshipgroupid'])) { + $sql="SELECT rg.id + FROM {relationship_groups} rg + WHERE name = :name"; + + $relationshipgroupid = $DB->get_field_sql($sql, array('name' => $record['group'])); + $record['relationshipgroupid'] = $relationshipgroupid; + } + + if (!isset($record['relationshipcohortid'])) { + $sql="SELECT rc.id + FROM {relationship_cohorts} rc + WHERE rc.cohortid = (SELECT cm.cohortid + FROM {cohort_members} cm + WHERE userid = (SELECT u.id + FROM {user} u + WHERE u.username = :username))"; + + $relationshipcohortid = $DB->get_field_sql($sql, array('username' => $record['user'])); + $record['relationshipcohortid'] = $relationshipcohortid; + } + + if (!isset($record['userid'])) { + $sql = "SELECT u.id + FROM {user} u + WHERE u.username = :username"; + $user_id = $DB->get_field_sql($sql, array('username' => $record['user'])); + + $record['userid'] = $user_id; + } + + $id = relationship_add_member($record['relationshipgroupid'], + $record['relationshipcohortid'], + $record['userid']); + + return $DB->get_record('relationship_members', array('id' => $id), '*', MUST_EXIST); + } + + /** + * + * Adiciona uma tag no relationship. + * + * @Given /^instance the tag "([^"]*)" at relationship "([^"]*)"$/ + */ + public function instance_the_tag_at_relationship($tag, $relationship) { + global $DB; + + $record = new stdClass(); + $record->id = 1; + $record->userid = 2; + $record->name = $tag; + $record->rawname = $tag; + $record->tagtype = 'default'; + $record->description = null; + $record->descriptionformat = 0; + $record->flag = 0; + $record->timemodified = time(); + + $DB->insert_record('tag', $record); + + $sql = "SELECT tag.id as tagid, relationship.id as relationshipid + FROM {tag} tag, {relationship} relationship + WHERE tag.name = :tag"; + + $id = $DB->get_record_sql($sql, array('tag' => $tag)); + + $record2 = new stdClass(); + $record2->tagid = $id->tagid; + $record2->component = null; + $record2->itemtype = 'relationship'; + $record2->itemid = $id->relationshipid; // itemid = relationshipid! Why?? + $record2->contextid = null; + $record2->tiuserid = 0; + $record2->ordering = 0; + $record2->timecreated = time(); + $record2->timemodified = time(); + + $DB->insert_record('tag_instance', $record2); + } + + /** + * + * Adiciona os cohorts criados no relationship. Para isso é feita a inserção na tabela relationship_cohorts + * e relationship_members. Como há mais de um tipo de cohort é utilizado um foreach e assim executada a inclusão + * de um cohort em cada iteração. + * + * @Given /^add created cohorts at relationship "([^"]*)" on relationship_groups "([^"]*)"$/ + */ + public function add_created_cohorts_at_relationship($relationship, $relationship_group) + { + global $DB; + + $sql_relationship = "SELECT relationship.id + FROM {relationship} relationship + WHERE relationship.name = :relationship"; + + $relationshipId = $DB->get_field_sql($sql_relationship, array('relationship' => $relationship)); + + $sql = "SELECT DISTINCT role_assignments.userid as id, role_assignments.roleid, cohort.id as cohortid + FROM {cohort} cohort, {role_assignments} role_assignments + LEFT JOIN {cohort_members} cohort_members + ON role_assignments.userid = cohort_members.userid + WHERE cohort_members.cohortid = cohort.id"; + + $sql_result = $DB->get_records_sql($sql); + + foreach ($sql_result as $id) { + + $sql_roleid = "SELECT COUNT(1) + FROM {relationship_cohorts} rc + WHERE rc.roleid = :roleid"; + + $roleid = $DB->get_field_sql($sql_roleid, array('roleid' => $id->roleid)); + + if($roleid == 0) { + $record = new stdClass(); + $record->relationshipid = $relationshipId; + $record->roleid = $id->roleid; + $record->cohortid = $id->cohortid; + $record->allowdupsingroups = 0; + $record->uniformdistribution = 0; + $record->timecreated = time(); + $record->timemodified = time(); + + $DB->insert_record('relationship_cohorts', $record); + } + +// $sql_rc = "SELECT id +// FROM {relationship_cohorts} +// WHERE roleid = :roleid"; +// +// $relationshipCohortId = $DB->get_fieldset_sql($sql_rc, array('roleid' => $id->roleid))[0]; +// +// $sql_rg = "SELECT id +// FROM {relationship_groups} +// WHERE name = :relationship_group"; +// +// $relationshipGroupId = $DB->get_field_sql($sql_rg, array('relationship_group' => $relationship_group)); +// +// $record = new stdClass(); +// $record->relationshipgroupid = $relationshipGroupId; +// $record->relationshipcohortid = $relationshipCohortId; +// $record->userid = $id->id; +// $record->timeadded = time(); +// +// $DB->insert_record('relationship_members', $record); + } + } + + /** + * Adds the user to the specified cohort. The user should be specified like "username". + * Obs: Ao adicionar o usuário ao grupo de cohort, automaticamente é adicionado o usuário + * aos respectivos grupos de tutoria. + * + * @Given /^I add the user "([^"]*)" with cohort "([^"]*)" to cohort members$/ + * @param string $user, $cohort + */ + public function i_add_user_to_cohort_members($user, $cohort) { + global $DB; + + //Inclusão dos valores local_tutores_student_roles e local_tutores_tutor_roles + + $sql_config = "SELECT COUNT(1) + FROM {config} config + WHERE config.name = 'local_tutores_student_roles'"; + + $config = $DB->get_field_sql($sql_config); + + if($config == 0){ + $record_config_student = new stdClass(); + $record_config_student->name = 'local_tutores_student_roles'; + $record_config_student->value = 'student'; + + $DB->insert_record('config', $record_config_student); + + $record_config_teacher = new stdClass(); + $record_config_teacher->name = 'local_tutores_tutor_roles'; + $record_config_teacher->value = 'editingteacher'; + + $DB->insert_record('config', $record_config_teacher); + + $record_config_editingteacher = new stdClass(); + $record_config_editingteacher->name = 'local_tutores_orientador_roles'; + $record_config_editingteacher->value = 'editingteacher'; + + $DB->insert_record('config', $record_config_editingteacher); + + } + + $sql_user = "SELECT id + FROM {user} + WHERE username = :user"; + + $userId = $DB->get_field_sql($sql_user, array('user' => $user)); + + $sql_cohort = "SELECT id + FROM {cohort} + WHERE name = :cohort"; + + $cohortId = $DB->get_field_sql($sql_cohort, array('cohort' => 'Cohort '.$cohort)); + + $record = new stdClass(); + $record->cohortid = $cohortId; + $record->userid = $userId; + $record->timeadded = time(); + + $DB->insert_record('cohort_members', $record); + + if($cohort == 'student'){ + $record_student_log = new stdClass(); + $record_student_log->userid = $userId; + $record_student_log->timemodified = time(); + $record_student_log->plugin = null; + $record_student_log->name = 'local_tutores_student_roles'; + $record_student_log->value = $cohort; + + $DB->insert_record('config_log', $record_student_log); + } + + if($cohort == 'teacher'){ + $record_teacher_log = new stdClass(); + $record_teacher_log->userid = $userId; + $record_teacher_log->timemodified = time(); + $record_teacher_log->plugin = null; + $record_teacher_log->name = 'local_tutores_tutor_roles'; + $record_teacher_log->value = 'editing'.$cohort; + + $DB->insert_record('config_log', $record_teacher_log); + + $record_editingteacher_log = new stdClass(); + $record_editingteacher_log->userid = $userId; + $record_editingteacher_log->timemodified = time(); + $record_editingteacher_log->plugin = null; + $record_editingteacher_log->name = 'local_tutores_orientador_roles'; + $record_editingteacher_log->value = 'editing'.$cohort; + + $DB->insert_record('config_log', $record_editingteacher_log); + } + } + + /** + * Change complete date of an activity. + * + * @Given /^I set the submission date of activity "([^"]*)" to "([^"]*)" days after$/ + * @param string $idnumber, $days + */ + public function i_set_submission_date($idnumber, $days) { + global $DB; + + $sql = "SELECT instance + FROM {course_modules} + WHERE idnumber = :idnumber"; + + $assign_assignid = $DB->get_field_sql($sql, array('idnumber' => $idnumber)); + + $sql_time = "SELECT completionexpected + FROM bethat_course_modules + WHERE instance = :instance"; + + $unix_timestamp = $DB->get_field_sql($sql_time, array('instance' => $assign_assignid)); + + //86400 = 1 dia + $new_unix_timestamp = $unix_timestamp + ($days * 86400); + + $DB->set_field('assign_submission', 'timemodified', $new_unix_timestamp, array('assignment' => $assign_assignid)); + } +} diff --git a/tests/behat/unasus.feature b/tests/behat/unasus.feature new file mode 100644 index 0000000..c8cbc63 --- /dev/null +++ b/tests/behat/unasus.feature @@ -0,0 +1,346 @@ + @unasus @report_unasus @javascript +Feature: Edit completion settings of an activity + In order to edit completion settings without accidentally breaking user data + As a teacher + I need to edit the activity and use the unlock button if required + +Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | s1 | stundent1@example.com | + | student2 | Student | s2 | stundent2@example.com | + | student3 | Student | s3 | stundent3@example.com | + | teacher1 | Teacher | t1 | teacher1@example.com | + | teacher2 | Teacher | t2 | teacher2@example.com | + + And the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + + And the following "courses" exist: + | fullname | shortname | category | groupmode | enablecompletion | + | Course1 | c1 | CAT1 | 1 | 1 | +# | Course2 | c2 | CAT2 | 1 | 1 | + And the following config values are set as admin: + | enablecompletion | 1 | + + And the following "cohorts" exist: + | name | idnumber | contextlevel | reference | + | Cohort teacher | CHt | Category | CAT1 | + | Cohort student | CHs | Category | CAT1 | + +# -----------------------------ASSIGN SETUP----------------------------------------------- +# Unix timestamp 946684800 = 1 jan 2000 at 00h00m00s + And the following "activities" exist: + | activity | course | idnumber | name | intro | grade | assignsubmission_onlinetext_enabled | completionexpected | + | assign | C1 | a1 | Test assignment one | Submit something! | 100 | 1 | 2147483647 | + | assign | C1 | a2 | Test assignment two | Submit something! | 100 | 1 | 978307200 | + | assign | C1 | a3 | Test assignment three | Submit something! | 100 | 1 | 0 | + | assign | C1 | a4 | Test assignment four | Submit something! | 100 | 1 | 946684800 | + | assign | C1 | a5 | Test assignment five | Submit something! | 100 | 1 | 946684800 | + | assign | C1 | a6 | Test assignment six | Submit something! | 100 | 1 | 946684800 | + | assign | C1 | a7 | Test assignment seven | Submit something! | 100 | 1 | 946684800 | + + +# And the following activity "assigns" exist: +# | activity | course | idnumber | name | intro | grade | assignsubmission_onlinetext_enabled | completionexpected | +# | assign | C1 | a1 | Test assignment one | Submit something! | 100 | 1 | time() + 31557600 | +# | assign | C1 | a2 | Test assignment two | Submit something! | 100 | 1 | 1524585600 | +# | assign | C1 | a3 | Test assignment three | Submit something! | 100 | 1 | 1524585600 | +# | assign | C1 | a4 | Test assignment four | Submit something! | 100 | 1 | 1524585600 | +# | assign | C1 | a5 | Test assignment five | Submit something! | 100 | 1 | 1524585600 | +# | assign | C1 | a6 | Test assignment six | Submit something! | 100 | 1 | 1524585600 | +# | assign | C1 | a7 | Test assignment seven | Submit something! | 100 | 1 | 1524585600 | + +# -------------------------------------------------------------------------------------- +# -----------------------------QUIZ SETUP----------------------------------------------- +# And the following "question categories" exist: +# | contextlevel | reference | name | +# | Course | C1 | Test questions | +# +# And the following "activities" exist: +# | activity | name | intro | course | idnumber | +# | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | +# +# +# And the following "questions" exist: +# | questioncategory | qtype | name | questiontext | +# | Test questions | truefalse | TF1 | First question | +# | Test questions | truefalse | TF2 | Second question | +# +# And quiz "Quiz 1" contains the following questions: +# | question | page | maxmark | +# | TF1 | 1 | | +# | TF2 | 1 | 3.0 | + +# -------------------------------------------------------------------------------------- +# -----------------------------FORUM SETUP----------------------------------------------- +# And I log in as "admin" +# And I follow "Courses" +# And I follow "Category 1" +# And I follow "Course1" +# And I turn editing mode on +# And I click on "Edit settings" "link" in the "Administration" "block" +# And I set the following fields to these values: +# | Enable completion tracking | Yes | +# And I press "Save and display" +# +## And the following "activities" exist: +## | activity | name | intro | course | idnumber | groupmode | +## | forum | forum | Test forum | C1 | forum | 0 | +# +# When I add a "forum" to section "1" and I fill the form with: +# | Forum name | Test forum name1 | +# | Description | Test forum description | +# | course | C1 | +# | groupmode | 0 | +# | Completion tracking | Show activity as complete when conditions are met | +# | completionview | 1 | +# +# When I add a "forum" to section "1" and I fill the form with: +# | Forum name | Test forum name2 | +# | Description | Test forum description | +# | course | C1 | +# | groupmode | 0 | +# | Completion tracking | Show activity as complete when conditions are met | +# | completionview | 1 | +# +# When I add a "forum" to section "1" and I fill the form with: +# | Forum name | Test forum name3 | +# | Description | Test forum description | +# | course | C1 | +# | groupmode | 0 | +# | Completion tracking | Show activity as complete when conditions are met | +# | completionview | 1 | +# And I log out + +# -------------------------------------------------------------------------------------- + + And the following "course enrolments" exist: + | user | course | role | + | student1 | c1 | student | + | student2 | c1 | student | + | student3 | c1 | student | + | teacher1 | c1 | editingteacher | + | teacher2 | c1 | editingteacher | + + # Por causa da exigência do relatório, é necessário que a coluna `role` tenha como valor editingteacher + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | local/relationship:view | Allow | editingteacher | Category | CAT1 | + | local/relationship:manage | Allow | editingteacher | Category | CAT1 | + | local/relationship:assign | Allow | editingteacher | Category | CAT1 | + | moodle/cohort:view | Allow | editingteacher | Category | CAT1 | + + And the following "role assigns" exist: + | user | role | contextlevel | reference | + | teacher1 | editingteacher | Category | CAT1 | + | teacher2 | editingteacher | Category | CAT1 | + + # O cohort precisa ser student ou teacher para que seja incluído nos grupos de tutoria + # É necessário usar a regra abaixo para a inclusão dos membros, visto a integração do plugin relationship + And I add the user "teacher1" with cohort "teacher" to cohort members + And I add the user "teacher2" with cohort "teacher" to cohort members + And I add the user "student1" with cohort "student" to cohort members + And I add the user "student2" with cohort "student" to cohort members + And I add the user "student3" with cohort "student" to cohort members + + And the following relationship "relationships" exist: + | name | contextid | + | relationship1 | 154005 | + + And the following relationship group "relationship_groups" exist: + | name | relationshipid | + | relationship_group1 | 344000 | + | relationship_group2 | 344000 | + + And instance the tag "grupo_tutoria" at relationship "relationship1" + And add created cohorts at relationship "relationship1" on relationship_groups "relationship_group1" + And add created cohorts at relationship "relationship1" on relationship_groups "relationship_group2" + + And the following users belongs to the relationship group as "relationship_members": + | user | group | + | student1 | relationship_group1 | + | student2 | relationship_group1 | + | student3 | relationship_group2 | + | teacher1 | relationship_group1 | + | teacher2 | relationship_group2 | + + + + + # Resposta do quiz (Entrega da atividade por parte do estudante) +# And I log in as "student1" +# And I follow "Course1" +# And I follow "Quiz 1" +# And I press "Attempt quiz now" +# And I click on "True" "radio" in the "First question" "question" +# And I click on "False" "radio" in the "Second question" "question" +# And I follow "Finish attempt ..." +# And I press "Submit all and finish" +# And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue" +# And I log out +# +# And I log in as "student2" +# And I follow "Course1" +# And I follow "Quiz 1" +# And I press "Attempt quiz now" +# And I click on "True" "radio" in the "First question" "question" +# And I click on "True" "radio" in the "Second question" "question" +# And I follow "Finish attempt ..." +# And I press "Submit all and finish" +# And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue" +# And I log out +# +# And I log in as "student3" +# And I follow "Course1" +# And I follow "Quiz 1" +# And I press "Attempt quiz now" +# And I click on "False" "radio" in the "First question" "question" +# And I click on "False" "radio" in the "Second question" "question" +# And I follow "Finish attempt ..." +# And I press "Submit all and finish" +# And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue" +# And I log out + + # Resposta do forum (Entrega da atividade por parte do estudante) +# And I log in as "student1" +# And I follow "Course1" +# And I add a new discussion to "Test forum name1" forum with: +# | Subject | Forum discussion 1 | +# | Message | How awesome is this forum discussion? | +# And I reply "Forum discussion 1" post from "Test forum name1" forum with: +# | Message | Actually, I've seen better. | +# And I log out +# +# And I log in as "student2" +# And I follow "Course1" +# And I add a new discussion to "Test forum name2" forum with: +# | Subject | Forum discussion 1 | +# | Message | How awesome is this forum discussion? | +# And I reply "Forum discussion 1" post from "Test forum name2" forum with: +# | Message | Actually, I've seen better. | +# And I log out +# +# And I log in as "student3" +# And I follow "Course1" +# And I add a new discussion to "Test forum name3" forum with: +# | Subject | Forum discussion 1 | +# | Message | How awesome is this forum discussion? | +# And I reply "Forum discussion 1" post from "Test forum name3" forum with: +# | Message | Actually, I've seen better. | +# And I log out + + # Resposta do assignment (Entrega da atividade por parte do estudante) +# And I log in as "student1" +# And I follow "Course1" +# And I follow "Test assignment one" +# And I press "Add submission" +# And I set the following fields to these values: +# | Online text | I'm the student1 submission | +# And I press "Save changes" +# And I press "Submit assignment" +# And I press "Continue" +# And I log out + + And I log in as "student2" + And I follow "Course1" + And I follow "Test assignment two" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student2 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I log out + + And I log in as "student3" + And I follow "Course1" + And I follow "Test assignment three" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student3 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I log out + + And I log in as "student1" + And I follow "Course1" + And I follow "Test assignment four" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student1 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I set the submission date of activity "a4" to "0" days after + And I log out + + And I log in as "student1" + And I follow "Course1" + And I follow "Test assignment five" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student3 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I set the submission date of activity "a5" to "10" days after + And I log out + + And I log in as "student1" + And I follow "Course1" + And I follow "Test assignment six" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student3 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I set the submission date of activity "a6" to "11" days after + And I log out + + And I log in as "student1" + And I follow "Course1" + And I follow "Test assignment seven" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student3 submission | + And I press "Save changes" + And I press "Submit assignment" + And I press "Continue" + And I set the submission date of activity "a7" to "11" days after + And I log out + + # Atribuição de nota em assignment (Avaliação da atividade por parte do professor) +# And I follow "Courses" +# And I follow "Category 1" +# And I follow "Course1" +# And I navigate to "Grades" node in "Course administration" +# And I turn editing mode on +# And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment one" +# And I give the grade "75.00" to the user "Student 2" for the grade item "Test assignment one" +# And I give the grade "50.00" to the user "Student 3" for the grade item "Test assignment one" +## And I give the grade "67.00" to the user "Student 1" for the grade item "Test assignment two" +# And I press "Save changes" + + + @javascript +Scenario: Correct report generation + And I log in as "admin" + + And I follow "Courses" + And I follow "Category 1" + And I follow "Course1" +# And I navigate to "Síntese: avaliações em atraso" node in "Reports > UNA-SUS" +# And I navigate to "Boletim" node in "Reports > UNA-SUS" +# And I pause + And I navigate to "Acompanhamento: entrega de atividades" node in "Reports > UNA-SUS" + And I press "Gerar relatório" + And I pause + Then I should see "Test assignment one" + + + +