diff --git a/docs/bios-configuration.md b/docs/bios-configuration.md deleted file mode 100644 index c4fed426..00000000 --- a/docs/bios-configuration.md +++ /dev/null @@ -1,29 +0,0 @@ -# BIOS Configuration - -## Steps - -F10 (Open Setup) - -- _Security_ - - _Create BIOS Administrator Password_ → Set password -- _Advanced_ - - _Boot Options_ - - _USB Storage Boot_ → Disabled - - _Fast Boot_ → Disabled (disturbs network boot) - - _Audio Alerts During Boot_ → Disabled (very noisy) - - _HP Sure Recover_ - - _HP Sure Recover_ → Disabled (tries to restore Windows) - - _Secure Boot Configuration_ - - _Configure Legacy Support and Secure Boot_ → «Legacy Support Disable and Secure Boot Disable» (**TODO**: use Secure Boot) - -F10 → Yes (Save changes & Reboot) - -> Enter the code that the BIOS asks to disable the secure boot - -## Automation - -- Can be automated using Intel vPro/AMT (**TODO**) -- Can be partially automated with a USB programmable keyboard such as : - - [USB Rubber Ducky](https://shop.hak5.org/products/usb-rubber-ducky-deluxe) - - [XK-24 USB Programmable Keypad for Windows or Mac](https://www.amazon.com/gp/product/B003MB780E) - - [Cactus WHID: WiFi HID Injector USB Rubberducky](https://www.tindie.com/products/aprbrother/cactus-whid-wifi-hid-injector-usb-rubberducky/) diff --git a/docs/db/database-structure.md b/docs/db/database-structure.md new file mode 100644 index 00000000..a4cc48b6 --- /dev/null +++ b/docs/db/database-structure.md @@ -0,0 +1,299 @@ +# Schema Public + +## Tables + +### audit + +Some exercises require reviews from other students or any other member of the school. The reviewer checks that some conditions are met by the code of the student being reviewed. This process is called an `audit` and it's kept in this table. + +Columns: +- id. +- groupId: The group that the audit refers to. +- auditorId: The user who's making the audit. +- attrs: The attributes of the audits keep the feedback of the auditor for each question failed. +- grade: A floating point number with the ratio between questions required to pass and questions approved. (Less than 1 means failed. More or equal than 1 means passed. More than 1 means that the student had bonus questions correct). +- createdAt: The timestamp of the time and date of creation. +- updatedAt: The timestamp of the last update. +- code: The code that must be used by the auditor to start the audit. This code is set to null after the audit is expired. +- resultId: The result of the audit. `resultId` is filled when the group has enough audits to validate or fail a project - that means that while it's not filled, audits are still "doable" (if no grade, so not done), and then after they are not needed anymore +- version: A sha of the commit that the audit refers to. +- endAt: It is used for expiration date (after this date the audit is expired). +- private: Used to access the code by the auditor. + +### discordToken (TODO: remove) + +Columns: +- id +- accessToken +- refreshToken +- expiresAt + +### event + +An event anchors an objects into time. +> Note: Some [object attributes](attributes.md) are related to time, but they express time only in relative terms to the beginning of the event. +> Also, live edits (i.e., editing an event while is ongoing) it's not supported. The changes will only take effect after reloading the page. + +Columns: +- id +- createdAt: The timestamp of the creation of the event. +- endAt: The timestamp for the end of the event. +- registrationId: The registration to the event. +- objectId: The object that is used to generate the event. +- parentId: The immediate event ancestor. The parent event. +- status: Confirmation that the event finished correctly (NULL or done for now). +- path: The path of the event (the relative url of the event). +- campus: The campus that contains the event. +- code: Used to unlock the exams. + +### event_user + +This table links users and events. A user can be in many events and an events have many users. + +Columns: +- id +- createdAt +- userId +- eventId + +### group + +Some projects are required to be made by groups. Those groups are kept in this table. + +Columns: +- id +- objectId: The object that is being "done" by the group. Usually projects or raids. +- eventId : The groups only exist in relation to an event +- captainId: The captain of the group. +- createdAt. +- updatedAt. +- status: See [group_status](#group_status) for possible values. +- path. +- campus. + +### group_status + +Columns: +- status +Possible values (for now) + - `setup` + - `working` + - `audit` + - `finished` + +### group_user + +This table links users to groups. A user can be in many groups and a group contains many users. + +Columns: +- id +- userId +- groupId +- confirmed: Boolean. False by default. True after the user represented by the user id confirms the group. +- createdAt +- updatedAt + +### match + +It is used for the `bet` system in the bonus exercises. Specifically to keep a record of the matches between students who will review and make a bet about each others code. + +Columns: +- id +- createdAt +- updatedAt +- objectId: The object that requires the match. +- userId: The user that is matched. +- matchId: The matched that is made to another user. +- confirmed: The same as in group_user it's a way to keep track of invitations that had not been confirmed. +- bet: boolean; For the optional exercises that require a bet. A bet can be true if the exercises is expected to pass and false otherwise. +- result: boolean; True for correct bet. +- path +- campus +- eventId: The event the object in inserted in. (Piscine, Raid, etc). + +### object + +Objects are generic representations of elements in the structure of the curriculum (Onboarding, campus, piscine, raids, etc). They are arranged in a hierarchical structure to allow unlimited nesting (see [object_child](#object_child)). They also keep the timeline of the events relaying in durations (ex. `duration`, `eventDuration`, etc) specified by [attributes](attributes.md) (`attrs`). + +Columns: +- id +- name +- type: + - `onboarding` + - `campus` + - `exercise` + - `quest` + - `signup` + - `exam` + - `raid` + - `project` + - `piscine` +- status: (Currently not in used, but it should always be `online` to avoid errors TODO: remove at some point). + - `online` + - `offline` + - `draft` +- attrs: See [object attributes](attributes.md). +- childrenAttrs: Attributes that are applied to all the children objects. +- createdAt +- updatedAt +- externalRelationUrl (Maybe not needed). +- authorId (Maybe not needed). +- campus: The campus the object is related to. +- referenceId: If the object is a duplication this field points to the reference object. +- referencedAt: The timestamp of the creation of the copy object. + +### object_child + +It keeps a child-parent relationship between two objects. It's used to encapsulate objects inside each other. + +Columns: +- id +- parentId +- childId +- attrs +- key: When generating the JS object this field will be the `key` of the child. It is also used in the url. +- index: Defines the position of the child object inside the parent object. + +### progress + +It is a register of the steps in the progression of students doing the exercises and projects. + +Columns: +- id +- createdAt +- updateAt +- userId +- groupId +- eventId +- version: the sha of the last commit +- grade: is the average of the grades of the results related to this progress if several exist. +- isDone: set to trure as soon as a user fails a validation or when all validations required are done. +- path +- campus +- objectId + +### record + +Keeps a register for the bans. It can also keep the record of other situations, this is done by setting the banEndAt to a date already passed and the reason for the record. + +Columns: +- id +- userId +- authorId +- message +- banEndAt +- createdAt + +### registration + +Registrations to events (For example, an exam). + +Columns: +- id +- createdAt, When the registration was created. +- startAt, When users can start registering to an event. +- endAt, When the registration ends. +- eventStartAt, Event at which the event will be started (and as such created). Event don't exist only when they start +- objectId, The object the registration refers to. +- parentId, The parent object of the object the registration refers to. +- attrs +- path +- campus + +### registration_user + +The user registered to events. A user can register to many events and and event can have many users. + +Columns: +- id +- registrationId +- userId +- createdAt + +### result + +The result for each exercise and project made in the platform. + +Columns: +- id +- createdAt +- updatedAt +- grade +- attrs +- type: + - `tester` + - `user_audit` + - `admit_audit` + - `admin_selection` + - `status` +- userId +- groupId +- objectId +- path +- version, The version of the code the result refers to. +- eventId +- isLast, Used to represent transitory states. A progress is only considered finished when `isLast` is `true`. +- campus + +### role + +Columns: +- id +- slug +- name +- description +- createdAt +- updatedAt + +### token + +Columns: +- id +- status + - `active` + - `expired` +- createdAt +- updatedAt + +### transaction + +It's a register of the rewards given to students. + +Columns: +- id +- type: + - `xp`: transaction giving xp + - `up`: transaction correspondent to reviewing someone + - `down`: transaction correspondent to reviewing you +- amount: + - type = xp; The amount of Xp that an object rewards. + - type = up || down; a percentage of the change (10%); +- userId +- attrs +- createdAt +- path +- objectId +- eventId +- campus + +### user + +Columns: +- id +- githubId: (deprecated). +- githubLogin: alias -> login. +- discordId: depracated (TODO: remove) +- discordLogin: depracated (TODO: remove) +- profile +- attrs: Extra information about the users (email, address, etc). +- createdAt +- updateAt +- discordDMChannelld: depracated (TODO: remove) +- campus + +### user_role + +Columns: +- id +- userId +- roleId diff --git a/docs/db/db-authorization.md b/docs/db/db-authorization.md new file mode 100644 index 00000000..a3c7e8ce --- /dev/null +++ b/docs/db/db-authorization.md @@ -0,0 +1,225 @@ +# DB authorization + +Every request to Hasura executes against a set of session variables. Normally there are some main variables for the authorization context: + +- `X-Hasura-User-Id`: this variable usually denotes the user executing the request. + +- `X-Hasura-Role`: This variable denotes the role with which the user is executing the current request. Hasura has a built-in notion of a role, and will explicitly look for this variable to infer the role. + +- `X-Hasura-campuses`: this variable contains the campus that the user currently is on. + +In our database we have several roles which are simple arbitrary names. +Each role can be given a set of permissions and actions (`select`, `insert`, `update`, `delete`). That will execute against each table of the database. + +Example: + +To give the user with a certain role a permission to make a request, we must set a permission rule that would look something like this: + +```json +{ "user_id": { "_eq": "X-Hasura-User-Id" } } +``` + +This is the same as saying : if the value of the `user_id` column equals the value of the session variable `X-Hasura-User-Id`, it allows this request to execute on the current row and get information on that user id. + +## Roles + +These are the roles presented in the database: + +- `anonymous`: this role allows non logged in users to query tables (only using the `select` action): + + - `users` : columns `id`, `login` + - `object` : columns `id`, `childAttr`, `campus`, `name`, `type` + - `result` : columns `groupId`, `objectId`, `progressId`, `userId`, `grade`, `campus` + - `transactions` : columns `objectId`, `userId`, `amount`, `type` + - `progress` : columns `isDone`, `objectId`, `userId`, `id`, `grade`, `campus` + +--- + +- `user` : this role allows the following queries: + + - `selects` action: + + - without permission rules: + + - `event_user` + - `group` + - `group_user` + - `match` + - `registration_user` + - `event` + - `object` + - `object_child` + - `object_status` + - `object_type` + - `registration` + - `role` + - `transaction_type` + - _`event_user_view`_ + - _`object_children_view`_ + - _`registration_user_view`_ + - _`user_public_view`_ + + - with permission rules: + - `audit`, the user only can query this table if the user id from the `X-Hasura-User-Id` variable is equal to one of the `members`, or the `auditorId`. + - `result`, the user only can query this table if the `X-Hasura-User-Id` is equal to the `userId` or one of the members from their group. + - `transaction`, this table can be queried by users if the `X-Hasura-User-Id` is equal to the `userId`. + - `record`, the same applies to this table and the tables below. + - `progress` + - `user_role` + - `user`, the same applies to this table but with the `id`. + - _`user_role_view`_ + - _`audit_private`_ + - _`progress_by_path_view`_ + - _`progress_view`_ + - _`xp`_ + - _`xp_by_event`_ + - _`xp_by_path`_ + +--- + +- `campus-admin` : this role allows users to query every table, but with the variables `X-Hasura-campus` checked (campus check). This means that users with this role will only be able to query information from their own campus. Example: a user in campus `madere` can only query the content associated to that campus. The following tables can be queried: + + - `select` action: + - without permission rules: + - `group_status` + - `object_status` + - `object_type` + - `result_type` + - `role` + - `transaction_type` + - `user_role` + - _`user_public_view`_ + - _`user_role_view`_ + - with permission rules: + - `event_user` + - `audit` + - `group` + - `group_user` + - `match` + - `object` + - `event` + - `progress` + - `record` + - `registration` + - `registration_user` + - `result` + - `transaction` + - `user` + - _`progress_by_path_view`_ + - _`audit_private`_ + - _`event_user_view`_ + - _`event_with_results_ready_view`_ + - _`progress_view`_ + - _`registration_user_view`_ + - _`registration_with_event_ready_view`_ + - _`toad_result_view`_ + - _`xp_by_event`_ + - _`xp_by_path`_ + +--- + +- `campus-admin-read-only` : this role allows users to query almost all tables (only using the `select` action). But with the same permission rule in the `campus-admin`. The following tables can be queried: + + - without permission rules: + - `group_status` + - `object_status` + - `object_type` + - `result_type` + - `role` + - `transaction_type` + - `user_role` + - _`user_public_view`_ + - _`user_role_view`_ + - with permission rules: + - `event_user` + - `audit` + - `group` + - `group_user` + - `match` + - `object` + - `event` + - `progress` + - `record` + - `registration` + - `registration_user` + - `result` + - `transaction` + - `user` + - _`progress_by_path_view`_ + - _`audit_private`_ + - _`event_user_view`_ + - _`event_with_results_ready_view`_ + - _`progress_view`_ + - _`registration_user_view`_ + - _`registration_with_event_ready_view`_ + - _`toad_result_view`_ + - _`xp_by_event`_ + - _`xp_by_path`_ + +--- + +- `admin-read-only` : this role allows users to query all tables only using the `select` action. + +--- + +- `admin` : this role allows users to query using any action in any table on the database. + +> You can see more about each role by going to the [graphiql](https://((DOMAIN))/graphiql) in the docs section. Note that you must be logged in with the user role you desire to see. For the role `anonymous` you do not need to be logged in. If you want to see the possible tables that can be queried by an admin, you must login with an admin, and so on... + +A role is given by default to every user, if an user has more roles, the highest would be taken by default when login. + +This table can describe the permissions for each table of the database and each user role. + +✅ : with permission rules\ +🟩 : without permission rules\ +❌ : not allowed\ +S : select\ +U : update\ +I : insert\ +D : delete + +| tables | `anonymous` | `user` | `campus-admin` | `campus-admin-read-only` | `admin` | `admin-read-only` | +| :--------------------------------- | :------------------------------ | :------------------------------ | :------------------------------ | :------------------------------ | :------------------------------ | ------------------------------- | +| | S  U  I  D  | S  U  I  D  | S  U  I  D  | S  U  I  D  | S  U  I  D  | S  U  I  D  | +| event_user | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| audit | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| group | ❌ ❌ ❌ ❌ | 🟩 ✅ ✅ ✅ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| group_user | ❌ ❌ ❌ ❌ | 🟩 ✅ ✅ ✅ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| match | ❌ ❌ ❌ ❌ | 🟩 ✅ ✅ ✅ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| progress | 🟩 ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| record | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| registration_user | ❌ ❌ ❌ ❌ | 🟩 ❌ ✅ ✅ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| result | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| transaction | 🟩 ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| user | 🟩 ❌ ❌ ❌ | ✅ 🟩 ❌ ❌ | ✅ ✅ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| audit_expired_view | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| audit_private | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| discordToken | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| event | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| event_user_view | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| object | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| event_with_results_ready_view | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| group_status | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| job | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| match_to_remove_view | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ✅ ✅ ✅ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| object_child | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ❌ ✅ ✅ ✅ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| object_children_view | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| object_status | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| object_type | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| progress_by_path_view | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| progress_view | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| registration | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| registration_user_view | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| registration_with_event_ready_view | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| result_type | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| role | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| toad_result_view | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| token | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| token_status | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| transaction_type | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| user_public_view | ❌ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| user_role | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| user_roles_view | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | 🟩 ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| xp | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ❌ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| xp_by_event | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | +| xp_by_path | ❌ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ❌ ❌ ❌ | ✅ ✅ ✅ ✅ | ✅ ❌ ❌ ❌ | diff --git a/docs/db/db-relations.md b/docs/db/db-relations.md new file mode 100644 index 00000000..318915b8 --- /dev/null +++ b/docs/db/db-relations.md @@ -0,0 +1,192 @@ +# Database Relations + +## Entity Relationship Diagram ERD + +An entity relationship diagram (ERD) shows the relationships of entity and sets stored in a database. + +An entity in this context is a table, this table contains a set of attributes, they can be of any data structure (INT, TEXT, ...). + +An entity can have several relations to other entities. Those relations are represented with "crow foots" + +### Relationships cardinality + +Relationships have a cardinality, normally they have two indicators that are shown on both sides of the line. + +1. One end of the line, refers to the **max** number of times that an instance of one entity can be associated with instances in the related entity. It can be **one**, **many** or **none** + +2. The second, describes the **min** number of times one instance can be related to others. +It can be **zero** or **mandatory** + +The combination of those two indicators create relations, you can get more information [here](https://community.mis.temple.edu/mis3506digitaldesignfall2018/files/2018/10/Adam-Alalouf_Cardinality.pdf) + +![alt text](../img/db/db-relations.jpg "hierarchical roles") + +## Relations + +### Events + +Events will be the accumulation of the following tables : + +- `event` +- `registration` +- `registration_user` +- `event_user` + +This part of the database takes care of schools activities with time. + +The `event` table contains the following relations: + +- `parentId` that is associated to himself. This association can be better explained if we take a look at the `path` column. An event can be based on a parent event (ex: the event `/madere/div-01/piscine-rust` is associated to this parent event `/madere/div-01`). + +- `registrationId` that is associated to the `registration` table. This is a one to one relations, meaning that an event must always have a registration associated to it. + +- `objectId` that is associated to the `object` table, this column will identify which object is associated to which event. An object can have multiple events, but an event must always be associated to an object. (it will never exist an event where the `objectId` is `null`) + +--- + +The `event_user` contains the associations between events and users. This will contain information on which users are registered to which event. An event can have multiple users and a user can have multiple events, this way being a many to many relationship. + +--- + +The `registration` table contains all objects/activities that need registration. Having the following relations: + +- `parentId` that is associated to himself. As said above (in the events), it has the same use. +- `objectId` that is associated to the object table, this is the object reference to the registrations. + +--- + +The `registration_user` table is a relationship many to many between `registration` and `user`. This table contains all users that are registered to an event. + +- `registrationId` a registration can have multiple users. +- `userId` a user can have multiple registrations. + +--- + +### Objects + +Object will be the accumulation of the following tables : + +- `object` +- `object_child` +- `object_status` +- `object_type` + +This part of the database defines the structure of the content. + +The `object` table contains the following relations: + +- `referenceId` that is associated to himself, this attribute allows the duplication of reference objects (given by **01-edu**), that are used to set up campuses +- `authorId` that is associated to the user table and this is the author of that object/content. + +--- + +The `object_child` table contains the encapsulation of objects. An object can have multiple children and a child must have one object parent. Note that one parent can't be associated two times to children with the same key. This table contains the following relationships to the object table: + +- `parentId` that associates the parent object to the child object. +- `childId` that belongs to the parent object. + +Both child and parent must have at least one association to the `object` table, and the `object` table can have multiple relations with the `object_child` table. + +Example: + +Campus `madeira` is a **parent object** of `piscine-go`, therefore the later one is the **child**. + +But `piscine-go` can be the **parent object** of all the quest, exams and raids (those being the **child objects**). And so on... creating a finite cycle. + +--- + +### Users + +Users will be the accumulation of the following tables: + +- `role` +- `user_role` +- `user` +- `group` +- `group_user` +- `token` +- `record` +- `transaction` + +--- + +The `role` table contains permission roles for each user. + +--- + +The `user_role` contains information on which users are associated to which role. A user can have multiple roles and a role can be associated to multiple users. + +--- + +The `group` table is the link between projects or raids and a group of users. This table contains the following relations: + +- `eventId` that associates which group is related to which event. +- `captainId` that associates the captain's user. +- `objectId` that associates which group is related to which object. + +--- + +The `group_user` table contains the relation between groups and users. A group can have several users and so do the users. + +--- + +The `token` table stores the tokens ids from the hasura authorization variables for each user. This table has no relation between other tables. + +--- + +The `record` table takes care of students records (bans). All relations in this table are with the table user. + +--- + +The `transaction` table takes care of rewarding the user, by accumulating the user's **xp** , **up** and **down** (you can see more information about those types in the `database-structure.md`). This table contains the following relations: + +- `userId` that represents the user rewarded +- `eventId` that associates the event in which the user was rewarded. Example: the user can be rewarded for an exercise `/madere/piscine-go/quest-01/make-it-better` and the parent event of that exercise will be `/madere/piscine-go`. +- `objectId` that associates the object in which the user was rewarded. Example: if a user passes an exercise (object), the reward will be associated to that object. + +--- + +#### Results + +Results will be the accumulation of the following tables: + +- `audit` +- `match` +- `progress` +- `result` + +This part of the database defines the users/students progress in the school. + +The `audit` table contains all information related to the audit system and it is one of the ways of obtaining results. This table contains the following relations: + +- `groupId` that associates the group being audited. +- `auditorId` as the name says, it is linked to the user table and has a relation of many to one. This column will be the auditor. +- `resultId` that associates the audit to the result. An audit can have one or no results (pending on the auditor review). While the results must have at least one audit. + +--- + +The `match` table is another way of obtaining a result. This table is used in bonus exercises to match two students. The following relations are established: + +- `userId` this will be the user wanting the match to happen. +- `matchId` this is a self related id, a match can be made by matching other students or it can be none. If the latter is none it means that the student is waiting for the match, otherwise it is a match. +- `eventId` that associates the event to the current match. Example: a user can be waiting for the exercise `/madere/piscine-go/quest-01/teacher` that is located in the `/madere/piscine-go` event. +- `objectId` that associates the object to the current match, this being the bonus exercise that the user is doing. + +--- + +The `progress` table is the reflection of user's activity on specific path: registration to an event related, commitment to a group associated to this path, generation of result expected to validate a progress on this path. + +- `userId` that associates an user with a progress. A progress must always have a user associate to it and a user can or cannot have multiple progresses. +- `groupId` this association allows each user form a group to have progress. This is a many to none or one connection, meaning that a progress can have none or one group and a group can have multiple progresses. +- `eventId` that associates which event the user has progressed on. +- `objectId` that associates which object the user has progressed on. +- `version` is the association between the `progress` and the `result` table + +--- + +The `result` table keeps the track of students result. The following relations are established: + +- `userId` that associates an user with a result. An user can have multiple results but a result is associated to just one user. +- `groupId` that associates a group with a result. The same logic as in the `userId` +- `objectId` that associates an object with a result. A result must have always a object associated to it and an object can have multiple results +- `eventId` that associates an event with a result. The same logic as in the `objectId` diff --git a/docs/db/graphql.md b/docs/db/graphql.md new file mode 100644 index 00000000..ce92654b --- /dev/null +++ b/docs/db/graphql.md @@ -0,0 +1,257 @@ +# Examples of graphql (queries) + +> Note: that all queries present here can be ran in your own school. For this you must login with an admin role and access the following route . Depending on our role the tables permissions may differ. + +## Simple queries to get info + +- The following query returns the basic information of a given user : + +```graphql +query getUserInfo($name: String!) { + user(where: {login: {_eq: $name}}) { + profile + login + attrs + auditRatio + campus + createdAt + totalDown + totalUp + updatedAt + } +} +``` + +Query variable: + +```graphql +{"name": "Joao"} +``` + +--- + +- The following query returns the list of all records of a given user (including the finished ones), the output would be : + - author of the record + - the time that the record was created and will end + - message/reason for the ban + +```graphql +query bannedUsers($name: String!) { + record(where: {user: {login: {_eq: $name}}}) { + authorLogin + banEndAt + createdAt + message + } +} +``` + +Query variable: + +```graphql +{"name": "Joao"} +``` + +--- + +- The following query returns a list of groups given the path `name`. The output will be the `captainLogin` and the `userLogin` from all the members of that group. + +```graphql +query getGroupInfo($object: String!) { + group(where: {object: {name: {_eq: $object}}}) { + captainLogin + path + status + members { + userLogin + } + } +} +``` + +Query variable: + +```graphql +{"path": "/madere/div-01/go-reloaded"} +``` + +--- + +- The following query returns all events in a given campus, the output for this query will be the: + - object name + - path of the event + - parent event (this will be the parent event of the given child event) + +```graphql +query eventsByCampus($campus: String!) { + event(where: {campus: {_eq: $campus}}) { + object { + name + } + parent { + path + object { + name + } + createdAt + endAt + path + } + } +} +``` + +Query variable: + +```graphql +{ "campus": "madere" } +``` + +--- + +- The following query returns information of users that are associated to an event. For the query to work it should be given two arguments : `campus` and the `path`. The output will be the user name/login, audit ratio and the event info. + +```graphql +query usersEvent($campus: String!, $path: String!) { + event_user(where: {event: {path: {_eq: $path}, _and: {campus: {_eq: $campus}}}}) { + userAuditRatio + userLogin + event { + path + object { + name + } + } + } +} +``` + +Query variable: + +```graphql +{"campus": "madera", "path": "/madere/div-01/piscine-js"} +``` + +- If we wanted to filter the users that were registered to a type of object in the event, we would just need to filter the object by `type` instead of filtering using the `path`. Should look something like this: + +```graphql +query usersEvent($campus: String!, $objectType: String!) { + event_user(where: {event: {object: {type: {_eq: $objectType}}, _and: {campus: {_eq: $campus}}}}) { + userAuditRatio + userLogin + event { + path + object { + name + } + } + } +} +``` + +Query variable: + +```graphql +{"campus": "pyc", "objectType": "raid"} +``` + +--- + +- The following query returns the current `XP` of a given user, the output should be the `amount` that this user should have + +```graphql +query xp($name: String!) { + xp(where: {user: {login: {_eq: $name}}}) { + user { + login + } + amount + } +} +``` + +Query variable: + +```graphql +{"name": "Joao"} +``` + +- If we wanted to filter all `XP` gain from an user from a given object, it would look something like this: + +```graphql +query eventXp($userName: String!, $objectName: String!) { + xp_by_path(where: {user: {login: {_eq: $userName}}, _and: {object: {name: {_eq: $objectName}}}}) { + path + user { + login + } + event { + path + } + object { + name + } + amount + } +} +``` + +Query variable: + +```graphql +{"userName": "Joao", "objectName": "ascii-art"} +``` + +--- + +- The following query gives information relevant to the onboarding games, This view will. + +```graphql +query getGameInfo($name: String!) { + toad_result_view(where: {user: {login: {_eq: $name}}}) { + user { + login + } + attempts + allowedAttempts + score + path + games + } +} +``` + +Query variables: + +```graphql +{"name": "Joao"} +``` + +--- + +- The following query returns information about the progress of a given user in a specific path. + +```graphql +query getProgress($name: String!, $path: String!) { + progress(where: {user: {login: {_eq: $name}}, _and: {path: {_eq: $path}}}) { + path + grade + isDone + campus + group { + captainLogin + members { + user { + login + } + } + } + } +} +``` + +query variable: + +```graphql +{"name": "Joao", "path": "/madere/piscine-go/exam-01" } +``` diff --git a/docs/img/db/db-relations.jpg b/docs/img/db/db-relations.jpg new file mode 100644 index 00000000..4bc60e53 Binary files /dev/null and b/docs/img/db/db-relations.jpg differ diff --git a/docs/object-attribute-reference.md b/docs/object-attribute-reference.md deleted file mode 100644 index 6012b609..00000000 --- a/docs/object-attribute-reference.md +++ /dev/null @@ -1,21 +0,0 @@ -# Object Attribute Reference - -## List all **USABLE** preset object attributes - -| Attribute | Type | Value | Description | -| ----------------- | -------- | ---------------------------------------------------------------------- | ------------------------------------------------------- | -| `xp` | function | `exerciceExpCalculation`, `examExpCalculation` or `raidExpCalculation` | Amount of experience points that an object will give. | -| `correctionPrice` | function | `correctionPrice` | Amount of correction points needed to test an exercise. | -| `duration` | number | | | -| `time` | string | | | -| `info` | object | | | - -## List all **RESERVED** preset object attributes - -| Attribute | Type | Value | Description | -| ------------ | -------- | ----- | ----------- | -| `scopeStart` | function | | | -| `scopeEnd` | function | | | -| `startDay` | function | | | -| `status` | function | | | -| `week` | function | | | diff --git a/docs/os-deployment.md b/docs/os-deployment.md deleted file mode 100644 index 5113199f..00000000 --- a/docs/os-deployment.md +++ /dev/null @@ -1,30 +0,0 @@ -# OS Deployment - -## Image creation steps - -- [Installation of Ubuntu](ubuntu-installation.md) - - minimal OS installation (downloads ~200 MB) - - Software installation (downloads ~900 MB) - - Optimization - - improve speed - - reduce image size - - reduce power (CPU) & memory usage - - reduce surface of attack - - reduce bandwidth usage - - Customization - - machine-dependent (drivers, bug workarounds...) - - time zone of the school - - school scripts - - Cleaning - - logs - - temporary files - - histories - - caches - - auto-generated IDs -- Preparation of the disk image - - zero unallocated space of filesystem (~7 GB of data remains) - - (optional) create compressed image with [lz4](https://lz4.github.io/lz4) (the resulting image is ~3.2 GB) - -## Network installation - -- Boot through PXE [UDPcast](http://udpcast.linux.lu) which allows an efficient transfer of the disk image (using multicast or broadcast) diff --git a/docs/pc-requirements.md b/docs/pc-requirements.md index 60c87951..71c9fd84 100644 --- a/docs/pc-requirements.md +++ b/docs/pc-requirements.md @@ -1,9 +1,12 @@ # PC requirements -| Component | Minimum specifications | -| ----------- | -------------------------------------------------------------------------------------------------- | -| Processor | 4 threads x86-64 (64 bits) | -| Memory | 8 GB | -| Disk | 120 GB SSD | -| Monitor | 14" Full HD flicker-free | -| Motherboard | [device encryption](https://support.microsoft.com/en-us/help/4502379/windows-10-device-encryption) | +Features required: + +- Linux compatible + +| Component | Minimum specifications | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Processor | 4 threads x86-64 (64 bits), [2200 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1000 single-core score](https://browser.geekbench.com/processor-benchmarks) | +| Memory | 8 GB | +| Disk | 120 GB SSD | +| Monitor | 14" Full HD flicker-free | diff --git a/docs/piscine-go-curriculum.md b/docs/piscine-go-curriculum.md index 38b769a8..b1fa3868 100644 --- a/docs/piscine-go-curriculum.md +++ b/docs/piscine-go-curriculum.md @@ -163,10 +163,17 @@ Videos: Exercices: +<<<<<<< HEAD - [printprogramname](https://github.com/01-edu/public/tree/master/subjects/printprogramname/README.md) - [printparams](https://github.com/01-edu/public/tree/master/subjects/printparams/README.md) - [revparams](https://github.com/01-edu/public/tree/master/subjects/revparams/README.md) - [sortparams](https://github.com/01-edu/public/tree/master/subjects/sortparams/README.md) +======= +- printprogramname | https://public.01-edu.org/subjects/printprogramname +- printparams | https://public.01-edu.org/subjects/printparams +- revparams | https://public.01-edu.org/subjects/revparams +- sortparams | https://public.01-edu.org/subjects/sortparams +>>>>>>> refs/remotes/origin/master ### Quest 7 @@ -213,11 +220,19 @@ Videos: Exercices: +<<<<<<< HEAD - [bool](https://github.com/01-edu/public/tree/master/subjects/bool/README.md) - [point](https://github.com/01-edu/public/tree/master/subjects/point/README.md) - [displayfile](https://github.com/01-edu/public/tree/master/subjects/displayfile/README.md) - [cat](https://github.com/01-edu/public/tree/master/subjects/cat/README.md) - [ztail](https://github.com/01-edu/public/tree/master/subjects/ztail/README.md) +======= +- bool | https://public.01-edu.org/subjects/bool +- point | https://public.01-edu.org/subjects/point +- displayfile | https://public.01-edu.org/subjects/displayfile +- cat | https://public.01-edu.org/subjects/cat +- ztail | https://public.01-edu.org/subjects/ztail +>>>>>>> refs/remotes/origin/master ### Quest 9 diff --git a/docs/principles.md b/docs/principles.md deleted file mode 100644 index eb247158..00000000 --- a/docs/principles.md +++ /dev/null @@ -1,37 +0,0 @@ -# Principles - -## Make a simple system (less complexity) - -Rationale : - -- Reduce the number of potential bugs and problems -- The remaining bugs will be easier to identify/isolate & fix -- Easier maintenance -- Lower human capital required - -## Limit security & filtering mechanisms - -Especially during the launch, rationale : - -- Reduce complexity (see above) -- Alem is a school, not a bank, so the security requirements are lower -- Some students will be able to bypass security systems in all cases - - And they will spread the word quickly -- The only reliable way to identify students will be security cameras and staff attention - - Students will share accounts and USB drives - - They will open connections to the outside and there is no definitive way to prevent this -- We will "hire" the students who have found vulnerabilities using technical skills and creativity - - We cannot anticipate every breach hundreds of students will find & exploit -- Focus on endpoint security rather than network security (firewall on each node) - - Reduce complexity of the network and make it more flexible - -## Promote open, neutral network & technologies - -Rationale : - -- Students will spend more time learning things and exchanging ideas than bypassing censorship -- Students will have more extensive knowledge and skills -- It is better to make them aware of their situation than to try to stop them -- A student's motivation is very much influenced by his or her environment - - An environment with limitations will limit the spectrum of things that stimulate the student's curiosity -- A focus will made on increasing student's empowerement in order to make them feel accountable for their own actions. If the student cheats, he has to understand that he is only hindering his own progress. diff --git a/docs/responsibilities.md b/docs/responsibilities.md deleted file mode 100644 index cecf4936..00000000 --- a/docs/responsibilities.md +++ /dev/null @@ -1,31 +0,0 @@ -# Responsibilities - -## Alem - -- Hardware - - Maintenance & replacement of parts - - HP machines - - Inventory (associates MAC address or other ID to the physical location of the machine) - - [BIOS configuration](bios-configuration.md) - - Connected on Ethernet network - - Audio & USB extension cables (to protect the PC ports) - - Computers & cables are physically attached to the table (to prevent stealing or damage) - - Monitor brightness (the default might be too high and it cannot be controlled by software) - - Server (virtualized with at least these dedicated resources) - - CPU : 8 threads - - RAM : 64 GB - - SSD : 512 GB - - NIC : pass-through or bridged ? (see with Vitalii) -- Software - - DHCP - - DNS - - PXE - - Image creation & deployment (with the help of team 01) - -## 01 - -- Software maintenance - - Implement the features requested or identified at the Alem School - - Bug fix -- Technical advice -- Pedagogical support diff --git a/docs/reviews.md b/docs/reviews.md index b60b9327..3a9a60f1 100644 --- a/docs/reviews.md +++ b/docs/reviews.md @@ -6,12 +6,12 @@ Only unblocked bonus exercises can be reviewed, which are usually the last items Bonus exercises are available in quests 02 / 03 / 04 / 05 / 07 / 08 / 09. Screenshot 2019-10-17 at 02.43.31 -Making a review involves 2 students who are goning to review each other's exercise. +Making a review involves 2 students who are going to review each other's exercise. Each user has to : -- **check** the code of the other one on Gitea. You must add your reviewer as contributor in your repository so he/she can see your code. -- **bet** if it is going to fail or succeed in the Review interface -- **run** his own exercise in the Review interface to give a result to compare with the bet, and state if it was right or wrong +- **check** the code of the other one on Gitea. **You must add your reviewer as contributor in your repository so he/she can see your code**. +- **bet** if it is going to fail or succeed in the Review interface. +- **run** his own exercise in the Review interface to give a result to compare with the bet, and state if it was right or wrong. ## Usage @@ -23,21 +23,21 @@ Then, when a match with another student who also wants to review is found, you w Screenshot 2019-10-17 at 02.03.11 -Once you and the other student have confirmed the match, you can go and check the code of the other student on his repository in the component `Your review` : +Once you and the other student have confirmed the match, you can go and check the code of the other student on their repository in the component `Your review` : Screenshot 2019-10-17 at 02.05.46 -When you have checked his code, those 4 steps will have to be completed to achieve the review : +When you have checked their code, those 4 steps will have to be completed to achieve the review : - You have to bet if the exercise of the other student will fail or succeed after running the tester - The other student has to do the same with your exercise and make his own bet, that you will see on the component `Review of your exercise` Screenshot 2019-10-17 at 02.20.18 - Once the other student's bet is set, the tester button unblocks and you have to run it on your exercise to output the result determining if your exercise has failed or succeeded ; this result is compared to the other student's bet to determine if it was wrong or right -- The other student also has to run the tester on his exercise to determine his result and so if your bet was wrong or right +- The other student also has to run the tester on their exercise to determine their result and so whether your bet was wrong or right Screenshot 2019-10-17 at 02.22.30 -In fact, a bet is succeeded if it is equal to the tester output : +A bet is considered succeeded if it is equal to the tester output : Screenshot 2019-10-17 at 02.24.04 You can have those 4 cases : diff --git a/docs/server-installation.md b/docs/server-installation.md index 36be1760..a8626d7c 100644 --- a/docs/server-installation.md +++ b/docs/server-installation.md @@ -15,7 +15,6 @@ One domain and one subdomain must point to the IP address of a [dedicated server | Port | Transport | Application | | ---- | --------- | ---------------- | -| 22 | TCP | SSH | | 80 | TCP, UDP | HTTP/(1.1, 2, 3) | | 443 | TCP, UDP | HTTP/(1.1, 2, 3) | | 521 | TCP | SSH | @@ -24,7 +23,7 @@ One domain and one subdomain must point to the IP address of a [dedicated server | Port | Transport | Application | | ---- | --------- | ----------- | -| 465 | TCP | SMTP | +| 587 | TCP | SMTP | ### OS installation diff --git a/docs/server-requirements.md b/docs/server-requirements.md index c6d7fc97..3616c5a4 100644 --- a/docs/server-requirements.md +++ b/docs/server-requirements.md @@ -1,15 +1,12 @@ # Server requirements -Features required : +Features required: - Dedicated hardware -- Linux compatibility -- UEFI -- Secure boot -- TPM 2.0 +- Linux compatible -| Component | Recommended specifications | -| --------- | --------------------------- | -| Processor | 12 threads x86-64 (64 bits) | -| Memory | 16 GB DDR4 | -| Disk | 2 \* 500 GB SSD | +| Component | Minimum specifications | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Processor | 8 threads x86-64 (64 bits), [2200 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1000 single-core score](https://browser.geekbench.com/processor-benchmarks) | +| Memory | 16 GB DDR4 | +| Disk | 2 \* 500 GB SSD | diff --git a/docs/server-room.md b/docs/server-room.md deleted file mode 100644 index fb8e35f3..00000000 --- a/docs/server-room.md +++ /dev/null @@ -1,35 +0,0 @@ -US based, it must be adapted to other countries (in order to avoid voltage problems). - -- UPS ([APC Smart-UPS Li-Ion, Short Depth 1000VA](https://www.apc.com/shop/us/en/products/APC-Smart-UPS-Li-Ion-Short-Depth-1000VA-120V-with-SmartConnect-Not-for-sale-in-Vermont-/P-SMTL1000RM2UC)) ≈ \$1,400.00 -- Router/Firewall ([Netgate XG-7100 1U](https://www.netgate.com/solutions/pfsense/xg-7100-1u.html)) ≈ \$1,000.00 -- Switch ([TP-Link 48-Port Gigabit Switch TL-SG1048](https://www.amazon.com/dp/B004UBUJZG)) ≈ \$220.00 - - Quantity : round(_number of students_ / 48 + 1) -- Server ([Dell EMC PowerEdge R340](https://www.dell.com/en-us/work/shop/servers-storage-and-networking/poweredge-r340-rack-server/spd/poweredge-r340/pe_r340_13158_vi_vp)) ≈ \$3,000.00 - - Trusted Platform Module (TPM) - - Trusted Platform Module 2.0 - - Chassis - - 2.5" Chassis with up to 8 Hot Plug Hard Drives - - Processor - - Intel® Xeon® E-2246G 3.6GHz, 12M cache, 6C/12T, turbo (80W) - - Memory - - 16GB 2666MT/s DDR4 ECC UDIMM - - Quantity : 2 - - RAID - - No RAID - - RAID/Internal Storage Controllers - - PERC H330 RAID Controller, Adapter - - Hard Drive - - 480GB SSD SATA Mix Use 6Gbps 512 2.5in Hot-plug AG Drive, 3 DWPD, 2628 TBW - - Quantity : 2 - - Power Supply - - Dual, Hot Plug, Redundant Power Supply (1+1), 550W - - Bezel - - PowerEdge 1U Standard Bezel - - ProSupport and Next Business Day Onsite Service, 60 Month(s) -- etc - - Rack Enclosure ≈ \$500.00 - - PDU - - Cable Manager - - Cable Organizer - - Cable Pass-Through Panel - - Roof Fan Tray diff --git a/docs/ubuntu-installation.md b/docs/ubuntu-installation.md index 55621887..a4437f0f 100644 --- a/docs/ubuntu-installation.md +++ b/docs/ubuntu-installation.md @@ -31,10 +31,8 @@ You can add your public SSH key to access the administrator account later: ```shell unset HISTFILE sudo mkdir /root/.ssh -wget github.com/xpetit.keys -cat xpetit.keys | sudo tee /root/.ssh/authorized_keys +sudo wget github.com/xpetit.keys --output-document !$/authorized_keys sudo chmod 400 !$ -rm xpetit.keys ``` ## OS configuration diff --git a/sh/debian/ubuntu/common_packages.txt b/sh/debian/ubuntu/common_packages.txt index 41912a17..07626ac4 100644 --- a/sh/debian/ubuntu/common_packages.txt +++ b/sh/debian/ubuntu/common_packages.txt @@ -24,7 +24,6 @@ isc-dhcp-client isc-dhcp-common jq less -libsdl2-dev linux-headers-generic linux-image-generic lm-sensors diff --git a/sh/debian/ubuntu/configure.sh b/sh/debian/ubuntu/configure.sh index 16852a16..fa6716b2 100755 --- a/sh/debian/ubuntu/configure.sh +++ b/sh/debian/ubuntu/configure.sh @@ -325,7 +325,6 @@ gimp gnome-calculator gnome-system-monitor gnome-tweaks -golang-mode i3lock imagemagick mpv @@ -434,6 +433,11 @@ cd /tmp/system cp --preserve=mode -RT . / +cd /usr/local/src/format +PATH=$PATH:/usr/local/go/bin +go mod download +go build -o /usr/local/bin/format + cd "$script_dir" rm -rf /tmp/system @@ -482,6 +486,9 @@ if ! test -v PERSISTENT; then gpasswd -d student lpadmin gpasswd -d student sambashare + # Give to rights to use format tool + echo 'student ALL = (root) NOPASSWD: /usr/local/bin/format' >> /etc/sudoers + cp /etc/shadow /etc/shadow- fi diff --git a/sh/debian/ubuntu/system/usr/local/src/format/go.mod b/sh/debian/ubuntu/system/usr/local/src/format/go.mod new file mode 100644 index 00000000..dcfbc9d9 --- /dev/null +++ b/sh/debian/ubuntu/system/usr/local/src/format/go.mod @@ -0,0 +1,5 @@ +module main + +go 1.16 + +require github.com/olekukonko/tablewriter v0.0.5 diff --git a/sh/debian/ubuntu/system/usr/local/src/format/go.sum b/sh/debian/ubuntu/system/usr/local/src/format/go.sum new file mode 100644 index 00000000..56c7ba45 --- /dev/null +++ b/sh/debian/ubuntu/system/usr/local/src/format/go.sum @@ -0,0 +1,4 @@ +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= diff --git a/sh/debian/ubuntu/system/usr/local/src/format/main.go b/sh/debian/ubuntu/system/usr/local/src/format/main.go new file mode 100644 index 00000000..c1406738 --- /dev/null +++ b/sh/debian/ubuntu/system/usr/local/src/format/main.go @@ -0,0 +1,231 @@ +package main + +import ( + "bufio" + "encoding/json" + "errors" + "fmt" + "math" + "os" + "os/exec" + "strconv" + "strings" + + "github.com/olekukonko/tablewriter" +) + +func fatalln(a ...interface{}) { + fmt.Println(a...) + os.Exit(1) +} + +func expect(target, err error, action string) { + if err != nil && err != target && !errors.Is(err, target) { + fatalln("Failed to", action, ":", err) + } +} + +func renderTable(data [][]string) { + table := tablewriter.NewWriter(os.Stdout) + table.SetColumnSeparator(" ") + table.SetCenterSeparator(" ") + table.SetRowSeparator(" ") + table.SetAlignment(tablewriter.ALIGN_CENTER) + table.SetHeader(data[0]) + for _, row := range data[1:] { + table.Append(row) + } + table.Render() +} + +// run returns the output of the command +// In case of error, display the description, the command and the error +func run(description, name string, arg ...string) []byte { + b, err := exec.Command(name, arg...).CombinedOutput() + if err != nil { + fmt.Println("Failed to", description) + fmt.Printf("%s %#v\n", name, arg) + if _, ok := err.(*exec.ExitError); ok { + fatalln(string(b)) + } + fatalln(err) + } + return b +} + +type ( + size int + stringTrim string + + device struct { + Path string // path to the device node + RO bool // read-only device + RM bool // removable device + Hotplug bool // removable or hotplug device (usb, pcmcia, ...) + Model stringTrim // device identifier + Size size // size of the device + Type string // device type + Tran string // device transport type + Vendor stringTrim // device vendor + } +) + +func (s stringTrim) String() string { + return strings.TrimSpace(string(s)) +} + +// format size with SI prefix +func (s size) String() string { + f := float64(s) + if f < 0 { + f = 0 + } + unit := " kMGTPEZY" + for f >= 1000 { + unit = unit[1:] + f /= 1000 + } + var prec int + if unit[0] != ' ' && math.Round(f) < 10 { + prec = 1 + } + return fmt.Sprintf("%.*f %cB", prec, f, unit[0]) +} + +func main() { + // Usage + fmt.Println("While using this formatting tool:") + fmt.Println(" - do not plug/unplug any drive") + fmt.Println(" - make sure the drive is not in use") + fmt.Print("Press ENTER to continue") + bufio.NewScanner(os.Stdin).Scan() + + // Get a list of the block devices + var data struct { + Blockdevices []device + } + b := run("list the block devices", + "lsblk", + "--all", + "--bytes", + "--nodeps", + "--json", + "--output", "path,ro,rm,hotplug,model,size,type,tran,vendor", + ) + expect(nil, json.Unmarshal(b, &data), "list the block devices") + + // Filter the block devices to get only the USB flash drives + var devices []device + for _, device := range data.Blockdevices { + if !device.RO && device.RM && device.Hotplug && device.Type == "disk" && device.Tran == "usb" { + devices = append(devices, device) + } + } + + // If no USB flash drive is found, exit the program with an explanation + if len(devices) == 0 { + fmt.Println("No available USB devices were found.") + if len(data.Blockdevices) > 0 { + fmt.Println("Here is a list of the block devices found:") + table := [][]string{{"Path", "RO", "RM", "Hotplug", "Model", "Size", "Type", "Tran", "Vendor"}} + for _, device := range data.Blockdevices { + table = append(table, []string{ + device.Path, + strconv.FormatBool(device.RO), + strconv.FormatBool(device.RM), + strconv.FormatBool(device.Hotplug), + device.Model.String(), + device.Size.String(), + device.Type, + device.Tran, + device.Vendor.String(), + }) + } + renderTable(table) + } + return + } + + // Display the found USB flash drives + table := [][]string{{"Number", "Vendor", "Model", "Size"}} + for i, device := range devices { + table = append(table, []string{ + strconv.Itoa(i), + device.Vendor.String(), + device.Model.String(), + device.Size.String(), + }) + } + renderTable(table) + + // Select the USB flash drive to format + fmt.Println(`Enter the number of the disk you want to format (or "exit"):`) + var choice string + fmt.Scanln(&choice) + if strings.ToLower(choice) == "exit" { + return + } + var nb int + nb, err := strconv.Atoi(choice) + if err != nil || nb < 0 || nb >= len(devices) { + fatalln("Wrong disk number:", choice) + } + device := devices[nb] + + // Get a list of the USB flash drive mount points + b, err = os.ReadFile("/proc/mounts") + expect(nil, err, "list the mount points") + lines := strings.Split(string(b), "\n") + var mountPoints []string + for _, line := range lines { + fields := strings.Fields(line) + if len(fields) < 2 { + continue + } + deviceName := fields[0] + mountPoint := fields[1] + if strings.Contains(deviceName, device.Path) { + mountPoints = append(mountPoints, mountPoint) + } + } + + // Unmount the USB flash drive + if len(mountPoints) > 0 { + mountPointOccurrences := map[string]int{} + for _, mountPoint := range mountPoints { + mountPoint = mountPoint[1:] // remove leading '/' + parts := strings.Split(mountPoint, "/") + for i := 1; i <= len(parts); i++ { + mountPointOccurrences[strings.Join(parts[:i], "/")]++ + } + } + for mountPoint, occurrences := range mountPointOccurrences { + parts := strings.Split(mountPoint, "/") + for i := len(parts) - 1; i > 0; i-- { + parent := strings.Join(parts[:i], "/") + if occurrences < mountPointOccurrences[parent] { + delete(mountPointOccurrences, mountPoint) + } else { + delete(mountPointOccurrences, parent) + } + } + } + for mountPoint := range mountPointOccurrences { + mountPoint = "/" + mountPoint // put back leading '/' + fmt.Print("The selected device is mounted on ", mountPoint, ". Trying to unmount it... ") + run("umount the selected device", "umount", "--recursive", mountPoint) + fmt.Println("done") + } + } + + // Format USB flash drive + fmt.Print("Formatting... ") + run("erase disk data", "wipefs", "--all", device.Path) + run("erase disk data", "sgdisk", "--zap-all", device.Path) + run("create partition table", "sgdisk", "--largest-new", "0", device.Path) + run("create partition table", "sgdisk", "--change-name", "1:01-home", device.Path) + run("inform the OS of partition table changes", "partx", "--update", device.Path) + run("format partition", "mkfs.f2fs", "-f", device.Path+"1") + fmt.Println("done") + fmt.Println(device.Vendor, device.Model, device.Size, "has been formatted, logout and login to use it") +} diff --git a/sh/tests/cl-camp1_test.sh b/sh/tests/cl-camp1_test.sh index 80823846..92305910 100755 --- a/sh/tests/cl-camp1_test.sh +++ b/sh/tests/cl-camp1_test.sh @@ -8,8 +8,8 @@ IFS=' script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) challenge() { - submitted=$(cd "$1" && "$script_dirS"/student/mastertheLS) - expected=$(cd "$1" && "$script_dirS"/solutions/mastertheLS) + submitted=$(cd "$1" && bash "$script_dirS"/student/mastertheLS) + expected=$(cd "$1" && bash "$script_dirS"/solutions/mastertheLS) diff <(echo "$submitted") <(echo "$expected") } diff --git a/sh/tests/cl-camp3_test.sh b/sh/tests/cl-camp3_test.sh index 00a5cba4..26a09150 100755 --- a/sh/tests/cl-camp3_test.sh +++ b/sh/tests/cl-camp3_test.sh @@ -8,8 +8,8 @@ IFS=' script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) challenge() { - submitted=$(cd "$1" && "$script_dirS"/student/look) - expected=$(cd "$1" && "$script_dirS"/solutions/look) + submitted=$(cd "$1" && bash "$script_dirS"/student/look) + expected=$(cd "$1" && bash "$script_dirS"/solutions/look) diff <(echo "$submitted") <(echo "$expected") } diff --git a/sh/tests/cl-camp4_test.sh b/sh/tests/cl-camp4_test.sh index fe38c702..c7dd907c 100755 --- a/sh/tests/cl-camp4_test.sh +++ b/sh/tests/cl-camp4_test.sh @@ -9,8 +9,8 @@ echo insecure >> ~/.curlrc caddy start &>/dev/null challenge() { - submitted=$(./student/myfamily.sh) - expected=$(./solutions/myfamily.sh) + submitted=$(bash student/myfamily.sh) + expected=$(bash solutions/myfamily.sh) diff <(echo "$submitted") <(echo "$expected") } diff --git a/sh/tests/cl-camp5_test.sh b/sh/tests/cl-camp5_test.sh index de406c3d..b141b113 100755 --- a/sh/tests/cl-camp5_test.sh +++ b/sh/tests/cl-camp5_test.sh @@ -8,8 +8,8 @@ IFS=' script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) challenge() { - submitted=$(cd "$1" && "$script_dirS"/student/lookagain.sh) - expected=$(cd "$1" && "$script_dirS"/solutions/lookagain.sh) + submitted=$(cd "$1" && bash "$script_dirS"/student/lookagain.sh) + expected=$(cd "$1" && bash "$script_dirS"/solutions/lookagain.sh) diff <(echo "$submitted") <(echo "$expected") } diff --git a/sh/tests/cl-camp6_test.sh b/sh/tests/cl-camp6_test.sh index 6e1b7602..3c0faa6a 100755 --- a/sh/tests/cl-camp6_test.sh +++ b/sh/tests/cl-camp6_test.sh @@ -8,8 +8,8 @@ IFS=' script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) challenge() { - submitted=$(cd "$1" && "$script_dirS"/student/countfiles.sh) - expected=$(cd "$1" && "$script_dirS"/solutions/countfiles.sh) + submitted=$(cd "$1" && bash "$script_dirS"/student/countfiles.sh) + expected=$(cd "$1" && bash "$script_dirS"/solutions/countfiles.sh) diff <(echo "$submitted") <(echo "$expected") } diff --git a/sh/tests/cl-camp8_test.sh b/sh/tests/cl-camp8_test.sh index c40837f0..3391a2df 100755 --- a/sh/tests/cl-camp8_test.sh +++ b/sh/tests/cl-camp8_test.sh @@ -7,7 +7,7 @@ IFS=' cd cl-camp8 -submitted=$(../student/skip.sh) -expected=$(../solutions/skip.sh) +submitted=$(bash ../student/skip.sh) +expected=$(bash ../solutions/skip.sh) diff <(echo "$submitted") <(echo "$expected") diff --git a/sh/tests/explain_test.sh b/sh/tests/explain_test.sh index c6e350f9..b5aeba02 100755 --- a/sh/tests/explain_test.sh +++ b/sh/tests/explain_test.sh @@ -5,8 +5,8 @@ set -euo pipefail IFS=' ' -submitted=$(student/explain.sh) -expected=$(solutions/explain.sh) +submitted=$(bash student/explain.sh) +expected=$(bash solutions/explain.sh) if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then echo "Wrong answer, detective." diff --git a/sh/tests/introduction_test.sh b/sh/tests/introduction_test.sh index 0266e003..e79dc800 100755 --- a/sh/tests/introduction_test.sh +++ b/sh/tests/introduction_test.sh @@ -5,7 +5,7 @@ set -euo pipefail IFS=' ' -submitted=$(./student/hello.sh) -expected=$(./solutions/hello.sh) +submitted=$(bash student/hello.sh) +expected=$(bash solutions/hello.sh) diff <(echo "$submitted") <(echo "$expected") | cat -t diff --git a/sh/tests/now-get-to-work_test.sh b/sh/tests/now-get-to-work_test.sh index 7313f2e1..efe236a3 100755 --- a/sh/tests/now-get-to-work_test.sh +++ b/sh/tests/now-get-to-work_test.sh @@ -5,8 +5,8 @@ set -euo pipefail IFS=' ' -submitted=$(student/my_answer.sh) -expected=$(solutions/my_answer.sh) +submitted=$(bash student/my_answer.sh) +expected=$(bash solutions/my_answer.sh) if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then echo "Wrong answer, detective." diff --git a/sh/tests/solutions/to-git-or-not-to-git.sh b/sh/tests/solutions/to-git-or-not-to-git.sh index 3c3be711..0f54959b 100755 --- a/sh/tests/solutions/to-git-or-not-to-git.sh +++ b/sh/tests/solutions/to-git-or-not-to-git.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -curl -s "https://$DOMAIN/api/graphql-engine/v1/graphql" --data '{"query":"{user(where:{githubLogin:{_eq:\"'$USERNAME'\"}}){id}}"}' | jq '.data.user[0].id' +curl -s "https://$DOMAIN/api/graphql-engine/v1/graphql" --data '{"query":"{user(where:{login:{_eq:\"'$USERNAME'\"}}){id}}"}' | jq '.data.user[0].id' diff --git a/sh/tests/teacher_test.sh b/sh/tests/teacher_test.sh index 4dde58be..ca8153fc 100755 --- a/sh/tests/teacher_test.sh +++ b/sh/tests/teacher_test.sh @@ -7,10 +7,9 @@ IFS=' script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) - challenge() { - submitted=$(cd "$1" && "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1) - expected=$(cd "$1" && "$script_dirS"/solutions/teacher.sh) + submitted=$(cd "$1" && bash "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1) + expected=$(cd "$1" && bash "$script_dirS"/solutions/teacher.sh) if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then echo "??? What ?? Wrong answer, teacher. Did you really do the job previously? Or was is just an \"echo\" of luck??" diff --git a/sh/tests/to-git-or-not-to-git_test.sh b/sh/tests/to-git-or-not-to-git_test.sh index bc302ca1..b319d6ed 100755 --- a/sh/tests/to-git-or-not-to-git_test.sh +++ b/sh/tests/to-git-or-not-to-git_test.sh @@ -5,7 +5,7 @@ set -euo pipefail IFS=' ' -submitted=$(./student/to-git-or-not-to-git.sh) -expected=$(./solutions/to-git-or-not-to-git.sh) +submitted=$(bash student/to-git-or-not-to-git.sh) +expected=$(bash solutions/to-git-or-not-to-git.sh) diff <(echo "$submitted") <(echo "$expected") diff --git a/sh/tests/who-are-you_test.sh b/sh/tests/who-are-you_test.sh index 14cc0c8b..b4e161d4 100755 --- a/sh/tests/who-are-you_test.sh +++ b/sh/tests/who-are-you_test.sh @@ -8,8 +8,8 @@ IFS=' echo insecure >> ~/.curlrc caddy start &>/dev/null -submitted=$(./student/who-are-you.sh) -expected=$(./solutions/who-are-you.sh) +submitted=$(bash student/who-are-you.sh) +expected=$(bash solutions/who-are-you.sh) caddy stop &>/dev/null diff --git a/subjects/abort/README.md b/subjects/abort/README.md index a5a9d939..c6ba2909 100644 --- a/subjects/abort/README.md +++ b/subjects/abort/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that returns the median of 5 five arguments. +Write a function that returns the median of five `int` arguments. ### Expected function diff --git a/subjects/alphamirror/README.md b/subjects/alphamirror/README.md index 9cc8a414..2508e3de 100644 --- a/subjects/alphamirror/README.md +++ b/subjects/alphamirror/README.md @@ -4,7 +4,7 @@ Write a program called `alphamirror` that takes a `string` as argument and displays this `string` after replacing each alphabetical character with the opposite alphabetical character. -The case of the letter stays the same, for example : +The case of the letter remains unchanged, for example : 'a' becomes 'z', 'Z' becomes 'A' 'd' becomes 'w', 'M' becomes 'N' diff --git a/subjects/ascii-art/README.md b/subjects/ascii-art/README.md index 34696297..1d984601 100644 --- a/subjects/ascii-art/README.md +++ b/subjects/ascii-art/README.md @@ -2,26 +2,40 @@ ### Objectives -Ascii-art consists on receiving a `string` as an argument and outputting the `string` in a graphic representation of ASCII. - -- This project should handle numbers, letters, spaces, special characters and `\n`. +Ascii-art is a program which consists in receiving a `string` as an argument and outputting the `string` in a graphic representation using ASCII. Time to write big. + +What we mean by a graphic representation using ASCII, is to write the `string` received using ASCII characters, as you can see in the example below: + +```````````console +@@@@@@BB@@@@``^^``^^``@@BB$$@@BB$$ +@@%%$$$$^^^^WW&&8888&&^^""BBBB@@@@ +@@@@@@""WW8888&&WW888888WW``@@@@$$ +BB$$``&&&&WWWW8888&&&&8888&&``@@@@ +$$``&&WW88&&88&&&&8888&&88WW88``$$ +@@""&&&&&&&&88888888&&&&&&88&&``$$ +``````^^``^^^^^^````""^^``^^``^^`` +""WW^^@@@@^^``````^^BB@@^^``^^&&`` +^^&&^^@@````^^``&&``@@````^^^^&&`` +``WW&&^^""``^^WW&&&&""``^^^^&&88`` +^^8888&&&&&&WW88&&88WW&&&&88&&WW`` +@@``&&88888888WW&&WW88&&88WW88^^$$ +@@""88&&&&&&&&888888&&``^^&&88``$$ +@@@@^^&&&&&&""``^^^^^^8888&&^^@@@@ +@@@@@@^^888888&&88&&&&MM88^^BB$$$$ +@@@@@@BB````&&&&&&&&88""``BB@@BB$$ +$$@@$$$$$$$$``````````@@$$@@$$$$$$ +``````````` + +- This project should handle an input with numbers, letters, spaces, special characters and `\n`. - Take a look at the ASCII manual. -This project will help you learn about : - -- The Go file system(**fs**) API. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Manipulation of structures. - ### Instructions - Your project must be written in **Go**. - The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices/). - It is recommended that the code present a **test file**. -- It will be given some [**banner**](https://github.com/01-edu/public/blob/master/subjects/ascii-art) files with a specific graphical template representation of ASCII. The files are formatted in a way that it is not necessary to change them. +- Some [**banner**](https://github.com/01-edu/public/blob/master/subjects/ascii-art) files (.txt files) with a specific graphical template representation using ASCII will be given. The files are formatted in a way that is not necessary to change them. ### Banner Format @@ -58,7 +72,6 @@ This project will help you learn about : ...... ...... -etc ``` ### Allowed packages @@ -115,3 +128,8 @@ $ go run . "{Hello There}" $ ``` + +This project will help you learn about : + +- The Go file system(**fs**) API +- Data manipulation diff --git a/subjects/ascii-art/color/README.md b/subjects/ascii-art/color/README.md index e929ff05..ac8302ac 100644 --- a/subjects/ascii-art/color/README.md +++ b/subjects/ascii-art/color/README.md @@ -2,24 +2,12 @@ ### Objectives -You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject but with colors. +You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject but this time with colors. -- The output should manipulate colors using the **flag** `--color=`, in which `--color` is the flag and `` is the color - desired by the user. -- The colors can be done using different notations (color code systems, like `RGB`, `hsl`, `ANSI`, ...), its up to you to - choose which one you want to use. -- You should be able to specify a single or a set of letters you want to be colored (use your imagination for this one). -- If the letter isn't specified, the whole `string` should be colored. - -This project will help you learn about : +The output should manipulate colors using the **flag** `--color=`, in which `--color` is the flag and `` is the color desired by the user. These colors can be achieved using different notations (color code systems, like `RGB`, `hsl`, `ANSI`...), it is up to you to choose which one you want to use. -- The Go file system(**fs**) API. -- Color converters. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Manipulation of colors on the terminal. -- Manipulation of structures. +- You should be able to specify a single or a set of letters you want to be colored (use your imagination for this one). +- If the letter is not specified, the whole `string` should be colored. ### Instructions @@ -30,3 +18,10 @@ This project will help you learn about : ### Allowed packages - Only the [standard go](https://golang.org/pkg/) packages are allowed + +This project will help you learn about : + +- The Go file system(**fs**) API +- Color converters +- Data manipulation +- Terminal display diff --git a/subjects/ascii-art/fs/README.md b/subjects/ascii-art/fs/README.md index 9fafef05..52eec813 100644 --- a/subjects/ascii-art/fs/README.md +++ b/subjects/ascii-art/fs/README.md @@ -2,15 +2,7 @@ ### Objectives -You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject but the second argument must be the name of the template. - -This project will help you learn about : - -- The Go file system(**fs**) API. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Manipulation of structures. +You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject but the second argument must be the name of the template. I know some templates may be hard to read, just do not obsess about it. Please... ### Instructions @@ -58,3 +50,8 @@ o o o-o o o o-o o o o o-o o o-o $ ``` + +This project will help you learn about : + +- The Go file system(**fs**) API +- Data manipulation diff --git a/subjects/ascii-art/justify/README.md b/subjects/ascii-art/justify/README.md index 3b6cb656..da8ce356 100644 --- a/subjects/ascii-art/justify/README.md +++ b/subjects/ascii-art/justify/README.md @@ -2,7 +2,15 @@ ### Objectives -You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/ascii-art.en) as in the first subject but the representation should be formatted using a **flag** `--align=`, in which `type` can be : +You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art) as in the first subject but the alignment can be changed. + +```console +We + will + explain! +``` + +To change the alignment of the output it must be possible to use a **flag** `--align=`, in which `type` can be : - center - left @@ -11,18 +19,10 @@ You must follow the same [instructions](https://public.01-edu.org/subjects/ascii - You must adapt your representation to the terminal size. If you reduce the terminal window the graphical representation should be adapted to the terminal size. -This project will help you learn about : - -- The Go file system(**fs**) API. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Manipulation of structures. - ### Instructions - Your project must be written in **Go**. -- The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices.en). +- The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices). - It is recommended that the code should present a **test file**. ### Allowed packages @@ -31,6 +31,8 @@ This project will help you learn about : ### Usage +Assume the bars in the display below are the terminal borders: + ```console |$ go run . "hello" standard --align=center | | _ _ _ | @@ -70,3 +72,9 @@ This project will help you learn about : | _|_| | |$ | ``` + +This project will help you learn about : + +- The Go file system(**fs**) API +- Data manipulation +- Terminal display diff --git a/subjects/ascii-art/output/README.md b/subjects/ascii-art/output/README.md index 68afb1a6..cd5df987 100644 --- a/subjects/ascii-art/output/README.md +++ b/subjects/ascii-art/output/README.md @@ -2,17 +2,9 @@ ### Objectives -- You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject **while** writing the result into a file. +- You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject **while** writing the result into a file. Yep, you will read from one file and write to another. -- The file must be named by using the flag `--output=`, in which `--output` is the flag and `` is the file name. - -This project will help you learn about : - -- The Go file system(**fs**) API. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Choices of outputs. +The file must be named by using the flag `--output=`, in which `--output` is the flag and `` is the file name which will contain the output. ### Instructions @@ -51,3 +43,8 @@ _| _| _|_|_| _| _| _|_| _| _| _| _|_|_| _| _ $ ``` + +This project will help you learn about : + +- The Go file system(**fs**) API +- Data manipulation diff --git a/subjects/ascii-art/reverse/README.md b/subjects/ascii-art/reverse/README.md index e46ebdc3..e93130e2 100644 --- a/subjects/ascii-art/reverse/README.md +++ b/subjects/ascii-art/reverse/README.md @@ -2,20 +2,11 @@ ### Objectives -You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject. +You must follow the same [instructions](https://public.01-edu.org/subjects/ascii-art/) as in the first subject but this time the process will be reversed. desrever fo dnik siht toN. -- Ascii-reverse consists on reversing the process, converting the graphic representation into a text. -- You will have to create a text file containing a graphic representation of a random `string`. -- The argument will be a **flag**, `--reverse=`, in which `--reverse` is the flag and `` is the file name. -- The program must print this `string` in **normal text**. +Ascii-reverse consists on reversing the process, converting the graphic representation into a text. You will have to create a text file containing a graphic representation of a random `string` given as an argument. -This project will help you learn about : - -- The Go file system(**fs**) API. -- Ways to receive data. -- Ways to output data. -- Manipulation of strings. -- Manipulation of structures. +The argument will be a **flag**, `--reverse=`, in which `--reverse` is the flag and `` is the file name. The program must then print this `string` in **normal text**. ### Instructions @@ -44,3 +35,8 @@ $ go run . --reverse=file.txt hello $ ``` + +This project will help you learn about : + +- The Go file system(**fs**) API +- Data manipulation diff --git a/subjects/atoi/README.md b/subjects/atoi/README.md index 19da105d..b7367c6d 100644 --- a/subjects/atoi/README.md +++ b/subjects/atoi/README.md @@ -6,7 +6,7 @@ - `Atoi` returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested**. Some will contain non-digits characters. -- For this exercise the handling of the signs + or - **does have** to be taken into account. +- For this exercise the handling of the signs `+` or `-` **does have** to be taken into account. - This function will **only** have to return the `int`. For this exercise the `error` result of `Atoi` is not required. diff --git a/subjects/chunk/README.md b/subjects/chunk/README.md index 2b2db41d..7a05a106 100644 --- a/subjects/chunk/README.md +++ b/subjects/chunk/README.md @@ -2,9 +2,9 @@ ### Instructions -Write a function called `Chunk` that receives as parameters a slice, `slice []int`, and an number `size int`. The goal of this function is to chunk a slice into many sub slices where each sub slice has the length of `size`. +Write a function called `Chunk` that receives as parameters a slice, `slice []int`, and a number `size int`. The goal of this function is to chunk a slice into many sub slices where each sub slice has the length of `size`. -- If the `size` is `0` it should print `\n` +- If the `size` is `0` it should print a newline (`'\n'`). ### Expected function diff --git a/subjects/cl-camp1/README.md b/subjects/cl-camp1/README.md index d559cec0..bf8be930 100644 --- a/subjects/cl-camp1/README.md +++ b/subjects/cl-camp1/README.md @@ -12,8 +12,8 @@ Put in a file `mastertheLS` the command line that will: - list the files and directories of the current directory. - Ignore the hidden files, the "." and the "..". -- Separates the resuls with commas. -- Order them by ascending order of creation date. +- Separates the results with commas. +- Order them by ascending order of creation date (the newest first). - Have the directories ends with a `/`. ### Hint diff --git a/subjects/cl-camp5/README.md b/subjects/cl-camp5/README.md index d5b91a5f..5878a669 100644 --- a/subjects/cl-camp5/README.md +++ b/subjects/cl-camp5/README.md @@ -4,11 +4,12 @@ "keep looking..." -Create a file `lookagain.sh`, which will look for, from the current directory and its sub-folders all the files: +Create a file `lookagain.sh`, which will look, from the current directory and its sub-folders for: - all the files ending with `.sh`. That command will only show the name of the files without the `.sh`. +The files will be in ascending order (as shown in the below example). ### Usage diff --git a/subjects/comcheck/README.md b/subjects/comcheck/README.md index a468d465..7988f911 100644 --- a/subjects/comcheck/README.md +++ b/subjects/comcheck/README.md @@ -6,7 +6,7 @@ Write a program `comcheck` that displays on the standard output `Alert!!!` follo - `01`, `galaxy` or `galaxy 01`. -- If none of the parameters match, the program displays a nothing. +- If none of the parameters match, the program displays nothing. ### Usage diff --git a/subjects/countif/README.md b/subjects/countif/README.md index c9c0f1d5..5a62994f 100644 --- a/subjects/countif/README.md +++ b/subjects/countif/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function `CountIf` that returns the number of elements of a `string` slice for which the `f` function returns `true`. +Write a function `CountIf` that returns, the number of elements of a `string` slice, for which the `f` function returns `true`. ### Expected function diff --git a/subjects/displayz/README.md b/subjects/displayz/README.md index 621bdb67..efe036b7 100644 --- a/subjects/displayz/README.md +++ b/subjects/displayz/README.md @@ -4,7 +4,7 @@ Write a program that takes a `string`, and displays the first `z` character it encounters in it, followed by a newline (`'\n'`). If there are no `z` characters in the string, the program just writes `z` followed by a newline (`'\n'`). -If the number of arguments is not 1, the program displays an `z` followed by a newline (`'\n'`). +If the number of arguments is not 1, the program displays a `z` followed by a newline (`'\n'`). ### Usage diff --git a/subjects/doop/README.md b/subjects/doop/README.md index b6967dfc..c2dd2e91 100644 --- a/subjects/doop/README.md +++ b/subjects/doop/README.md @@ -10,7 +10,7 @@ The program has to be used with three arguments: - An operator, one of : `+`, `-`, `/`, `*`, `%` - Another value -In case of an invalid operator, value, number of arguments or an overflow the programs prints nothing. +In case of an invalid operator, value, number of arguments or an overflow, the programs prints nothing. The program has to handle the modulo and division operations by 0 as shown on the output examples below. diff --git a/subjects/expandstr/README.md b/subjects/expandstr/README.md index daf8aee9..dd8d174d 100644 --- a/subjects/expandstr/README.md +++ b/subjects/expandstr/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a program that takes a `string` and displays it with exactly three spaces between each word, with no spaces or tabs at either the beginning nor the end. +Write a program that takes a `string` and displays it with exactly three spaces between each word, with no spaces nor tabs at neither the beginning nor the end. The `string` will be followed by a newline (`'\n'`). diff --git a/subjects/explain/README.md b/subjects/explain/README.md index 3cd09cc6..d35dce50 100644 --- a/subjects/explain/README.md +++ b/subjects/explain/README.md @@ -8,7 +8,7 @@ The commissioner thanks you for delivering the suspect. He now asks you how did you get onto his trail. -Write an `explain.sh` file that: +Write an `explain.sh` file that in this order: - displays the first and last name of your key witness - displays the interview number of this witness diff --git a/subjects/fibonacci/README.md b/subjects/fibonacci/README.md index 959a72a3..cb90c944 100644 --- a/subjects/fibonacci/README.md +++ b/subjects/fibonacci/README.md @@ -2,7 +2,7 @@ ### Instructions -Write an **recursive** function that returns the value of fibonacci sequence matching the index passed as parameter. +Write a **recursive** function that returns the value of the fibonacci sequence matching the index passed as parameter. The first value is at index `0`. diff --git a/subjects/flags/README.md b/subjects/flags/README.md index cfed2dec..8a4a9468 100644 --- a/subjects/flags/README.md +++ b/subjects/flags/README.md @@ -8,7 +8,7 @@ This program should : - Insert the string given to the `--insert` (or `-i`), in the `string` argument, if given. - Order the `string` argument (in ASCII order) if given the flag `--order` (or `-o`). -- In case there are no arguments or the flag `--help` (or `-h`) is given, it should print the options, as shown in the example. +- In case there are no arguments or if the flag `--help` (or `-h`) is given, it should print the options, as shown in the example. Example of output : diff --git a/subjects/foldint/README.md b/subjects/foldint/README.md index aec767dc..efdd1be6 100644 --- a/subjects/foldint/README.md +++ b/subjects/foldint/README.md @@ -2,7 +2,7 @@ ### Instructions -The function should have as parameters a function, `f func(int, int) int` a slice of integers, `slice []int` and an int `acc int`. You should apply for each element of the slice the arithmetic function, saving and printing it. The function will be tested with our own functions `Add, Sub, and Mul`. +The function should have as parameters a function, `f func(int, int) int` a slice of integers, `slice []int` and an int `acc int`. For each element of the slice, it should apply the arithmetic function, save the result and print it. The function will be tested with our own functions `Add, Sub, and Mul`. ### Expected function diff --git a/subjects/forum/advanced-features/README.md b/subjects/forum/advanced-features/README.md index f48f40d7..75ded1de 100644 --- a/subjects/forum/advanced-features/README.md +++ b/subjects/forum/advanced-features/README.md @@ -33,4 +33,7 @@ This project will help you learn about : ### Allowed packages -- The [standard go](https://golang.org/pkg/) packages are allowed +- All [standard go](https://golang.org/pkg/) packages are allowed. +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid \ No newline at end of file diff --git a/subjects/forum/authentication/README.md b/subjects/forum/authentication/README.md index feb9cbd4..efc04045 100644 --- a/subjects/forum/authentication/README.md +++ b/subjects/forum/authentication/README.md @@ -20,3 +20,10 @@ This project will help you learn about: - Your project must have implemented at least the two authentication examples given. - Your project must be written in **Go**. - The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices/). + +### Allowed packages + +- All [standard go](https://golang.org/pkg/) packages are allowed. +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid \ No newline at end of file diff --git a/subjects/forum/image-upload/README.md b/subjects/forum/image-upload/README.md index f3b037cf..ed48a403 100644 --- a/subjects/forum/image-upload/README.md +++ b/subjects/forum/image-upload/README.md @@ -30,4 +30,7 @@ This project will help you learn about: ### Allowed packages -- Only the [standard go](https://golang.org/pkg/) packages are allowed +- All [standard go](https://golang.org/pkg/) packages are allowed. +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid \ No newline at end of file diff --git a/subjects/forum/moderation/README.md b/subjects/forum/moderation/README.md index af42fa23..36d267ef 100644 --- a/subjects/forum/moderation/README.md +++ b/subjects/forum/moderation/README.md @@ -39,13 +39,16 @@ This project will help you learn about : - Moderation System - User access levels -### Allowed packages - -- All [standard go](https://golang.org/pkg/) packages are allowed. - ### Instructions - You must handle website errors, HTTPS status. - You must handle all sort of technical errors. - The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices/). - It is recommended that the code should present a **test file**. + +### Allowed packages + +- All [standard go](https://golang.org/pkg/) packages are allowed. +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid diff --git a/subjects/fprime/README.md b/subjects/fprime/README.md index f6054971..64d0c13e 100644 --- a/subjects/fprime/README.md +++ b/subjects/fprime/README.md @@ -6,7 +6,7 @@ Write a program that takes a positive `int` and displays its prime factors, foll - Factors must be displayed in ascending order and separated by `*`. -- If the number of arguments is different from 1, if the argument is invalid or if the integer doesn't have a prime factor, the program displays nothing. +- If the number of arguments is different from 1, if the argument is invalid, or if the integer does not have a prime factor, the program displays nothing. ### Usage diff --git a/subjects/graphql/README.md b/subjects/graphql/README.md index c31f40da..76b7a470 100644 --- a/subjects/graphql/README.md +++ b/subjects/graphql/README.md @@ -48,7 +48,7 @@ for example: [github-pages](https://pages.github.com/), [netlify](https://www.ne ### Usage -> To test your queries you can access the GraphQL IDE on _https://((DOMAIN))/public/subjects/graphql/_ or create your own [**GraphiQL Docs**](https://github.com/graphql/graphiql). This will give you a bigger picture of the tables, attributes and all the types of queries that you can do. +> To test your queries you can access the GraphQL IDE on _https://((DOMAIN))/graphiql/_ or create your own **GraphiQL Docs**. This will give you a bigger picture of the tables, attributes and all the types of queries that you can do. Here are the list of tables that you are allowed to query (it will be only provided the columns present on the tables): @@ -66,29 +66,29 @@ Here are the list of tables that you are allowed to query (it will be only provi This table will give you access to XP and audits ratio - | id | type | amount | objectId | userId | - | --- | :--: | -----: | -------: | -----: | - | 1 | xp | 234 | 42 | 1 | - | 2 | xp | 1700 | 2 | 2 | - | 3 | xp | 175 | 64 | 3 | + | id | type | amount | objectId | userId | createdAt | path | + | --- | :--: | -----: | -------: | -----: | -------------------------------: | ---------------------: | + | 1 | xp | 234 | 42 | 1 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | + | 2 | xp | 1700 | 2 | 2 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | + | 3 | xp | 175 | 64 | 3 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | - **Progress table**: - | id | userId | objectId | grade | - | --- | :----: | -------: | ----: | - | 1 | 1 | 3001 | 1 | - | 2 | 2 | 198 | 0 | - | 3 | 3 | 177 | 1 | + | id | userId | objectId | grade | createdAt | updatedAt | path | + | --- | :----: | -------: | ----: | -------------------------------: | -------------------------------: | --------------------------: | + | 1 | 1 | 3001 | 1 | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/piscine-go/quest-01 | + | 2 | 2 | 198 | 0 | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/piscine-go/quest-01 | + | 3 | 3 | 177 | 1 | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/piscine-go/quest-01 | - **Results table**: Both progress and result table will give you the student progression - | id | objectId | userId | grade | progressId | type | - | --- | -------: | -----: | ----: | ---------: | ---: | - | 1 | 3 | 1 | 0 | 58 | | - | 2 | 23 | 1 | 0 | 58 | | - | 3 | 41 | 6 | 1 | 58 | | + | id | objectId | userId | grade | progressId | type | createdAt | updatedAt | path | + | --- | -------: | -----: | ----: | ---------: | ---: | -------------------------------: | -------------------------------: | ---------------------: | + | 1 | 3 | 1 | 0 | 58 | | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | + | 2 | 23 | 1 | 0 | 58 | | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | + | 3 | 41 | 6 | 1 | 58 | | 2021-07-26T13:04:02.301092+00:00 | 2021-07-26T13:04:02.301092+00:00 | /madere/div-01/graphql | - **Object table**: @@ -152,7 +152,7 @@ You can see the result using `curl`: - `curl "https://((DOMAIN))/api/graphql-engine/v1/graphql" --data '{"query":"{user(where:{id:{_eq:6}}){id login}}"}'` -In graphQL the usage of arguments can be specified in the schema of the API. Like said above you can visit the _docs_ for the graphQL endpoint, _https://((DOMAIN))/public/subjects/grapqhl_ +In graphQL the usage of arguments can be specified in the schema of the API. Like said above you can visit the _docs_ for the graphQL endpoint, _https://((DOMAIN))/graphiql_ Example of nesting, using the result and user table : diff --git a/subjects/graphql/index.html b/subjects/graphql/index.html deleted file mode 100644 index 60e86fe6..00000000 --- a/subjects/graphql/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - - GraphiQL - - - -
- - - - - - - - \ No newline at end of file diff --git a/subjects/grouping/README.md b/subjects/grouping/README.md index 3d635f67..ab454487 100644 --- a/subjects/grouping/README.md +++ b/subjects/grouping/README.md @@ -4,11 +4,11 @@ Write a program that receives two strings and replicates the use of brackets in regular expressions. Brackets in regular expressions returns the words that contain the expression inside of it. -The program should handle the "`|`" operator, that searches for both strings on each side of the operator. +The program should handle the "`|`" operator, which searches for both strings on each side of the operator. -The output of the program should be the results of the regular expression by order of appearance in the string, being themselves identified by a number. +The output of the program should be, the results of the regular expression, numbered and displayed by the order of appearance in the string. -If the number of arguments is different from 2, if the regular expression is not valid, if the last argument is empty or there are no matches the program should print nothing. +If the number of arguments is different from 2, if the regular expression is not valid, if the last argument is empty or if there are no matches, the program should print nothing. ### Usage diff --git a/subjects/guess-it-1/README.md b/subjects/guess-it-1/README.md new file mode 100644 index 00000000..f0664010 --- /dev/null +++ b/subjects/guess-it-1/README.md @@ -0,0 +1,76 @@ +## guess-it-1 + +### Objectives + +Now that you have the math skills up and running , it is time for you to guess numbers. Find a way to implement the `math-skills` exercise into this one. + +### Instructions + +That is right, you must build a program that given a number as standard input, prints out a range in which the next number provided should be. + +The data received by the program, as always, will be presented as the following example: + +```console +189 +113 +121 +114 +145 +110 +... +``` + +This data represents a graph in which the values of the x axis are the number of the lines (0, 1, 2, 3, 4, 5 ...) and the values of the y axis are the actual numbers (189, 113, 121, 114, 145, 110...). + +Each of the numbers will be your standard input and the purpose of your program is for you to find the range in which the next number will be in. +This range should have a space separating the lower limit from the upper one like in the example: + +```console +>$ ./your_program +189 --> the standard input +120 200 --> the range for the next input, in this case for the number 113 +113 --> the standard input +160 230 --> the range for the next input, in this case for the number 121 +121 --> the standard input +110 140 --> the range for the next input, in this case for the number 114 +114 --> the standard input +100 200 --> the range for the next input, in this case for the number 145 +145 --> the standard input +1 99 --> the range for the next input, in this case for the number 110 +110 --> the standard input +100 150 --> the range for the next input, in this case for the number +145 +... +``` + +As seen above, some of the ranges are not correct and some are bigger than others. As this is just an example, if you so wish, a specific range in your program can be given. That is fully up to you to decide. The intent of this exercise is to use the calculations you did in the `math-skills` exercise to guess the numbers. + +### Testing + +Your program will be extensively tested, so performance should be prioritized. Testing will work as follow: + +If you guess correctly the range for the next given number, your score will be incremented based on the size of your range. In other words, the bigger your range is, the smaller your score will be. So we advise you to find the perfect balance between a small range and a good guess. + +In order for auditors to test your program, you will have to follow the next steps: + +- create a folder called **`student`** +- copy the files that are needed to run your program into this folder +- write an **executable** shell script named `script.sh` containing the command(s) to run your program, **from the root folder of the provided tester** (see below where to find it) + +Here is a following example of the script, assuming that the program is called `solution` and was written in JS(Javascript): + +```sh +#!/bin/sh +# We assume that we are on the root folder, so we have to enter the +# student folder in order to run the `solution.js` file +node ./student/solution.js +``` + +You can choose in which language you want to build your program. + +If you fail one of these steps, the test will not work. So we advise you to run the test by downloading [this zip file](https://assets.01-edu.org/guess-the-number.zip) containing the tester. You should place the `student/` folder in the root directory of the items provided and read its instructions. The data sets used to test this exercise will be `Data 1`, `Data 2` and `Data 3`. + +This project will help you learn about: + +- Statistical and Probabilities Calculation +- Scripting diff --git a/subjects/guess-it-1/audit/README.md b/subjects/guess-it-1/audit/README.md new file mode 100644 index 00000000..3c7c487b --- /dev/null +++ b/subjects/guess-it-1/audit/README.md @@ -0,0 +1,23 @@ +#### Functional + +##### After downloading [this zip file](https://assets.01-edu.org/guess-the-number.zip) containing a tester, follow its instructions (present in the README) in order to test the student program against the `big-range` program 3 times using the `Data 1`. + +###### Did the student won against `big-range` most of the times (at least 2 out of 3 times)? + +##### Try running the student program against the `big-range` program, using `Data 2` and then `Data 3` 3 times each. + +###### Did the student won against `big-range` most of the times (at least 2 out of 3 times for each)? + +##### Try running the student program against the `average` program, using `Data 1`, `Data 2` and `Data 3` 3 times each. + +###### Did the student won against `average` most of the times (at least 2 out of 3 times for each)? + +##### Try running the student program against the `median` program, using `Data 1`, `Data 2` and `Data 3` 3 times each. + +###### Did the student won against `median` most of the times (at least 2 out of 3 times for each)? + +#### Bonus + +##### Try running the student program against the `nic` program, using `Data 1`, `Data 2` and `Data 3` 3 times each. + +###### +Did the student won against `nic` most of the times (at least 2 out of 3 times for each)? diff --git a/subjects/guess-it-2/README.md b/subjects/guess-it-2/README.md new file mode 100644 index 00000000..200dcf7c --- /dev/null +++ b/subjects/guess-it-2/README.md @@ -0,0 +1,76 @@ +## guess-it-2 + +### Objectives + +Now that you have even more statistical knowledge, you will guess even more numbers. This time it will be a bit harder. + +### Instructions + +That is right, you must build a program that given a number as standard input, prints out a range in which the next number provided should be. Just like last time. + +The data received by the program, as always, will be presented as below: + +```console +189 +113 +121 +114 +145 +110 +... +``` + +This data represents a graph in which the values of the x axis are the number of the lines (0, 1, 2, 3, 4, 5 ...) and the values of the y axis are the actual numbers (189, 113, 121, 114, 145, 110...). + +Each of the numbers will be your standard input and the purpose of your program is for you to find the range in which the next number will be in. +This range should have a space separating the lower limit from the upper one like in the example: + +```console +>$ ./your_program +189 --> standard input +120 200 --> range for the next input, in this case for the number 113 +113 --> standard input +160 230 --> range for the next input, in this case for the number 121 +121 --> standard input +110 140 --> range for the next input, in this case for the number 114 +114 --> standard input +100 200 --> range for the next input, in this case for the number 145 +145 --> standard input +1 99 --> range for the next input, in this case for the number 110 +110 --> standard input +100 150 --> range for the next input, in this case for the number 145 +145 --> standard input +... +``` + +As you can see, some of the ranges are not correct and some are bigger than others. This is just an example. If you wish, you can give a specific range in your program, that is fully up to you to decide. The intent of this exercise is for you to use the calculations you did in the previous exercise (`linear_stats`) to guess the numbers. + +### Testing + +Your program will be extensively tested, so performance should be prioritized. Testing will work as follow: + +If you correctly guess the range for the next given number, your score will be incremented based on the size of your range. In other words, the bigger your range is, the smaller your score will be. So we advise you to find the perfect balance between a small range and a good guess. + +In order for auditors to test your program, you will have to follow the next steps: + +- create a folder called **`student`** +- copy the files that are needed to run your program into this folder +- write an **executable** shell script named `script.sh` containing the command(s) to run your program, **from the root folder of the provided tester** (see below where to find it) + +Here is a following example of the script, assuming that the program is called `solution` and was written in JS(Javascript): + +```sh +#!/bin/sh +# We assume that we are on the root folder, so we have to enter the +# student folder in order to run the `solution.js` file +node ./student/solution.js +``` + +You can choose in which language you want to build your program. + +If you fail one of these steps, the test will not work. So we advise you to run the test by downloading [this zip file](https://assets.01-edu.org/guess-the-number.zip) containing the tester. You should place the `student/` folder in the root directory of the items provided and read its instructions. The data sets used to test this exercise will be `Data 5` and `Data 6`. + +This project will help you learn about: + +- Statistical and Probabilities Calculations +- Scripting diff --git a/subjects/guess-it-2/audit/README.md b/subjects/guess-it-2/audit/README.md new file mode 100644 index 00000000..6923ee07 --- /dev/null +++ b/subjects/guess-it-2/audit/README.md @@ -0,0 +1,27 @@ +#### Functional + +##### After downloading [this zip file](https://assets.01-edu.org/guess-the-number.zip) containing a tester, follow its instructions (present in the README) in order to test the student program against the `big-range` program 3 times using the `Data 4`. + +###### Did the student won against `big-range` most of the times (at least 2 out of 3 times)? + +##### Try running the student program against the `big-range` program, using `Data 5` 3 times. + +###### Did the student won against `big-range` most of the times (at least 2 out of 3 times for each)? + +##### Try running the student program against the `linear-regr` program, using `Data 4` and `Data 5` 3 times each. + +###### Did the student won against `linear-regr` most of the times (at least 2 out of 3 times for each)? + +##### Try running the student program against the `correlation-coef` program, using `Data 4` and `Data 5` 3 times each. + +###### Did the student won against `correlation-coef` most of the times (at least 2 out of 3 times for each)? + +#### Bonus + +##### +Try running the student program against the `mse` program, using `Data 4` and `Data 5` 3 times each. + +###### +Did the student won against `mse` most of the times (at least 2 out of 3 times for each)? + +##### +Try running the student program against the `nic` program, using `Data 4` and `Data 5` 3 times each. + +###### +Did the student won against `nic` most of the times (at least 2 out of 3 times for each)? diff --git a/subjects/hello_rust/README.md b/subjects/hello_rust/README.md index 5761ab5c..58af8820 100644 --- a/subjects/hello_rust/README.md +++ b/subjects/hello_rust/README.md @@ -16,41 +16,29 @@ This repository will be the folder where all the exercices must be uploaded. Once created, clone that repository on your desktop. -If your username was `choumi` this is the command that will need to be used : +First, tell Git to remember your password (like a web browser would): -`git clone git@git.((DOMAIN)):choumi/((ROOT)).git` - -This command needs to be adapted with **your own username**. - -If the `git clone` gives you an authenticity of host error, your SSH key must be configured. -Follow the steps below. - -#### SSH Configuration - -Execute the following commands: - -```console -mkdir -p ~/.ssh -ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N '' -cat ~/.ssh/id_ed25519.pub +``` +git config --global credential.helper store ``` -- Copy the result and paste it in the content field of adding an SSH key in your [Gitea settings]() +If your username was `choumi` this is the command that will need to be used: -- Confirm by clicking on the add key button. +``` +git clone https://git.((DOMAIN))/choumi/((ROOT)).git +``` -Once this is done the git clone command should work now. +This command needs to be adapted with **your own username**. #### gitignore file -Once you repository is cloned, -create and edit the .gitignore file in your repository and add this line: +Once you repository is cloned, create and edit the .gitignore file in your repository and add this line: ```console **/target/* ``` -The goal of this setup is to avoid any binary files to be pushed in your gitea accidentaly. +The goal of this setup is to avoid any binary files to be pushed in your Gitea accidentally. Do not forget to push it to your repository. @@ -94,7 +82,7 @@ This command will compile, and run the binary. #### 4- return your solution -After that the `hello_rust` project is executing correctly, it needs to be uploaded to the repository with the following commands : +After that the `hello_rust` project is executing correctly, it needs to be uploaded to the repository with the following commands: 1. `git add hello_rust/` 2. `git commit -m "My very first rust commit"` diff --git a/subjects/hiddenp/README.md b/subjects/hiddenp/README.md index e3e226b3..48916545 100644 --- a/subjects/hiddenp/README.md +++ b/subjects/hiddenp/README.md @@ -6,7 +6,7 @@ Write a program named `hiddenp` that takes two `string` and that, if the first ` Let s1 and s2 be `string`. It is considered that s1 is hidden in s2 if it is possible to find each character from s1 in s2, **in the same order as they appear in s1.** -If s1 is an empty `string` it is considered hidden in any `string`. +If s1 is an empty `string`, it is considered hidden in any `string`. If the number of arguments is different from 2, the program displays nothing. diff --git a/subjects/introduction/README.md b/subjects/introduction/README.md index 748f2ec6..a2945d9b 100644 --- a/subjects/introduction/README.md +++ b/subjects/introduction/README.md @@ -6,61 +6,51 @@ Create in your [Gitea]() account the repository named `((ROOT))`. -This repository will be the folder where all the exercices must be uploaded. +This repository will be the folder where all the exercises must be uploaded. Once created, clone that repository on your desktop. -If your username was `choumi` this is the command that will need to be used : +To do so, open a Unix shell (e.g. Git Bash on Windows), you are going to type commands in it. -`git clone git@git.((DOMAIN)):choumi/((ROOT)).git` +First, tell Git to remember your password (like a web browser would): -This command needs to be adapted with **your own username**. - -If the `git clone` gives you an authenticity of host error, your SSH key must be configured. -Follow the steps below. - -#### SSH Configuration - -Execute the following commands: - -```console -mkdir -p ~/.ssh -ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N '' -cat ~/.ssh/id_ed25519.pub +``` +git config --global credential.helper store ``` -- Copy the result and paste it in the content field of adding an SSH key in your [Gitea settings]() +If your username was `choumi` this is the command that will need to be used: -- Confirm by clicking on the add key button. +``` +git clone https://git.((DOMAIN))/choumi/((ROOT)).git +``` -Once this is done the git clone command should work now. +This command needs to be adapted with **your own username**. #### 2- set -Once the repository is created, write your first shell program called `hello.sh` +Once the repository is created, use you code editor to write your first shell script called `hello.sh` -When executed this program must print `Hello choumi!` -Where `choumi` is your username +When executed, this script must print `Hello choumi!`, where `choumi` is your username. ##### Usage -If the username is `choumi` : +If the username is `choumi`: ```console -$ ./hello.sh +$ bash hello.sh Hello choumi! $ ``` #### 3- go-say-hello -After that the `hello.sh` is executing correctly, it needs to be uploaded to the repository with the following commands : +After that the `hello.sh` is executing correctly, it needs to be uploaded to the repository with the following commands: 1. `git add hello.sh` 2. `git commit -m "My very first commit"` 3. `git push` -Once these steps are applied, the file can now be submitted for grading on the platform by clicking on the "RUN INTRODUCTION TEST..." button. +Once these steps are applied, the file can now be submitted for grading on the platform by clicking on the "RUN INTRODUCTION TEST" button. This action will run the tests on your submitted `hello.sh` file. @@ -68,4 +58,4 @@ This action will run the tests on your submitted `hello.sh` file. Videos designed to give **hints** are assigned to each quest. It is strongly suggested to watch them as you go. -There is subtitles available in French and English. +There are subtitles available in French and English. diff --git a/subjects/ispowerof2/README.md b/subjects/ispowerof2/README.md index 39c06c6f..919cfee0 100644 --- a/subjects/ispowerof2/README.md +++ b/subjects/ispowerof2/README.md @@ -4,11 +4,11 @@ Write a program that determines if a given number is a power of 2. -This program must print `true` if the given number is a power of 2, otherwise it prints `false`. +This program must print `true` if the given number is a power of 2, otherwise it has to print `false`. -- If there is more than one or no argument the program should print nothing. +- If there is more than one or no argument, the program should print nothing. -- When there is only one argument, it will always be a positive valid int. +- When there is only one argument, it will always be a positive valid `int`. ### Usage : diff --git a/subjects/isprime/README.md b/subjects/isprime/README.md index ec0c648c..9d65db8d 100644 --- a/subjects/isprime/README.md +++ b/subjects/isprime/README.md @@ -8,6 +8,8 @@ The function must be optimized in order to avoid time-outs with the tester. (We consider that only positive numbers can be prime numbers) +(We also consider that 1 is **not** a prime number) + ### Expected function ```go diff --git a/subjects/issorted/README.md b/subjects/issorted/README.md index a09abfd5..819c9917 100644 --- a/subjects/issorted/README.md +++ b/subjects/issorted/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function `IsSorted` that returns `true` if the slice of `int` is sorted, and that returns `false` otherwise. +Write a function `IsSorted` that returns `true`, if the slice of `int` is sorted, and that returns `false` otherwise. The function passed in parameter returns a positive `int` if `a` (the first argument) is superior to `b` (the second argument), it returns `0` if they are equal and it returns a negative `int` otherwise. diff --git a/subjects/itoabase/README.md b/subjects/itoabase/README.md index 17ee139e..4ffa4eff 100644 --- a/subjects/itoabase/README.md +++ b/subjects/itoabase/README.md @@ -12,7 +12,7 @@ the base are the digits from 0 to 9, followed by uppercase letters from A to F. For example, the base `4` would be the equivalent of "0123" and the base `16` would be the equivalent of "0123456789ABCDEF". -If the value is negative, the resulting `string` has to be preceded with a +If the value is negative, the resulting `string` has to be preceded by a minus sign `-`. Only valid inputs will be tested. diff --git a/subjects/lcm/README.md b/subjects/lcm/README.md index 27e090b8..4be6741e 100644 --- a/subjects/lcm/README.md +++ b/subjects/lcm/README.md @@ -21,9 +21,14 @@ Here is a possible program to test your function : ```go package main +import ( + "fmt" + "student" +) + func main() { - fmt.Println(Lcm(2, 7)) - fmt.Println(Lcm(0, 4)) + fmt.Println(student.Lcm(2, 7)) + fmt.Println(student.Lcm(0, 4)) } ``` diff --git a/subjects/linear-stats/README.md b/subjects/linear-stats/README.md new file mode 100644 index 00000000..31082a67 --- /dev/null +++ b/subjects/linear-stats/README.md @@ -0,0 +1,46 @@ +## linear-stats + +This time, like in the first exercise, you will have to build a program that prints various statistical calculations. Now, you will focus on the `Linear Regression Line` and the `Pearson Correlation Coefficent`. + +### Instructions + +Your program must be able to read from a file and print the result of each statistic mentioned above. In other words, your program must be able to read the data present in the path passed as argument. The data in the file will be presented as below: + +```console +189 +113 +121 +114 +145 +110 +... +``` + +This data represents a graph in which the values of the x axis are the number of the lines (0, 1, 2, 3, 4, 5 ...) and the values of the y axis are the actual numbers (189, 113, 121, 114, 145, 110...). + +To run your program, a command similar to this one will be used if your project is made in Go: + +```sh +>$ go run your-program.go data.txt +``` + +After reading the file, your program should print the `Linear Regression Line` and the `Pearson Correlation Coefficient` in the following format: + +```console +Linear Regression Line: y = x + +Pearson Correlation Coefficient: +``` + +The values in between the single angle quotation marks (`< >`) should be a decimal number. The values for the `Linear Regression Line` should have 6 decimal places, while the `Pearson Correlation Coefficient` value should have 10 decimal places. + +#### Testing + +Your program will be tested by an auditor who will run a program provided by us, that creates a random data set of numbers and prints the result. The auditor task is to compare how your program performed. + +You can choose the language in which you want to build your program. + +This program will help you learn about: + +- Statistical and Probabilities Calculations + - [Linear Regression Line](https://en.wikipedia.org/wiki/Linear_regression) + - [Pearson Correlation Coefficient](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient) diff --git a/subjects/linear-stats/audit/README.md b/subjects/linear-stats/audit/README.md new file mode 100644 index 00000000..c8503774 --- /dev/null +++ b/subjects/linear-stats/audit/README.md @@ -0,0 +1,19 @@ +#### Functional + +##### After downloading the [file](https://assets.01-edu.org/stats-projects/linear-stats) and giving executable permissions, run the script with `./linear-stats` and then run the program of the student with the created `data.txt` by the previous command. + +###### Are the outputs of both programs (the one provided and the student one) in the same format? + +###### In the output of the student program, did the values on the Linear Regression Line contain 6 decimal places? + +###### In the output of the student program, did the values on the Pearson Correlation Coefficient contain 10 decimal places? + +###### Did the values of both programs match? + +##### Do the same procedure (running the script provided and the student program) 3 more times in order to test new data sets. + +###### Did the values of both programs match in all tries? + +#### Bonus + +###### +Did the student provided a README with an explanation on how to test his/her program? diff --git a/subjects/listforeachif/README.md b/subjects/listforeachif/README.md index 44a11da6..156c7b15 100644 --- a/subjects/listforeachif/README.md +++ b/subjects/listforeachif/README.md @@ -25,26 +25,25 @@ type List struct { Tail *NodeL } -func IsPositive_node(node *NodeL) bool { +func IsPositiveNode(node *NodeL) bool { switch node.Data.(type) { case int, float32, float64, byte: return node.Data.(int) > 0 - case string, rune: + default: return false } - return false } -func IsAl_node(node *NodeL) bool { +func IsAlNode(node *NodeL) bool { switch node.Data.(type) { case int, float32, float64, byte: return false - case string, rune: + default: return true } - return true } + func ListForEachIf(l *List, f func(*NodeL), cond func(*NodeL) bool) { } @@ -93,9 +92,9 @@ func main() { PrintList(link) fmt.Println("--------function applied--------") - piscine.ListForEachIf(link, PrintElem, piscine.IsPositive_node) + piscine.ListForEachIf(link, PrintElem, piscine.IsPositiveNode) - piscine.ListForEachIf(link, StringToInt, piscine.IsAl_node) + piscine.ListForEachIf(link, StringToInt, piscine.IsAlNode) fmt.Println("--------function applied--------") PrintList(link) diff --git a/subjects/make-it-better/README.md b/subjects/make-it-better/README.md index fa1e37ec..8ff4db44 100644 --- a/subjects/make-it-better/README.md +++ b/subjects/make-it-better/README.md @@ -2,7 +2,7 @@ ### Instructions -Create the files and directories so that when you use the command `ls` below the output will look like this : +Create the files and directories so that when you use the command `ls` below, the output will look like this : ```console $ TZ=utc ls -l --time-style='+%F %R' | sed 1d | awk '{print $1, $6, $7, $8, $9, $10}' @@ -20,7 +20,7 @@ dr-------x 1995-04-10 10:10 A $ ``` -Once it's done, use the command below to create the file `done.tar` to be submitted. +Once it is done, use the command below to create the file `done.tar` to be submitted. ```console $ tar -cf done.tar * diff --git a/subjects/math-skills/README.md b/subjects/math-skills/README.md new file mode 100644 index 00000000..133bef81 --- /dev/null +++ b/subjects/math-skills/README.md @@ -0,0 +1,57 @@ +## math-skills + +### Objectives + +The purpose of this project is for you to calculate the following: + +- Average +- Standard Deviation +- Variance +- Median + +### Instructions + +Your program must be able to read from a file and print the result of each statistic mentioned above. In other words, your program must be able to read the data present in the path passed as argument. The data in the file will be presented as the following example: + +```console +189 +113 +121 +114 +145 +110 +... +``` + +This data represents a graph in which the values of the x axis are the number of the lines (0, 1, 2, 3, 4, 5 ...) and the values of the y axis are the actual numbers (189, 113, 121, 114, 145, 110...). + +To run your program a command similar to this one will be used if your project is made in Go: + +```sh +>$ go run your-program.go data.txt +``` + +After reading the file, your program must execute each of the calculations asked above and print the results in the following manner (the following numbers are only examples): + +```console +Average: 35 +Standard Deviation: 65 +Variance: 5 +Median: 4 +``` + +Please note that the values are rounded integers. + +### Testing + +Your program will be tested by an auditor who will run a program provided by us. This program creates a random data set of numbers and prints the result. The auditor job is to compare how your program performed. + +You can choose the language in which you want to build your program. + +This project will help you learn about: + +- Statistics and Mathematics + - [Average](https://en.wikipedia.org/wiki/Average) + - [Standard Deviation](https://en.wikipedia.org/wiki/Standard_deviation) + - [Variance](https://en.wikipedia.org/wiki/Variance) + - [Median](https://en.wikipedia.org/wiki/Median) diff --git a/subjects/math-skills/audit/README.md b/subjects/math-skills/audit/README.md new file mode 100644 index 00000000..58be19d2 --- /dev/null +++ b/subjects/math-skills/audit/README.md @@ -0,0 +1,17 @@ +#### Functional + +##### After downloading the [file](https://assets.01-edu.org/stats-projects/math-skills) and giving executable permissions, run the script with `./math-skills` and then run the program of the student with the created `data.txt` by the previous command. + +###### Are the outputs of both programs (the one provided and the student one) in the same format? + +###### In the output of the student program, are the data types of the values rounded integers? + +###### Did the values of both programs match? + +##### Do the same procedure (running the script provided and the student program) 3 more times in order to test new data sets. + +###### Did the values of both programs match in all tries? + +#### Bonus + +###### +Did the student provided a README with an explanation on how to test his/her program? diff --git a/subjects/max/README.md b/subjects/max/README.md index d3b71e4b..8cb667dd 100644 --- a/subjects/max/README.md +++ b/subjects/max/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function, `Max`, that returns the maximum value in a slice of integers. If the slice is empty, returns 0. +Write a function `Max` that will return the maximum value in a slice of integers. If the slice is empty it will return 0. ### Expected function diff --git a/subjects/nbrconvertalpha/README.md b/subjects/nbrconvertalpha/README.md index ee21124c..fa76a104 100644 --- a/subjects/nbrconvertalpha/README.md +++ b/subjects/nbrconvertalpha/README.md @@ -6,7 +6,7 @@ Write a **program** that prints the corresponding letter in the `n` position of For example `1` matches `a`, `2` matches `b`, etc. If `n` does not match a valid position of the alphabet or if the argument is not an integer, the **program** should print a space (" "). -A flag `--upper` should be implemented. When used the program prints the result in upper case. The flag will always be the first argument. +A flag `--upper` should be implemented. When used, the program prints the result in upper case. The flag will always be the first argument. ### Usage diff --git a/subjects/now-get-to-work/README.md b/subjects/now-get-to-work/README.md index 77c2eb74..409602ad 100644 --- a/subjects/now-get-to-work/README.md +++ b/subjects/now-get-to-work/README.md @@ -11,7 +11,7 @@ Submit your solution in the file `my_answer.sh` that will print it when executed ### Utilisation ```console -$ ./my_answer.sh | cat -e +$ bash my_answer.sh | cat -e John Doe$ $ ``` diff --git a/subjects/olympic/README.md b/subjects/olympic/README.md index 62bf6487..b82df8ef 100644 --- a/subjects/olympic/README.md +++ b/subjects/olympic/README.md @@ -5,8 +5,9 @@ The Olympic games just ended and you want to tell everyone about the ranking of your favorite athlete: Pedro. +Look for the position of Pedro inside the array `athletes`. For the first to the third position, log the matching medal emoji 🥇🥈🥉. -Otherwhise log this disapointed emoji: 😞 and a message of his exact ranking. +Otherwise log this disapointed emoji: 😞 and a message of his exact ranking. Example, if pedro is in 10th place, the message to log would be: diff --git a/subjects/options/README.md b/subjects/options/README.md index 807c4b3c..544316be 100644 --- a/subjects/options/README.md +++ b/subjects/options/README.md @@ -41,5 +41,7 @@ $ go run . -eeeeee | cat -e 00000000 00000000 00000000 00010000$ $ go run . -% | cat -e Invalid Option$ +$ go run . - | cat -e +Invalid Option$ $ ``` diff --git a/subjects/phant0m-writ3r/README.md b/subjects/phant0m-writ3r/README.md index 0962c1f1..f65e44fd 100644 --- a/subjects/phant0m-writ3r/README.md +++ b/subjects/phant0m-writ3r/README.md @@ -23,5 +23,5 @@ left for good, but you still have an ace up your sleeve, you will write a bot ### Notions -- [startsWith](https://devdocs.io/javascript/global_objects/string/startsWith) -- [endsWith](https://devdocs.io/javascript/global_objects/string/endsWith) +- [startsWith](https://devdocs.io/javascript/global_objects/string/startswith) +- [endsWith](https://devdocs.io/javascript/global_objects/string/endswith) diff --git a/subjects/piglatin/README.md b/subjects/piglatin/README.md index 0d7d4390..bdb6c712 100644 --- a/subjects/piglatin/README.md +++ b/subjects/piglatin/README.md @@ -9,7 +9,7 @@ The rules used by Pig Latin are as follows: - If a word begins with a vowel, just add "ay" to the end. - If it begins with a consonant, then we take all consonants before the first vowel and we put them on the end of the word and add "ay" at the end. -If the word has no vowels the program should print "No vowels". +If the word has no vowels, the program should print "No vowels". If the number of arguments is different from one, the program prints nothing. diff --git a/subjects/pilot/README.md b/subjects/pilot/README.md index 332bd41a..e3b7f370 100644 --- a/subjects/pilot/README.md +++ b/subjects/pilot/README.md @@ -2,7 +2,7 @@ ### Instructions -Append to the code below what's needed so that the program compiles. +Append to the code below what is needed so that the program compiles. ### Usage diff --git a/subjects/printbits/README.md b/subjects/printbits/README.md index 15bf2dc6..99b6357a 100644 --- a/subjects/printbits/README.md +++ b/subjects/printbits/README.md @@ -4,7 +4,7 @@ Write a program that takes a number as argument, and prints it in binary value **without a newline at the end**. -- If the the argument is not a number the program should print `00000000`. +- If the the argument is not a number, the program should print `00000000`. ### Usage : diff --git a/subjects/printcomb/README.md b/subjects/printcomb/README.md index bb2dee3d..f4085887 100644 --- a/subjects/printcomb/README.md +++ b/subjects/printcomb/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that prints in ascending order on a single line all unique combinations of three different digits so that the first digit is lower than the second and the second is lower than the third. +Write a function that prints, in ascending order and on a single line: all **unique** combinations of three different digits so that, the first digit is lower than the second, and the second is lower than the third. These combinations are separated by a comma and a space. diff --git a/subjects/printcomb2/README.md b/subjects/printcomb2/README.md index 620b46d7..40043087 100644 --- a/subjects/printcomb2/README.md +++ b/subjects/printcomb2/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that prints in ascending order on a single line all possible combinations of two different two-digit numbers. +Write a function that prints in ascending order and on a single line: all possible combinations of two different two-digit numbers. These combinations are separated by a comma and a space. diff --git a/subjects/printcombn/README.md b/subjects/printcombn/README.md index 0e3f6eb2..38533f87 100644 --- a/subjects/printcombn/README.md +++ b/subjects/printcombn/README.md @@ -6,7 +6,7 @@ - n will be defined as : 0 < n < 10 -below are your references for the **printing format** expected. +Below are the references for the **printing format** expected. - (for n = 1) '0, 1, 2, 3, ..., 8, 9' diff --git a/subjects/printhex/README.md b/subjects/printhex/README.md index 5791e20b..a3951bc0 100644 --- a/subjects/printhex/README.md +++ b/subjects/printhex/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (with lowercase letters) followed by a newline (`'\n'`). +Write a program that takes a positive (or zero) number expressed in base 10, and that displays it in base 16 (with lowercase letters) followed by a newline (`'\n'`). - If the number of arguments is different from 1, the program displays nothing. - Error cases have to be handled as shown in the example below. diff --git a/subjects/printmemory/README.md b/subjects/printmemory/README.md index a0e5799a..8926a49b 100644 --- a/subjects/printmemory/README.md +++ b/subjects/printmemory/README.md @@ -2,16 +2,16 @@ ### Instructions -Write a function that takes `(arr [10]int)`, and displays the memory as in the example. +Write a function that takes `(arr [10]byte)`, and displays the memory as in the example. -After displaying the memory the function must display all the graphic characters. The non printable characters must be replaced by a dot. +After displaying the memory the function must display all the ASCII graphic characters. The non printable characters must be replaced by a dot. -A graphic character is any character intended to be written, printed, or otherwise displayed in a form that can be read by humans. In other words, it is any encoded character that is associated with one or more glyphs. +The ASCII graphic characters are any characters intended to be written, printed, or otherwise displayed in a form that can be read by humans, present on the ASCII encoding. ### Expected function ```go -func PrintMemory(arr [10]int) { +func PrintMemory(arr [10]byte) { } ``` @@ -24,7 +24,7 @@ Here is a possible program to test your function : package main func main() { - PrintMemory([10]int{104, 101, 108, 108, 111, 16, 21, 42}) + PrintMemory([10]byte{'h', 'e', 'l', 'l', 'o', 16, 21, '*'}) } ``` @@ -32,9 +32,9 @@ And its output : ```console $ go run . | cat -e -6800 0000 6500 0000 6c00 0000 6c00 0000 $ -6f00 0000 1000 0000 1500 0000 2a00 0000 $ -0000 0000 0000 0000 $ +68 65 6c 6c$ +6f 10 15 2a$ +00 00$ hello..*..$ $ ``` diff --git a/subjects/printnbrinorder/README.md b/subjects/printnbrinorder/README.md index d634dea0..674c46a7 100644 --- a/subjects/printnbrinorder/README.md +++ b/subjects/printnbrinorder/README.md @@ -3,7 +3,7 @@ ### Instructions Write a function which prints the digits of an `int` passed in parameter in ascending order. -All possible values of type `int` have to go through, besides negative numbers. +All possible values of type `int` have to go through, excluding negative numbers. Conversion to `int64` is not allowed. ### Expected function diff --git a/subjects/printwordstables/README.md b/subjects/printwordstables/README.md index 1ea60980..21cd4f55 100644 --- a/subjects/printwordstables/README.md +++ b/subjects/printwordstables/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that prints the words of a `string` slice that will be returned a function `SplitWhiteSpaces`. +Write a function that prints the words of a `string` slice that will be returned by a function `SplitWhiteSpaces`. Each word is on a single line (each word ends with a `\n`). diff --git a/subjects/real-time-forum/README.md b/subjects/real-time-forum/README.md index 1e85650c..cc41a51e 100644 --- a/subjects/real-time-forum/README.md +++ b/subjects/real-time-forum/README.md @@ -50,7 +50,7 @@ This part is pretty similar to the first forum. Users must be able to: Users will be able to send private messages to each other, so you will need to create a chat, where it will exist : -- A section to show who is online and able to talk to: +- A section to show who is online/offline and able to talk to: - This section must be organized by the last message sent (just like discord). If the user is new and does not present messages you must organize it in alphabetic order. - The user must be able to send private messages to the users who are online. @@ -69,8 +69,11 @@ As it is expected, the messages should work in real time, in other words, if a u ### Allowed Packages -- Only the [standard go](https://golang.org/pkg/) packages are allowed +- All [standard go](https://golang.org/pkg/) packages are allowed. - [Gorilla](https://pkg.go.dev/github.com/gorilla/websocket) websocket +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid This project will help you learn about: diff --git a/subjects/real-time-forum/typing-in-progress/README.md b/subjects/real-time-forum/typing-in-progress/README.md index ca6d6c7b..4a7807e0 100644 --- a/subjects/real-time-forum/typing-in-progress/README.md +++ b/subjects/real-time-forum/typing-in-progress/README.md @@ -25,8 +25,11 @@ To help with the display of the typing in progress you can take a look on the js ### Allowed Packages -- Only the [standard go](https://golang.org/pkg/) packages are allowed +- All [standard go](https://golang.org/pkg/) packages are allowed. - [Gorilla](https://pkg.go.dev/github.com/gorilla/websocket) websocket +- github.com/mattn/go-sqlite3 +- golang.org/x/crypto/bcrypt +- github.com/satori/go.uuid This project will help you learn about: diff --git a/subjects/reduceint/README.md b/subjects/reduceint/README.md index b19224f3..87cb06b6 100644 --- a/subjects/reduceint/README.md +++ b/subjects/reduceint/README.md @@ -2,7 +2,7 @@ ### Instructions -The function should have as parameters a slice of integers, `a []int` and a function `f func(int, int) int`. You should apply for each element of the slice the arithmetic function, saving it and printing. +The function should have as parameters a slice of integers `a []int` and a function `f func(int, int) int`. For each element of the slice, it should apply the function `f func(int, int) int`, save the result and then print it. ### Expected function diff --git a/subjects/revparams/README.md b/subjects/revparams/README.md index 52408319..1a9bf10b 100644 --- a/subjects/revparams/README.md +++ b/subjects/revparams/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a **program** that prints the arguments received in the command line in a reverse order. +Write a **program** that prints the arguments received in the command line in reverse order. Example of output : diff --git a/subjects/revwstr/README.md b/subjects/revwstr/README.md index 0d606feb..561063f7 100644 --- a/subjects/revwstr/README.md +++ b/subjects/revwstr/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a program that takes a `string` as a parameter, and prints its words in reverse. +Write a program that takes a `string` as a parameter, and prints its words in reverse, followed by a newline. - A word is a sequence of **alphanumerical** characters. diff --git a/subjects/romannumbers/README.md b/subjects/romannumbers/README.md index f70a72de..fce2a6eb 100644 --- a/subjects/romannumbers/README.md +++ b/subjects/romannumbers/README.md @@ -4,7 +4,7 @@ Write a program called `rn`. The objective is to convert a number, given as an argument, into a roman number and print it with its roman number calculation. -The program should have a limit of `4000`. In case of an invalid number, for example `"hello"` or `0` the program should print `ERROR: can not convert to roman digit`. +The program should have a limit of `4000`. In case of an invalid number, for example `"hello"` or `0` the program should print `ERROR: cannot convert to roman digit`. Roman Numerals reminder: @@ -37,7 +37,7 @@ The following table gives the Roman numerals for the first few positive integers ```console $ go run . hello -ERROR: can not convert to roman digit +ERROR: cannot convert to roman digit $ go run . 123 C+X+X+I+I+I CXXIII @@ -48,6 +48,6 @@ $ go run . 3999 M+M+M+(M-C)+(C-X)+(X-I) MMMCMXCIX $ go run . 4000 -ERROR: can not convert to roman digit +ERROR: cannot convert to roman digit $ ``` diff --git a/subjects/rot13/README.md b/subjects/rot13/README.md index 6e2b38f4..a8aa3549 100644 --- a/subjects/rot13/README.md +++ b/subjects/rot13/README.md @@ -3,7 +3,7 @@ ### Instructions Write a program that takes a `string` and displays it, replacing each of its -letters by the letter 13 spaces ahead in alphabetical order. +letters by the letter 13 spots ahead in alphabetical order. - 'z' becomes 'm' and 'Z' becomes 'M'. The case of the letter stays the same. diff --git a/subjects/rot14/README.md b/subjects/rot14/README.md index 61700061..c18aa671 100644 --- a/subjects/rot14/README.md +++ b/subjects/rot14/README.md @@ -2,7 +2,10 @@ ### Instructions -Write a function `rot14` that returns the `string` within the parameter transformed into a `rot14 string`, that replaces a letter with the 14th letter after it, in the alphabet. +Write a function `rot14` that returns the `string` within the parameter transformed into a `rot14 string`. +Each letter will be replaced by the letter 14 spots ahead in the alphabetical order. + +- 'z' becomes 'n' and 'Z' becomes 'N'. The case of the letter stays the same. ### Expected function @@ -25,7 +28,7 @@ import ( ) func main() { - result := piscine.Rot14("Hello How are You") + result := piscine.Rot14("Hello! How are You?") for _, r := range result { z01.PrintRune(r) diff --git a/subjects/rotatevowels/README.md b/subjects/rotatevowels/README.md index 75cfec46..ee94aee3 100644 --- a/subjects/rotatevowels/README.md +++ b/subjects/rotatevowels/README.md @@ -6,7 +6,7 @@ Write a **program** that checks the arguments for vowels. - If the argument contains vowels (for this exercise `y` is not considered a vowel) the program has to **"mirror"** the position of the vowels in the argument (see the examples). - If the number of arguments is less than 1, the program display a new line ("`\n`"). -- If the arguments does not have any vowels, the program just prints the arguments. +- If the arguments do not have any vowels, the program just prints the arguments. Example of output : diff --git a/subjects/searchreplace/README.md b/subjects/searchreplace/README.md index 6a3ff8aa..52adfef5 100644 --- a/subjects/searchreplace/README.md +++ b/subjects/searchreplace/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a program that takes 3 arguments, the first argument is a `string` in which to replace a letter (the 2nd argument) by another one (the 3rd argument). +Write a program that takes 3 arguments, the first argument is a `string` in which a letter (the 2nd argument) will be replaced by another one (the 3rd argument). - If the number of arguments is different from 3, the program displays nothing. @@ -13,6 +13,8 @@ Write a program that takes 3 arguments, the first argument is a `string` in whic ```console $ go run . "hella there" "a" "o" hello there +$ go run . "hallo thara" "a" "e" +hello there $ go run . "abcd" "z" "l" abcd $ go run . "something" "a" "o" "b" "c" diff --git a/subjects/slice/README.md b/subjects/slice/README.md index 89bd2b16..c2ad61f1 100644 --- a/subjects/slice/README.md +++ b/subjects/slice/README.md @@ -6,7 +6,7 @@ The function receives a slice of strings and one or more integers, and returns a In case there only exists one int, the resulting slice begins in the position indicated by the int and ends at the end of the received slice. -The integers can be lower than 0. +The integers can be negative. ### Expected function diff --git a/subjects/sortintegertable/README.md b/subjects/sortintegertable/README.md index 0849f2ec..933e7469 100644 --- a/subjects/sortintegertable/README.md +++ b/subjects/sortintegertable/README.md @@ -2,7 +2,7 @@ ### Instructions -- Write a function that reorder a slice of `int` in ascending order. +- Write a function that reorders a slice of `int` in ascending order. ### Expected function diff --git a/subjects/sqrt/README.md b/subjects/sqrt/README.md index 7434a071..7392215d 100644 --- a/subjects/sqrt/README.md +++ b/subjects/sqrt/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that returns the square root of the `int` passed as parameter if that square root is a whole number. Otherwise it returns `0`. +Write a function that returns the square root of the `int` passed as parameter, if that square root is a whole number. Otherwise it returns `0`. ### Expected function diff --git a/subjects/swap/README.md b/subjects/swap/README.md index 0c5b36f1..5bc20cd5 100644 --- a/subjects/swap/README.md +++ b/subjects/swap/README.md @@ -2,7 +2,7 @@ ### Instructions -- Write a function that swaps the contents of two **pointers to an `int`** (`*int`). +- Write a function that takes two **pointers to an `int`** (`*int`) and swaps their contents. ### Expected function diff --git a/subjects/teacher/README.md b/subjects/teacher/README.md index 6fcb8ead..72094859 100644 --- a/subjects/teacher/README.md +++ b/subjects/teacher/README.md @@ -4,7 +4,7 @@ "let's play!" -"A **true teacher** does not jealously guard his understanding." +"A **true teacher** does not jealously guard his mastery." The commissioner was most impressed by the result of your answers. He has now asked your help to create a training program for the future police inspectors. You gladly accept as you think that this will help lessen your burden of fighting crime in the future. @@ -13,11 +13,11 @@ In a training folder, various folders `mystery` were prepared with some key diff To simplify your life as a teacher and as the answers will not be exactly the same in each `mystery` folder, you need to write a `teacher.sh` file that does the following: -- step 1, it enters the `mystery` folder. -- step 2, it isolates, thru as similar command that you used to find it, and into an environment variable, the number (**and only the number**) of the key interview that helped solved the mystery (Unlike the interview number, the adress will not change across the `mystery` folders that will be tested, hence the command to find the interview is the same across all the `mystery` folder that will be tested). +- step 1, it enters the `mystery` folder.(again, the names will vary) +- step 2, it isolates, through a similar command that you used to find it, and into an environment variable, the number (**and only the number**) of the key interview that helped solved the mystery (Unlike the interview number, the address will not change across the `mystery` folders that will be tested, hence the command to find the interview is the same across all the `mystery` folders that will be tested). - step 3, it prints the newly created environment variable. - step 4, it prints what the interview contains. -- step 5, it executes the command that should have printed the shorted list of 4 suspects. (it shows only the license Plate, the Make, the Color, the Owner, and the Height) +- step 5, it executes the command that should have printed the short list of 4 suspects. (it only shows the license Plate, the Make, the Color, the Owner, and the Height) - step 6, it executes the command that should have gotten your main suspect convicted (as a reminder the result of that command should be the printing of a number) except that now you replace your suspect name with the environment variable MAIN_SUSPECT. - step 7, step 1 to 6 are repeated for each `mystery` folder of the training folder that the program works in. diff --git a/subjects/the-great-escape/README.md b/subjects/the-great-escape/README.md index db98da44..96bc4e4e 100644 --- a/subjects/the-great-escape/README.md +++ b/subjects/the-great-escape/README.md @@ -29,7 +29,7 @@ the character normaly means for a string_ ### Instructions Nothing can stop you now with that new knowledge. Like Houdini, master of -escapes, you are going to escape some strings: +escapes, in this exercise you are going to **escape some strings**: - Create a `escapeFromDelimiters` that includes all 3 quotes _(`` ` ``, `"` and `'`)_. diff --git a/subjects/to-git-or-not-to-git/README.md b/subjects/to-git-or-not-to-git/README.md index 03b660af..eb0a9002 100644 --- a/subjects/to-git-or-not-to-git/README.md +++ b/subjects/to-git-or-not-to-git/README.md @@ -15,7 +15,7 @@ curl -s https://((DOMAIN))/api/graphql-engine/v1/graphql --data '{"query":"{user ### Usage ```console -$ ./to-git-or-not-to-git.sh +$ bash to-git-or-not-to-git.sh 231748 $ ``` diff --git a/subjects/tolower/README.md b/subjects/tolower/README.md index 7c825a7d..23205146 100644 --- a/subjects/tolower/README.md +++ b/subjects/tolower/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a function that lower cases each letter of a `string`. +Write a function that lower cases for each letter of a `string`. ### Expected function diff --git a/subjects/trimatoi/README.md b/subjects/trimatoi/README.md index e9cf36d8..30cb10d0 100644 --- a/subjects/trimatoi/README.md +++ b/subjects/trimatoi/README.md @@ -4,7 +4,7 @@ - Write a function that transforms a number within a `string`, in an `int`. -- For this exercise the handling of the sign `-` **has** to be taken into account. If the sign is encountered before any number it should determine the sign of the returned `int`. +- For this exercise the handling of the `-` sign **has** to be taken into account. If the sign is encountered before any number it should determine the sign of the returned `int`. - This function will **only** return an `int`. In case of invalid input, the function should return `0`. diff --git a/subjects/union/README.md b/subjects/union/README.md index 8d7ed3b3..35a6d604 100644 --- a/subjects/union/README.md +++ b/subjects/union/README.md @@ -4,9 +4,9 @@ Write a program that takes two `string` and displays, without doubles, the characters that appear in either one of the `string`. -The display will be in the order that the characters will appear on the command line and will be followed by a newline (`'\n'`). +The display will be in the same order that the characters appear on the command line and will be followed by a newline (`'\n'`). -If the number of arguments is different from 2, then the program displays newline (`'\n'`). +If the number of arguments is different from 2, then the program displays a newline (`'\n'`). ### Usage diff --git a/subjects/wdmatch/README.md b/subjects/wdmatch/README.md index 9fa242ce..6e5f0e2e 100644 --- a/subjects/wdmatch/README.md +++ b/subjects/wdmatch/README.md @@ -2,7 +2,7 @@ ### Instructions -Write a program that takes two `string` and checks whether it is possible to write the first `string` with characters from the second `string`, while respecting the order in which these characters appear in the second `string`. +Write a program that takes two `string` and checks whether it is possible to write the first `string` with characters from the second `string`. This rewrite must respect the order in which these characters appear in the second `string`. If it is possible, the program displays the `string` followed by a newline (`'\n'`), otherwise it simply displays nothing. @@ -11,6 +11,8 @@ If the number of arguments is different from 2, the program displays nothing. ### Usage ```console +$ go run . 123 123 +123 $ go run . faya fgvvfdxcacpolhyghbreda faya $ go run . faya fgvvfdxcacpolhyghbred diff --git a/subjects/wget/README.md b/subjects/wget/README.md index d40e83ca..619001a9 100644 --- a/subjects/wget/README.md +++ b/subjects/wget/README.md @@ -10,7 +10,6 @@ These functionalities will consist in: - Downloading a single file and saving it under a different name - Downloading and saving the file in a specific directory - Set the download speed, limiting the rate speed of a download -- Continuing interrupted downloads - Downloading a file in background - Downloading multiple files at the same time, by reading a file containing multiple download links asynchronously - Main feature will be to download an entire website, [mirroring a website](https://en.wikipedia.org/wiki/Mirror_site) @@ -59,7 +58,22 @@ finished at 2017-10-14 03:46:07 Your program should be able to handle different flags. -1. Download a file and save it under a different name by using the flag `-O` followed by the name you wish to save the file, example: +1. The flag `-B` should be handled, this flag should download a file immediately to the background and the output should be redirected to a log file. When the program containing this flag is executed it should output : `Output will be written to "wget-log"`. Example: + +```console +$ go run . -B https://pbs.twimg.com/media/EMtmPFLWkAA8CIS.jpg +Output will be written to "wget-log". +$ cat wget-log +start at 2017-10-14 03:46:06 +sending request, awaiting response... status 200 OK +content size: 56370 [~0.06MB] +saving file to: ./EMtmPFLWkAA8CIS.jpg +Downloaded [https://pbs.twimg.com/media/EMtmPFLWkAA8CIS.jpg] +finished at 2017-10-14 03:46:07 +$ +``` + +2. Download a file and save it under a different name by using the flag `-O` followed by the name you wish to save the file, example: ```console $ go run . -O=meme.jpg https://pbs.twimg.com/media/EMtmPFLWkAA8CIS.jpg @@ -78,7 +92,7 @@ $ ls -l --- -2. It should also handle the path to where your file is going to be saved using the flag `-P` followed by the path to where you want to save the file, example: +3. It should also handle the path to where your file is going to be saved using the flag `-P` followed by the path to where you want to save the file, example: ```console $ go run . -P=~/Downloads/ -O=meme.jpg https://pbs.twimg.com/media/EMtmPFLWkAA8CIS.jpg @@ -96,7 +110,7 @@ $ ls -l ~/Downloads/meme.jpg --- -3. The program should handle speed limit. Basically the program can control the speed of the download by using the flag `--rate-limit`. If you download a huge file you can limit the speed of your download, preventing the program from using the full possible bandwidth of your connection, example: +4. The program should handle speed limit. Basically the program can control the speed of the download by using the flag `--rate-limit`. If you download a huge file you can limit the speed of your download, preventing the program from using the full possible bandwidth of your connection, example: ```console $ go run . --rate-limit=400k https://pbs.twimg.com/media/EMtmPFLWkAA8CIS.jpg @@ -106,7 +120,7 @@ This flag should accept different value types, example: k and M. So you can put --- -4. Downloading different files should be possible. For this the program will receive the `-i` flag followed by a file name that will contain all links that are to be downloaded. Example: +5. Downloading different files should be possible. For this the program will receive the `-i` flag followed by a file name that will contain all links that are to be downloaded. Example: ```console $ ls @@ -127,7 +141,7 @@ The Downloads should work asynchronously, it should download both files at the s --- -5. [**Mirror a website**](https://en.wikipedia.org/wiki/Mirror_site). This option should download the entire website being possible to use "part" of the website offline and for other useful [reasons](https://www.quora.com/How-exactly-does-Mirror-Site-works-and-how-it-is-done). For this you will have to download the website file system and save it into a folder that will have the domain name. Example: `http://www.example.com`, will be stored in a folder with the name `www.example.com` containing every file from the mirrored website. The flag should be `--mirror`. +6. [**Mirror a website**](https://en.wikipedia.org/wiki/Mirror_site). This option should download the entire website being possible to use "part" of the website offline and for other useful [reasons](https://www.quora.com/How-exactly-does-Mirror-Site-works-and-how-it-is-done). For this you will have to download the website file system and save it into a folder that will have the domain name. Example: `http://www.example.com`, will be stored in a folder with the name `www.example.com` containing every file from the mirrored website. The flag should be `--mirror`. The default usage of the flag will be to retrieve and parse the HTML or CSS from the given URL. This way retrieving the files that the document refers through tags. The tags that will be used for this retrieval must be `a`, `link` and `img` that contains attributes `href` and `src`. diff --git a/subjects/wget/audit/README.md b/subjects/wget/audit/README.md index 292be4e1..a81e4d35 100644 --- a/subjects/wget/audit/README.md +++ b/subjects/wget/audit/README.md @@ -68,6 +68,31 @@ http://ipv4.download.thinkbroadband.com/10MB.zip ###### Did the downloads occurred in an asynchronous way? (tip: look to the download order) +##### Try to run the following command, `"./wget -B http://ipv4.download.thinkbroadband.com/20MB.zip"` + +``` +Output will be written to ‘wget-log’. +``` + +###### Did the program output the statement above? + +###### Was the download made in "silence" (without displaying anything to the terminal)? + +##### Try and open the log file `"wget-log"`. + +``` +start at +sending request, awaiting response... status 200 OK +content size: <56370 [~0.06MB]> +saving file to: ./ +Downloaded [] +finished at +``` + +###### Is the structure of the file organized like above? + +###### And if so, was the file actually downloaded? + #### Mirror ##### Try to run the following command `"./wget --mirror http://corndog.io/"`, then try to open the `"index.html"` with a browser diff --git a/subjects/ztail/README.md b/subjects/ztail/README.md index ae3ea789..4cbe2142 100644 --- a/subjects/ztail/README.md +++ b/subjects/ztail/README.md @@ -10,7 +10,7 @@ For this program the `os` package can be used. Handle the errors by returning a non-zero exit status but process all the files. -If several files are given, print a new line and the file name between each one of them (see below). +If several files are given, print a newline and the file name between each one of them (see below). ### Usage