Skip to the content.

FRQ-PPR

FRQ

Checklist

i. The first program code segment must be a student-developed procedure that:

  • Defines the procedure’s name and return type (if necessary)
  • Contains and uses one or more parameters that have an effect on the functionality of the procedure
  • Implements an algorithm that includes sequencing, selection, and iteration
function analyzeMood(message) {
    for (let keyword of selfHarmKeywords) {
        if (message.toLowerCase().includes(keyword)) {
            userMood = "distressed";
            console.warn("Potential self-harm message detected.");
            break;
        }
    }
}
  • Defines the procedure’s name and return type: The function analyzeMood is clearly named and modifies the global variable userMood instead of returning a value.
  • Contains and uses parameters: The parameter message directly affects the function. If it contains concerning keywords, the mood changes to "distressed."
  • Implements sequencing, selection, and iteration: The function iterates through selfHarmKeywords, uses an if statement to check for matches, and updates userMood accordingly.

Formatted Text

ii. The second program code segment must show where your student-developed procedure is being called in your program.

document.getElementById('messageBox').addEventListener('keypress', async function(event) {
    if (event.key === 'Enter') {
        event.preventDefault();
        const userMessage = event.target.value;

        analyzeMood(userMessage);
  • Calls the student-developed procedure: The function analyzeMood is called inside the keypress event listener when the user presses "Enter."
  • Uses the function's parameter: The user’s input (userMessage) is passed as an argument to analyzeMood, allowing it to analyze the message.
  • Triggers the procedure based on user action: The event listener ensures the function is only called when the user submits a message, making it contextually relevant.

Formatted Text

List: Capture and paste two program code segments you developed during the administration of this task that contain a list (or other collection type) being used to manage complexity in your program.

i. The first program code segment must show how data have been stored in the list.

const selfHarmKeywords = ["hurt myself", "self-harm", "suicide", "cutting", "end it all", "worthless", "hopeless"];
let userMood = "neutral"; 


function analyzeMood(message) {
    for (let keyword of selfHarmKeywords) {
        if (message.toLowerCase().includes(keyword)) {
            userMood = "distressed";
            console.warn("Potential self-harm message detected.");
 
            break;
        }
    }
  • Example of list usage: The list selfHarmKeywords contains phrases related to self-harm. The function analyzeMood iterates through this list to check if the user’s message contains any concerning keywords.
  • Purpose of the list: The list helps simplify the code by storing multiple keywords in one place instead of using multiple if statements. This improves code readability and maintainability.
  • Planned complexity improvement: Although not implemented due to time constraints, I planned to enhance the detection system by using regex (regular expressions). This would allow broader and more flexible pattern matching, capturing variations of concerning messages beyond the exact keywords.
  • Impact of the list: Without the list, the code would require a separate condition for each keyword, making it lengthy and inefficient. The list provides a scalable and clear approach to handling multiple keywords with minimal code repetition.

ii. The second program code segment must show the data in the same list being used, such as creating new data from the existing data or accessing multiple elements in the list, as part of fulfilling the program’s purpose.

function analyzeMood(message) {
    for (let keyword of selfHarmKeywords) {
        if (message.toLowerCase().includes(keyword)) {
            userMood = "distressed";
            console.warn("Potential self-harm message detected.");

            break;
        }
    }
}

  • Use of the list: This function analyzeMood actively uses the selfHarmKeywords list by iterating through each keyword with a for...of loop.
  • Purpose of the iteration: The loop checks if the user's message contains any of the concerning keywords. If a match is found, it updates the global variable userMood to "distressed" and logs a warning to the console.
  • Efficiency through the list: By using a list, the code can process multiple keywords without needing separate if statements for each one. This reduces repetition and keeps the code simple and scalable.
  • Logical flow: The function reads the user's message, converts it to lowercase, and compares it against each keyword in the list. If a match occurs, the process stops with a break, ensuring unnecessary checks are avoided.
  • Example of practical use: For example, if the user writes, "I feel worthless", the function detects the keyword "worthless", triggers the warning, and adjusts the user's mood to "distressed".

Plan of Action to Improve My PPR for FRQ

Understand Key Concepts:

  • Review programming fundamentals, algorithms, and data analysis.
  • Utilize AP CSP prep books, online resources, and classroom notes.
Improve Code Complexity and Readability:
  • Enhance solutions by using efficient algorithms and appropriate data structures.
  • Use meaningful variable names and consistent formatting for clarity.
  • Break down code into functions to improve modularity and readability.
Thoroughly Explain Each Part of the Response:
  • Clearly describe the purpose of each function and major code segment.
  • Use precise terminology when explaining how the code meets the problem requirements.
  • Justify algorithm choices and explain how they improve efficiency or readability.
Focus on the Create Performance Task:
  • Follow the rubric carefully to meet all requirements.
  • Test and debug the program thoroughly.
  • Document the development process clearly and concisely.
Develop a Study Schedule:
  • Dedicate time daily to reviewing concepts and practicing FRQ-style coding questions.
  • Practice writing complete, well-commented solutions within a timed setting.
Seek Feedback and Guidance:
  • Discuss doubts with teachers or peers.
  • Get feedback on FRQ responses to refine explanations and improve clarity.
Simulate Full Exams:
  • Take practice exams under timed conditions to build confidence.
  • Analyze mistakes, refine explanations, and ensure all rubric criteria are met.

Comments