

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


November 2020. 2nd^ Midterm exam
Duration: 2 hours The objective of this problem is to develop an e-learning application that presents some questions to a student (only ONE) and checks the answers. The questions are organized in units of increasing level of difficulty. The number of questions in the system is always 250 and the number of units is 10
Section 1. (1 point). Design, create and initialize the data structures needed to develop the program: a) A vector of structures (questions) to store all the questions in the system. The information to store regarding a question is the number of the unit it belongs to, the text of the question, and the answer (that can only be true or false). b) A vector of structures (outcomes) storing the outcome of the student in the different units. The vector contains one outcome structure per unit, storing the unit number, the number of questions from that unit that have been asked to the student, and the number of correct answers given by the student in that unit. c) A vector of integers (usedQuestions) with the same number of elements as the vector of questions, where 1 in a given position indicates that this question has been asked to the student and 0 indicates the opposite. Add a drawing that represents the data structures you have defined. Initialize the number of correct and total questions for every unit to zero. You can do this either in the declaration of the structure or right after it.
Section 2. (1.5 points).
Implement the function selectQuestion to select one question from the vector of questions. The input parameters for this function are the vector with all the questions, the total number of questions in the system, the number of the unit, and the vector with the used questions. The output is the position of the selected question in the vector of questions (integer). The function searches (in the vector of questions) for the first question belonging to the unit -defined by the parameter -that has not been previously used. In case there are no questions left from that unit, the function returns -1.
The header for this function must be:
function pos=selectQuestion(questions, nQuestions, unit, usedQuestions)
Section 3. (2 points).
Write the function testUnit to present the questions from one unit to the user. The input parameters are the vector with all the questions, the total number of questions, the number of the unit to test and the vector with the used questions. The output is one structure of the type outcome and the updated vector with the used questions.
testUnit must call the function selectQuestion to select the question to ask, display the text question, read the user answer, and update the used questions and the number of correct answers in the unit. The number of questions to ask from a unit is 3 if it is possible. If there are only one or two questions from the unit left, the student will see only one or two questions. If there are no questions left, the student will see no questions and the function will return one outcome structure with the field representing the number of correct answers with the value -1.
The header for this function must be:
function [outcome,usedQuestions]= testUnit(questions, nQuestions, unit, usedQuestions)
November 2020. 2nd^ Midterm exam
Section 4. (2 points)
Write the main script of the system. The questions will be loaded from a MatLab binary file named questions.mat, containing the vector vQuestions, using the function load.
The program will start asking questions from the first unit, then the second and so on, up to the last unit (10). However, to make sure the student is making a consistent progress, he/she will only be moved on to the next unit if the number of correct answers is 2 or 3. If the number of correct answers is only one, the next turn of questions will belong to the same unit, and if no correct answer is given, in the next turn the questions will be selected from the previous unit (with the exception of unit one, in which case the next turn of questions will be again from unit one). You can assume that there will be always available questions for each unit.
After each turn of questions, the program will ask the student if he/she wants to force exit the program (exit the program without completing the 10 units)
You don’t need to repeat here the declaration/initialization of variables that you already did in section 1.
Section 5. (1.5 points)
Write a function called process Outcome to calculate the final mark of the student in each unit. The mark for each unit is 10 times the number of correctly answered questions divided by the total number questions asked by the program.
This function will create a new structure - userOutcome - containing the name of the user, the outcomes vector and the vector with the marks and save it to a binary file (using the function save). The name of the file will be marks.mat and the name of the student will be entered by the user.
Write as well the code that has to be added at the end of the main script in section 4 to calculate the final mark obtained by the student in each unit and to display the units that he or she should review. The program will display messages recommending the user to review any unit for which the mark is below 8. If the student has selected to exit the program without completing all the units, the outcome will not be processed
The header for this function must be: function userOutcome=processOutcome (outcomes, nUnits)
Section 6. ( 2 points )
Let’s now assume that 20 different users have been tested using the previous program and their results are stored in files like the one created in the previous section. The teachers want to analyze the results obtained by the 20 students to see which unit is the most difficult, by developing a different program. Assume this new program reads all the files and stores the data in a vector of structures called users according with the MatLab statements below. You don’t have to develop this part , just assume the vector users has already been initialized with the data from the files.
nUsers=20; users = struct('name',cell(1, nUsers), ... 'outcomes',cell(1, nUsers),... 'marks', cell(1, nUsers));
Write the MatLab code needed to identify the most difficult unit, defined as the unit in which the ratio of total correct answers given by the users divided by total questions asked to the users is lower.
Notes All the program outputs must have an appropriate format (use fprintf instead of disp)
Only the following MatLab functions can be used: zeros, ones, randi, struct and those explicitly referenced.