0% ont trouvé ce document utile (0 vote)
161 vues3 pages

Examen de Programmation JavaScript TS

Transféré par

Roda Rodi
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
161 vues3 pages

Examen de Programmation JavaScript TS

Transféré par

Roda Rodi
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Direction Régionale TTA

Examen de fin de module Régional


M105 : Programmation JavaScript

Filière : Développement Digital Epreuve : Théorique


Année : 2022-2023 Variante : 1 (Page 1/3)
Niveau : TS Barème : 40Pts
Date : 24/06/2023 Durée : 02h00

Dossier 1 : (12 points)

1. Comment accéder au prochain élément frère d'un élément dans le DOM ?


a) [Link]
b) [Link]
c) [Link]
d) [Link]()
2. Quel mot-clé est utilisé pour générer une exception personnalisée en JavaScript ?
a) Throw
b) Catch
c) Try
d) finally
3. Quel est le résultat de l'expression régulière suivante : /[0-9]{2}/.test("42") ?
a) True
b) False
c) SyntaxError
d) TypeError
4. Quelle est la méthode jQuery utilisée pour ajouter une classe CSS à un élément ?
a) addClass()
b) appendClass()
c) insertClass()
d) setClass ()
5. Comment sélectionne-t-on tous les éléments ayant la classe CSS "example" et dont le texte contient
le mot "jQuery" en utilisant jQuery ?
a) $(".example:contains('jQuery')")
b) $(".example").has("jQuery")
c) $("example:contains('jQuery')")
d) $("example").has("jQuery")
6. Quelle méthode JavaScript est utilisée pour créer une requête AJAX ?
a) fetch()
b) getJSON()
c) ajax()
d) sendRequest()
Direction Régionale TTA
Examen de fin de module Régional
M105 : Programmation JavaScript

Filière : Développement Digital Epreuve : Théorique


Année : 2022-2023 Variante : 1 (Page 2/3)
Niveau : TS Barème : 40Pts
Date : 24/06/2023 Durée : 2h

Dossier 2 : (28 points)

Pour gérer les notes des stagiaires de l'établissement à l'OFPPT, une page web statique est nécessaire.
Cette page contient un formulaire permettant de saisir les informations des stagiaires et de calculer leurs
notes.
Direction Régionale TTA
Examen de fin de module Régional
M105 : Programmation JavaScript

Filière : Développement Digital Épreuve : Théorique


Année : 2022-2023 Variante : 1 (Page 3/3)
Niveau : TS Barème : 40Pts
Date : 24/06/2023 Durée : 2h

1. Écrire le code HTML de la section "Informations du stagiaire". Les champs "Numéro d'inscription"
et "Nom complet" sont obligatoires à remplir. La vérification sera effectuée à l'aide de code JavaScript.
(6pts)

2. Programmer le code JQUERY/JavaScript permettant, suite au clic sur le bouton « Ajouter Stagiaire »,
d'insérer les données saisies dans un tableau HTML en respectant les contraintes suivantes : (12 pts)

a. Le numéro d'inscription doit commencer par "Stg" suivi de 4 chiffres (par exemple : Stg2123).
b. Le téléphone doit comporter 10 chiffres.
c. La valeur du statut peut prendre deux valeurs : "Admis" ou "Ajourné" (si note>=10, alors
"Admis", sinon "Ajourné").
d. La moyenne des notes sera calculée avec les coefficients. Chaque note saisie est multipliée par
son coefficient. Les résultats obtenus sont additionnés, puis la somme obtenue est divisée par la
somme des coefficients.

3. Programmer le code JQUERY/JavaScript permettant suite au clic sur le bouton « Nombre de stagiaires
admis » d’afficher, dans une division, le nombre de stagiaires admis. (5pts)

4. Programmer le code JQUERY/JavaScript permettant suite au clic sur le bouton « Nombre de stagiaires
Non admis » d’afficher, dans une division, le nombre de stagiaires Non admis. (5pts)

Common questions

Alimenté par l’IA

The jQuery method used to add a CSS class to an element is `addClass()`. You would use this method over vanilla JavaScript for its simplicity and cleaner syntax, especially when manipulating multiple elements or applying multiple class changes, as jQuery methods are chainable and handle browser inconsistencies effectively .

To display the number of students who have passed using jQuery, first filter the data based on the condition that defines 'passed', such as a score of 10 or higher being 'Admis'. Count these entries, and then display the result within a specific division using jQuery's text manipulation methods, such as `$('#passedCount').text(count)`, to reflect the calculated number of admitted students in the specified HTML element .

The correct keyword to generate a custom exception in JavaScript is `throw`. You can use it to throw any expression, such as an error object or a message of your choice, that can then be caught by a surrounding `try...catch` block to handle the error. For example, `throw new Error('Custom error message');` creates a new Error object with the specified message .

To calculate a student's average grade with weighted coefficients, first sum the products of each grade and its respective coefficient. Then, divide this sum by the total of the coefficients to find the weighted average. For example, if grades are [grade1, grade2] with coefficients [coef1, coef2], the algorithm is ((grade1 * coef1) + (grade2 * coef2)) / (coef1 + coef2). This ensures each grade's influence is proportionate to its assigned weight in the overall average calculation .

The method used to create an AJAX request in JavaScript is `fetch()`. This method returns a Promise that resolves to the Response object representing the response to the request. It is used for handling HTTP requests in a modern, promise-based manner, allowing for simpler and more readable asynchronous code when compared to the older `XMLHttpRequest` method. Despite its convenience, developers need to handle any potential network errors and utilize `Promise` methods such as `then()` and `catch()` to process the results .

The result of the regular expression /[0-9]{2}/ applied to the string '42' is `true`. This indicates that the pattern is looking for exactly two consecutive digits between 0 and 9, and it successfully finds those in the string '42', matching the two-digit pattern .

You can access the next sibling element of a selected element in the DOM using the `nextElementSibling` property. For example, `element.nextElementSibling` allows you to programmatically navigate to the next sibling that is an element node, skipping over any text or comment nodes .

In validating a student's registration number and phone number using JavaScript, the registration number must begin with 'Stg' followed by four digits, such as 'Stg2123'. This requires a regular expression to match this specific pattern. Meanwhile, the phone number must exactly consist of 10 digits, which can be validated using another regular expression to ensure there are neither more nor fewer digits. Both forms of validation are crucial to maintain data integrity and format consistency .

To select elements with a specific CSS class containing certain text using jQuery, you would use the selector `$('.className:contains("text")')`. This selects all elements with the given class name and also containing the specified text in their content. For example, `$('.example:contains("jQuery")')` selects elements with the class `example` that include the text 'jQuery' .

To programmatically count and display non-passing students using jQuery or JavaScript, start by filtering the data set for those who did not meet the 'passing' condition, such as having a score lower than 10. Once counted, output this total into an HTML division using a jQuery method like `.text()` or `.html()`, targeting the division by its ID or class, for instance, `$('#nonPassedCount').text(nonPassedCount)` .

Vous aimerez peut-être aussi