<!DOCTYPE html>

CPT Requirements

CPT Requirements

Adding Location and Review to History:

self.location_history.append({"user_id": user_id, "location": location, "review": review})
            

This code adds a user’s location and their review to the location_history list. It helps track the locations users have \ pinned along with their associated reviews, creating a historical log for future reference.

Student-Developed Procedure:

def save_location(self, user_id, latitude, longitude, review):
    """Save a specific location with its review.""" 
    location = {"user_id": user_id, "latitude": latitude, "longitude": longitude, "review": review} 
    self.location_history.append(location) 
    return location
            

The save_location method stores a user's latitude, longitude, and review for a particular location. This allows users to return to the same spot later by saving and referencing their data in the system.

Algorithm (Sequencing, Selection, Iteration):

try:
    location_data = request.get_json()

    if not location_data or 'latitude' not in location_data or 'longitude' not in location_data:
        return jsonify({"error": "Latitude and Longitude are required"}), 400
            

This code illustrates selection through the if statement. It checks whether the required fields (latitude and longitude) are present in the incoming request data. If missing, it returns an error message indicating that both coordinates are necessary.

Procedure Call:

location_response = self.save_location(user_id, latitude, longitude, review)
            

This line calls the save_location method to store the user's location and their review. It sends the received data to be saved and stores it in the system, preparing a response for the user.

Output Statement:

return jsonify({"message": "Location saved successfully", "location": location_response})
            

This statement sends a JSON response back to the user, confirming that their location and review have been saved successfully. It includes the saved location data to verify that the operation was successful.

CRUD Functionality in Model:

def create(self):
    """Save the location to the database.""" 
    db.session.add(self) 
    db.session.commit()
            

This create method adds the location object to the database session and commits it, effectively saving the new location record to the database. This supports the "Create" aspect of CRUD functionality.

MC Personal Reflection

Strengths:

  • Core Concepts: I did well on questions about basic programming, algorithms, and data representation (e.g., Q1, Q5, Q9).
  • Security & Privacy: I understood topics related to data security, such as Q9 (Transmit private data securely) and Q31 (Use of a copyrighted application).

Weaknesses:

  • Binary & Data Analysis: I struggled with questions on binary data (e.g., Q12, Q17) and need more practice in this area.
  • Error Detection: I had difficulty identifying code errors in questions like Q4 (Cause of overflow error) and Q15 (Program comparison).
  • Computational Thinking: Questions requiring the application of algorithms, like Q47 (Binary search) and Q50 (Reasonable time algorithms), were challenging.

Test-Taking Strategy:

  • Time Management: I spent too much time on some questions (e.g., Q32, Q54), so I need to work on pacing myself during the real exam.
  • Accuracy Over Speed: Some mistakes were due to rushing. I’ll focus on checking my work for accuracy.

Moving Forward:

I plan to review binary concepts and practice debugging. I’ll also work on time management by practicing with timed exams.

In summary, while I’m strong in certain areas, I need to focus on binary data, debugging, and computational problem-solving to improve my performance.