KKcbal / KingCobain

I love Asher
MIT License
0 stars 0 forks source link

Final FRQs #5

Open KKcbal opened 4 months ago

KKcbal commented 4 months ago

All the FRQs

Question 1 | 2D Arrays

There's no direct connections to our project when it comes to 2D Arrays, but it could be used in the quiz feature we plan to add in the future. The 2D Array could consist of arrays scores for separate classes.

quiz scores = 
{
    {1, 4, 2, 5, 2, 3}
    {2, 4, 5, 3, 4, 3}
    {5, 5, 2, 3, 4, 3}
}

Where each array is a single class. Teachers have the same classes, just across multiple periods. Sending the same quiz to different periods, but holding the data in a 2D Array could work be effective.

Question 2 | Classes

We had some classes in our project. One I know particularly well is the assignment class. I worked on the assignment frontend and backend, so I know the assignment class pretty well. Classes are an integral part of coding, and are demanded in Java. Classes allow us to create frameworks for ease of object creation while coding.

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Convert(attributeName ="assignment", converter = JsonType.class)
public class Assignment {

    // automatic unique identifier for Person record
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    // @NonNull, etc placed in params of constructor: "@NonNull @Size(min = 2, max = 30, message = "Name (2 to 30 chars)") String name"
    @NonNull
    @Size(min = 2, max = 30, message = "Name (2 to 50 chars)")
    private String name;

    //date the assignment is created
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date dateCreated;

    // the date the assignment is due
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date dateDue;

    @NonNull
    @Size(min=2, max=5000, message = "Content (2 to 5000 chars)")
    private String content;

    // classes assigned
    /* 
     * @ManyToMany
     * @JoinColumn(name="assignment_to_classes")
     * private Collection<ClassPeriod> classesAssigned = new ArrayList<>()
    */

    // Constructor used when building object from an API
    public Assignment(String name, Date dateCreated, Date dateDue, String content) {
        this.name = name;
        this.dateCreated = dateCreated;
        this.dateDue = dateDue;
        this.content = content;
    }
}

In the question we created a POJO, just like I did here in assignment, and has been done in other parts of our project. These POJOs are entities in our database, so they are a very important part of its functionality. We'll talk more about JPA repo in a later question, but that's how we access the POJO data and have it be persistent. For assignments, that means looking at assignments by due date and name, and in the problem FRQ, we looked at the word contents.

Question 3 | Arrays/ArrayLists

We use ArrayLists in our ClassPeriod class. It's important that we use an Array List because the amount we can hold is flexible. We can freely add and remove objects unlike Arrays, which have a predefined length that cannot be changed. The amount of students and assignments are ever-changing and it would be impossible to implement this code without the flexibility of ArrayLists.

    @ManyToMany(fetch = EAGER)
    private Collection<Person> students = new ArrayList<>();

    @ManyToMany(fetch = EAGER)
    private Collection<Assignment> assignments = new ArrayList<>();

ArrayLists are also used in the storage of security settings in SecurityConfig.java.

private CorsConfigurationSource corsConfigurationSource() {
        CorsConfiguration configuration = new CorsConfiguration();
        configuration.setAllowedOrigins(Arrays.asList("*"));
        configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
        configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-csrf-token"));
        configuration.setExposedHeaders(Arrays.asList("authorization"));
        configuration.setAllowCredentials(true);
        configuration.setAllowedOrigins(Arrays.asList("https://john-scc.github.io"));
        //configuration.setAllowedOrigins(Arrays.asList("http://localhost:4100"));

        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", configuration);
        return source;
    }

Question 4 | Methods and Control Structures

There's plenty of iteration, sequencing and selection in our project. A good piece I thought would fit is the Assignment post method. I've had a lot of trouble trying to post from the frontend, so this method stuck out to me. It also fits the bill. It iterates through class names and uses the condition that the class is found in our database to determine if it's not valid.

@PostMapping("/post")
    public ResponseEntity<Object> postAssignment(@RequestBody AssignmentRequest request) {
        for (String className : request.getClassNames()) {
            if (classService.getByName(className) == null) {
                return new ResponseEntity<>("One or more classes was invalid", HttpStatus.BAD_REQUEST);
            }
        }
        // A assignment object WITHOUT ID will create a new record with default roles as student
        Assignment assignment = new Assignment(request.getName(), request.getDateCreated(), request.getDateDue(), request.getContent());
        assignmentDetailsService.save(assignment);
        for (String className : request.getClassNames()) {
            classService.addAssignmentToClass(assignment.getId(), className);
        }
        return new ResponseEntity<>(assignment.getName() +" is created successfully", HttpStatus.CREATED);
    }

There's also an interface in AssignmentJpaRepository.java. It extends another interface and by outlining specific methods, it allows for us to create and implement in other java files.

public interface AssignmentJpaRepository extends JpaRepository<Assignment, Long> {

    Assignment findById(long id);

    List<Assignment> findByName(String name);

    // JPA query, findBy does JPA magic with "Name", "Containing", "Or", "Email", "IgnoreCase"
    //List<Assignment> findByNameContainingIgnoreCaseOrClassesContainingIgnoreCase(String name, arraylist classes);

    /* Custom JPA query articles, there are articles that show custom SQL as well
       https://springframework.guru/spring-data-jpa-query/
       https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods
    */
    List<Assignment> findByDateDue(Date dateDue);

    /*
      https://www.baeldung.com/spring-data-jpa-query
    */
}

Peer Grading

Title Calculations Score
FRQ (no bonus) 0.9 * (0.9 + 0.8 + 0.78 + 0.82) 2.97/3.6
PBL Connections (no bonus) 0.9 * (0.82 + 0.82 + 0.8 + 0.8) 2.916/3.6
drewreed2005 commented 4 months ago

Peer Grading

Peer grader: Drew Reed

FRQ Content Grading

Title Description Score
FRQ 1 All of your code is shown to be functional. I can tell you were considerate of showing that everything was functional when you created your main class testing method. I especially like your use of HashSets in the isDiverse method, since it prevents duplicate values, but keep in mind that LinkedHashSets, while requiring more memory, are able to retain order, while HashSets do not. It was also good to see your thought process and reasoning through thorough code comments. 0.9 / 1
FRQ 2 Your solution here doesn't seem to meet all of the requirements. You fail to define instance variables and do not include a constructor for the class's word solution. The getHint method isn't intended to be static, as it is intended to be applied specifically to the solution word saved to the class. Overall, it just seems like there was a slight lack of understanding of what the goal was with this class. You do, however, provide many code comments to explain what your thought was behind each line. You were very thorough in that regard, so good job. You also went above and beyond by making it a functional word guessing game, not just ensuring it worked on a basic level, so I gave some added credit for that. 0.8 / 1
FRQ 3 You showed good understanding for the most part in this problem. You correctly initialize the ArrayList of entries and we handled the getValueAt method in a very similar way. Adding a column setter to modify it was a good decision, though I'm not sure if College Board is okay with modifying that initial class, but there are workarounds available. This is another one where you don't provide insight into your thought process again, however, which isn't ideal. There's also one minor problem with your removeColumn method, which should completely remove sparse array entries from the entries ArrayList rather than just setting their value to 0. Your tester method was thorough, which was good to see. 0.78 / 1
FRQ 4 Good job with this one. Your interface does everything it needs to. Your contains method in Range is actually more efficient than mine and made me realize I did mine in a strange and roundabout way. Your MultipleGroups class properly utilizes the contains method of all applicable NumberGroup interfaced classes. I like how you showed understanding of the interface-class relationship in your main method with the comment, as well as how your use comments to explain what is being shown in the test. Once again, though, it would be good to see more comments or reflection materials that give insight into your answer and reasoning. 0.82 / 1
Total (no bonus) 0.9 * (0.9 + 0.8 + 0.78 + 0.82) 2.97/3.6

I think you definitely could have bumped up a lot of these scores if you put slightly more time into your answers. You clearly understood your own code, and you can tell that it was hand-written and not ChatGPTed, which a lot of people certainly can't say about theirs. It would have been even better to see that honesty behind your code through more comments, like you did in the second one.

PBL Reflections

Title Description Score
FRQ 1 I like that, because you couldn't show direct implementation of 2D arrays in your project, you proposed a possible way that they could be utilized. I think you could be slightly more clear on why that data type specifically would be the best option and what the full context of its implementation would be. It's good that you put thought into the future of your project or your part in it, however. This one was pretty brief. 0.82 / 1
FRQ 2 I was a little worried when you were just talking about Classes at first, but it was good to see you identify the connection between the two being POJOs and extended that to the purpose of your database. It's still pretty brief, but I think the content you showed was very valuable and showed good understanding. 0.82 / 1
FRQ 3 This is another very brief one, but I like that you showed understanding of the purpose of using ArrayLists (them having mutable length). It would be good to see more discussion into why this feature of ArrayLists mattered within this class (it was a ManyToMany relationship, so its length would have to be mutable). 0.8 / 1
FRQ 4 I'm glad you identified iteration, conditionals, and even an interface being used within your project. It's good to see understanding of the purpose being the JPA repository class. It could be more fleshed-out, once again, but I think you showed good thought with this answer and the contents you provided. 0.8 / 1
Total (no bonus) 0.9 * (0.82 + 0.82 + 0.8 + 0.8) 2.916 / 3.6

I think brevity here wasn't really the way to go, but I'm glad to see some valuable connections in the project that you were able to identify. I think the main thing hurting your scores was a lack of depth in responses sometimes, but in your short answers, you did a good job showing understanding of why certain things were implemented in your project. This was a good decision overall. Very good effort.